Unacceptable loading time due to mail.message object
The loading times of Odoo is unacceptably slow. The environment contains a large number of products (around 500.000 items) and 4100 attachments are stored in the database. The application server is a virtual machine with 2 gb of memory and the OpenERP version is 7.0. When using this application it sometimes take 10 minutes to finish the confirmation of a sale order!
To have an idea of what database queries are taking so long, I used the performance tool pg badger to give an analysis of the running database queries for three days. I focused on the normalized slowest queries. Surprising was the duration of the ir_attachment and the mail_message queries. Where I expected the duration of the product_product and product_template would be very long, they took much less than on these tables.
Here are the average durations:
ir_attachment : 18m45s
mail_message : 16m15s
product_product : 2m40s
The result of ir_attachment can be explained by the retrieving of large documents from the database and can be fixed by using a file system instead. And the mail_message records, this object is used everywhere among the application, for almost every action a message is stored to have activity logging like on september 28 user admin created this invoice. This is useful and nice to have some logging to the end user but I don't want this to take too much database effort at the expense of other queries. I also saw that is you create a quotation, a mail_message record is also created but when you remove this quotation, the mail_message is not deleted and is hold in the database a death data that will not have any value left.
I there a way to solve the mail_message issue taking too much effort in the database?
Or can I disable this functionality in an easy way?
For now I deleted the whole table mail_message, which consisted over 7.000.000 messages. I also implemented following code to prevent the creation of new messages:
_inherit = 'mail.message'
def create(self, cr, uid, values, context=None):