[FIX] crm.opportunity.report: query performance
[FIX] crm.opportunity.report: query performance

Using a subselect is more efficient than constructing
a complete temporary table of all messages, and then
joining them. This way only messages or relevant
opportunities are used, as most of the time the
report is accessed for a specific subset of opportunities
(by date, salesman, stage, etc.).
The query planner can then use the dedicated index
to quickly access the corresponding messages.

On a sample database with 1 million crm.lead
entries and 10 million mail.message entries
this brings the time for a typical read_group
call on crm.opportunity.report down from 300s to
500ms (600x faster)

bplancher/odoo,laslabs/odoo,stephen144/odoo,microcom/odoo,Elico-Corp/odoo_OCB,laslabs/odoo,Elico-Corp/odoo_OCB,storm-computers/odoo,sysadminmatmoz/OCB,stephen144/odoo,laslabs/odoo,microcom/odoo,dfang/odoo,sysadminmatmoz/OCB,dfang/odoo,ygol/odoo,storm-computers/odoo,hip-odoo/odoo,Elico-Corp/odoo_OCB,sysadminmatmoz/OCB,sysadminmatmoz/OCB,ygol/odoo,Elico-Corp/odoo_OCB,hip-odoo/odoo,ygol/odoo,ygol/odoo,hip-odoo/odoo,bplancher/odoo,microcom/odoo,storm-computers/odoo,sysadminmatmoz/OCB,microcom/odoo,dfang/odoo,microcom/odoo,bplancher/odoo,bplancher/odoo,bplancher/odoo,stephen144/odoo,Elico-Corp/odoo_OCB,laslabs/odoo,storm-computers/odoo,storm-computers/odoo,hip-odoo/odoo,microcom/odoo,stephen144/odoo,ygol/odoo,laslabs/odoo,dfang/odoo,hip-odoo/odoo,storm-computers/odoo,dfang/odoo,sysadminmatmoz/OCB,ygol/odoo,hip-odoo/odoo,stephen144/odoo,stephen144/odoo,bplancher/odoo,sysadminmatmoz/OCB,ygol/odoo,laslabs/odoo,Elico-Corp/odoo_OCB,dfang/odoo