Through this strategy, time consumed by queries for my application have dropped to extreme lows; however, some queries consume more milliseconds than necessary.
The reason why is that upon examination of EXPLAIN ANALYZE, I found that sub-statements that depend upon the RETURNING of another query will still execute despite the source query returning an empty set.
In my application, I've reduced the number of queries from many 10s to four. All are bulk operations. The ones that have many sub-statements are the ones that consume 5ms or more. It's those I'd like to trim.
I gave functions another chance and tried to manually prevent chain sections by using IF statements. I had to use TEMPORARY TABLEs to store the RETURNING results and check them in the IFs.
I can't explain it, but the time consumed was 2 to 4x that consumed by the equivalent CTE.
To that end, is it possible to completely prevent a CTE sub-statement from executing if a RETURNING that it depends upon has no rows?
Aucun commentaire:
Enregistrer un commentaire