Skip to content
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

Tweak explain_analyze helper invocation to avoid pg_hint_plan limitation #683

Conversation

msakrejda
Copy link
Contributor

For the collector-based Query Tuning workflow, the collector receives
a query text from the pganalyze server and runs it on the target
database. This query text may include pg_hint_plan hints, as users use
workbooks to optimize queries.

However, it looks like pg_hint_plan ignores hints if they are not in
the first comment in a query. The collector prepends a query marker
as a separate comment, and this causes pg_hint_plan to ignore any
hints specified in the query.

Avoid passing our query marker, since we're already prepending it to
the top-level explain_analyze invocation, and nested queries will not
show up in pg_stat_activity anyway.

For the collector-based Query Tuning workflow, the collector receives
a query text from the pganalyze server and runs it on the target
database. This query text may include pg_hint_plan hints, as users use
workbooks to optimize queries.

However, it looks like pg_hint_plan ignores hints if they are not in
the _first_ comment in a query. The collector prepends a query marker
as a separate comment, and this causes pg_hint_plan to ignore any
hints specified in the query.

Avoid passing our query marker, since we're already prepending it to
the top-level explain_analyze invocation, and nested queries will not
show up in pg_stat_activity anyway.
@msakrejda msakrejda requested a review from a team February 20, 2025 02:45
Copy link
Member

@lfittl lfittl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@msakrejda msakrejda merged commit d6c4b40 into main Feb 20, 2025
9 checks passed
@msakrejda msakrejda deleted the tweak-explain_analyze-helper-invocation-to-avoid-pg_hint_plan-limitation branch February 20, 2025 16:43
msakrejda added a commit that referenced this pull request Feb 20, 2025
msakrejda added a commit that referenced this pull request Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants