-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Postgres query plan fix #45230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Postgres query plan fix #45230
Conversation
0cb7d3b to
5453fd6
Compare
| - Adds tests to verify proper connection closure. | ||
| Previously, the EXPLAIN query was using obfuscated queries with ? placeholders, which PostgreSQL does not recognize. | ||
| Now uses the raw query with $1, $2 placeholders that PostgreSQL expects. | ||
| Also orders top query results by calls DESC, stats_since DESC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also orders top query results by calls DESC, stats_since DESC.
I suggest we move this order change to another individual PR, as it is unrelated to issue #45190
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ORDER BY calls desc is to get queries with highest execution count in Top N, there is really no change in the data collected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is this change has nothing to do with issue #45190 (query plan issue). This is more like an additional enhancement combined with the fix. It is good to separate these, though I am fine to keep it combined.
ORDER BY calls desc is to get queries with highest execution count in Top N, there is really no change in the data collected
It may not change the result from a test environment, but it does change the collection behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the concern. However, given the slower review cycle for the PostgreSQL PRs, I chose to include this small change in the same PR to prevent additional delays. thanks!
Remove ORDER BY stats_since DESC in topQuery template
c290965 to
01e4234
Compare
Description
Fixing the bug where postgresql query plan were not getting generated. Reason being, the obfuscation done prior to EXPLAIN was causing errors. Now EXPLAIN gets unonfuscated query andpland generate correctly.
Another issue fixed here was adding of correct ORDER BY clause to the query to ensure correct set of TopN queries are collected.
ORDER BY CALLS DESC ensures we get queries with highest execution count in Top N, additionally we are sub-ordering by stats_since to ensure the query most recently first executed is also caught in Top N for the last 60 sec
Link to tracking issue
Fixes #45190
Testing
Unit tests updated. Also ran in internal environment for extended testing.