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

sql/opt: index recommendations can significantly increase planning time #131544

Open
rytaft opened this issue Sep 27, 2024 · 1 comment
Open

sql/opt: index recommendations can significantly increase planning time #131544

rytaft opened this issue Sep 27, 2024 · 1 comment
Labels
A-sql-observability Related to observability of the SQL layer A-sql-optimizer SQL logical planning and optimizations. branch-release-23.2 Used to mark GA and release blockers, technical advisories, and bugs for 23.2 branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 branch-release-24.2 Used to mark GA and release blockers, technical advisories, and bugs for 24.2 C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-support Would prevent or help troubleshoot a customer escalation - bugs, missing observability/tooling, docs T-observability

Comments

@rytaft
Copy link
Collaborator

rytaft commented Sep 27, 2024

For certain types of complex queries, finding index recommendations can take significantly longer than the time to optimize or even execute the query. This is a problem because when the cluster setting sql.metrics.statement_details.index_recommendation_collection.enabled is true (which it is by default), we periodically collect index recommendations as part of execution to populate the DB Console SQL Insights. As a result, every few executions of a query could have high latency due to the time needed to collect index recommendations. This seems to have gotten worse in 23.2+ with #103782, which sometimes increases the number of index candidates considered.

We should prevent index recommendations from significantly increasing the latency of production queries. Some ideas:

  • Limit the time for index recommendations to some configurable value (maybe 1s by default). Don't collect recommendations if it takes longer than this (make the lack of recommendations due to a timeout visible in the SQL Insights page as well).
  • Provide a separate session setting to set the timeout for index recommendations on EXPLAIN.
  • Collect index recommendations in a separate goroutine to avoid increasing the latency of production queries.

Jira issue: CRDB-42591

@rytaft rytaft added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-support Would prevent or help troubleshoot a customer escalation - bugs, missing observability/tooling, docs A-sql-optimizer SQL logical planning and optimizations. A-sql-observability Related to observability of the SQL layer T-sql-queries SQL Queries Team labels Sep 27, 2024
Copy link

blathers-crl bot commented Sep 27, 2024

Hi @rytaft, please add branch-* labels to identify which branch(es) this C-bug affects.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@rytaft rytaft added branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 branch-release-23.2 Used to mark GA and release blockers, technical advisories, and bugs for 23.2 branch-release-24.2 Used to mark GA and release blockers, technical advisories, and bugs for 24.2 T-observability labels Sep 27, 2024
@exalate-issue-sync exalate-issue-sync bot removed the T-sql-queries SQL Queries Team label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-observability Related to observability of the SQL layer A-sql-optimizer SQL logical planning and optimizations. branch-release-23.2 Used to mark GA and release blockers, technical advisories, and bugs for 23.2 branch-release-24.1 Used to mark GA and release blockers, technical advisories, and bugs for 24.1 branch-release-24.2 Used to mark GA and release blockers, technical advisories, and bugs for 24.2 C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-support Would prevent or help troubleshoot a customer escalation - bugs, missing observability/tooling, docs T-observability
Projects
Status: Triage
Development

No branches or pull requests

1 participant