I have a complex python-sql query with subqueries, joins, coalesce, case, round, groupby, etc. A lot of python-sql classes which uses params. All this become in ~250 query params.
When I try to evaluate query.params it takes ~9min long. Doing some prints in “params” method it does not freeze at one point but it is iterating all the time and I cannot find the problem. Probably the problem is the query complexity.
So I would like to know if is possible to avoid the use of params, for instance inserting these values on the query. Or use named parameters due to most of them are repeated and it will reduce the number of params.
No for security reason. The parameters must be escaped by the DB-API library.
This would mean that for each parameter we would need to search for identical parameter to see if it could be reuse. So it means adding a n log(n) operation.
To send to the server at the cost of more computation in python-sql.
I have extracted part of the python-sql code (it is implemented in several modules) with no Tryton dependency and uploaded here.
This example is not taking so much time (90s) as the complete query but it is representative.
It seems the problem is with join of subqueries (commenting them the time decreases).