Xavier ALT (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.1-opw-577963-odo into 
lp:openobject-addons/6.1.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-577963-odo/+merge/120588

Hi,

This improve the speed of ir.attachment search() method - making this usable 
for database with 100k+ attachments.
(coutesy of Mr. Olivier Dony)

MP corresponding to server MP: 
https://code.launchpad.net/~openerp-dev/openobject-server/6.1-opw-577963-odo/+merge/120586

Regards,
Xavier
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-577963-odo/+merge/120588
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.1-opw-577963-odo.
=== modified file 'document/document.py'
--- document/document.py	2011-12-19 16:54:40 +0000
+++ document/document.py	2012-08-21 14:48:50 +0000
@@ -187,6 +187,10 @@
         if not ids:
             return 0 if count else []
 
+        # Work with a set, as list.remove() is prohibitive for large lists of documents
+        # (takes 20+ seconds on a db with 100k docs during search_count()!)
+        ids = set(ids)
+
         # Filter out documents that are in directories that the user is not allowed to read.
         # Must use pure SQL to avoid access rules exceptions (we want to remove the records,
         # not fail), and the records have been filtered in parent's search() anyway.
@@ -198,8 +202,8 @@
         for doc_id, parent_id in doc_pairs:
             if parent_id in disallowed_parents:
                 ids.remove(doc_id)
-        return len(ids) if count else ids
 
+        return len(ids) if count else list(ids)
 
     def copy(self, cr, uid, id, default=None, context=None):
         if not default:

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to