Skip to content

Save index recommendations per statement fingerprint id #83782

@maryliag

Description

@maryliag

Collect index recommendations per fingerprint id.

We don't want to collect recommendation for all executions, so only calculate if there is no recommendations calculated in-memory so far. Steps:

  1. Statement is executed
  2. Check if there is a recommendation in-memory (crdb_internal.cluster_statement_statistics)
    2a. If there isn't one, set a new flag to true indicating it should be calculated, and update here to also check this flag, calculate the recommendation and save in-memory
    2b. If there is one, keep the flag as false
  3. When the data in-memory flushed, replace the value persisted, with the latest value from memory

This solution keep the recommendations updated, and also doesn't generate a problem by calculating on every execution.

Challenge: since I'll calculate the rec the first time is added to in-memory, this means after a flush, there will be a spike on calculation, since everything will be new in-memory. Need to find a way to spread the calculation on the 10min period

Jira issue: CRDB-17261

Metadata

Metadata

Assignees

Labels

C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions