ir.attachment: Index on res_model,res_id

_All_ client forms are trying to locate attachments of records, so they
are querying ir.attachment for their (res_model, res_id). Speed that up!

bzr revid: p_christ@hol.gr-20100627200016-gt9cyafm97if51e5
This commit is contained in:
P. Christeas
2010-06-27 23:00:16 +03:00
parent a2fbbc7c7c
commit 3d3bc04771
+7
View File
@@ -124,6 +124,13 @@ class ir_attachment(osv.osv):
'type': 'binary',
}
def _auto_init(self, cr, context=None):
super(ir_attachment, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = %s', ('ir_attachment_res_idx',))
if not cr.fetchone():
cr.execute('CREATE INDEX ir_attachment_res_idx ON ir_attachment (res_model, res_id)')
cr.commit()
ir_attachment()