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 · 2 comments
Open

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

rytaft opened this issue Sep 27, 2024 · 2 comments
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 P-3 Issues/test failures with no fix SLA 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.

@github-project-automation github-project-automation bot moved this to Triage in SQL Queries Sep 27, 2024
@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
@michae2 michae2 moved this from Triage to 25.1 Release in SQL Queries Oct 1, 2024
@michae2 michae2 added the P-3 Issues/test failures with no fix SLA label Oct 1, 2024
@mgartner
Copy link
Collaborator

mgartner commented Nov 7, 2024

Some notes:

rytaft added a commit to rytaft/cockroach that referenced this issue Nov 14, 2024
rytaft added a commit to rytaft/cockroach that referenced this issue Nov 15, 2024
rytaft added a commit to rytaft/cockroach that referenced this issue Nov 15, 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 P-3 Issues/test failures with no fix SLA T-observability
Projects
Status: 25.1 Release
Development

No branches or pull requests

3 participants