Validation of pyson domain
The validation of pyson domain groups them per evaluated domain but it is not enough to be fast in all cases. Simple domain like the one on Sale.shipment_address [1] generates in most cases unique domain for each record.
So this generates one search for each record validated, so the code is O(n) instead of O(1) (per bunch of 1000).
I think we could improve the heuristic by splitting the test into two cases:
- the number of different domains are low compare to the number of records, so we keep the current validation: [(id, in, ids), domain]
- the number of different domains is almost equals to the number of records tested. We must include in each domain the ids of the records. So it will become: domain = [(id, =, id), domain_for_id] and we group all those domains per bunch of ids.
[1] [('party', '=', If(Bool(Eval('shipment_party')), Eval('shipment_party'), Eval('party')))]