cockroachdb / cockroachdb/cockroach
sql: make `stats_as_of` more comprehensive
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
- [ ] Support time traveling to older than latestStableFullStatsCreationTime
- [ ] Support it for both normal and stable stats caches
----
In #162243, we introduced the stats_as_of session variable to enable limited time travel when selecting table statistics.
Currently, time travel is restricted to the latest statistics retained in the stable stats cache (i.e., the second most recent full statistics). As a result, users cannot select statistics older than what is available in the cache.
We should extend this functionality to support selecting table statistics from further back in time, beyond the current stable cache boundary.
The possible way is to query the table_statistics system table with AS OF SYSTEM TIME. One point is that we would emphasize the usage of this feature in stmt bundle creation, so that we can collect the table stats back in a historical timestamp.
Also, the usage of the `stats_as_of` session var is only limited for stable stats selection now, meaning it only takes effect when we are picking the stable stats for a table has canary stats window set. We should extend the usage for general use cases -- even for tables that don't have canary stats feature enabled, we should support the pick of table statistics for them as of system time.
Jira issue: CRDB-60253
Contributor guide
Assessment
This issue has not been assessed yet.