[FIX] OPW 577963: ir_attachment: speed up ir.attachment search for large databases
[FIX] OPW 577963: ir_attachment: speed up ir.attachment search for large databases

Frequents calls to list.remove() were being a bottleneck for large
document lists (100k+). Using a set make remove() calls much faster.

Also turned a read() into a pure SQL command, as its high-level
features were unnecessary (security checks performed before and
after it anyways) and it was 50% slower than the direct SQL version.

This commit has a corresponding addons patch in order to use a set
instead of a list in the document module as well.
splbio/openobject-server,gisce/openobject-server,ovnicraft/openerp-server,gisce/openobject-server,gisce/openobject-server,ovnicraft/openerp-server,MarkusTeufelberger/openobject-server,vnc-biz/openerp-server,splbio/openobject-server,MarkusTeufelberger/openobject-server,vnc-biz/openerp-server,MarkusTeufelberger/openobject-server,splbio/openobject-server