forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: fix removal of histograms when printing table statistics
`PrintTableStats` is used by several variants of `EXPLAIN` to print an `ALTER TABLE INJECT STATISTICS` command with the current statistics for a given table. At least two of these variants (the existing `EXPLAIN (OPT, ENV)` and the upcoming `EXPLAIN ANALYZE (DEBUG, REDACT)`) want those statistics with histograms removed. We were removing histograms by simply deleting the `histo_buckets` JSON element, leaving behind some other histogram-related elements (`histo_col_type` and `histo_version`). As of cockroachdb#81793 the existence of these elements without `histo_buckets` indicates an empty table with an empty histogram, rather than a non-empty table without a histogram. To indicate a non-empty table without a histogram, we have to also remove `histo_version` and set `histo_col_type` to the empty string. (The difference currently only matters for statistics forecasting.) Epic: CRDB-19756 Release note: None
- Loading branch information
Showing
2 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters