RE: Slow query fixed by replacing equality with a nested query

2022-01-21 Thread val.janeiko
My mistake. I have updated the query in the gist: cte1 should have been referenced in cte2. The query plans are correct. It was just the query in the gist that was incorrect (I was just verifying cte1 was the culprit – without it the query is fast too). This SQL query is a result of transl

Slow query performance inside a transaction on a clean database

2021-03-05 Thread val.janeiko
Hi everyone, I have a SELECT query that uses a long chain of CTEs (6) and is executed repeatedly as part of the transaction (with different parameters). It is executed quickly most of the time, but sometimes becomes very slow. I managed to consistently reproduce the issue by executing a transactio