Dear community,
I have come up with a ORM method to compute the ongoing sale + credit amount of partners grouped by same register code (aka siren character). However the method is awfully slow and causes performance issues.
In order to fix the method I have tried translating the ORM method into a SQL query (for greater perfomance). Testing shows that the SQL query performs even worse than the ORM method.
I expect this shouldn't be the case..so... what am I doing wrong ?
ORM Method:
+ sum(line.price_subtotal for line in lines_order)
SQL method :