cockroachdb / cockroachdb/cockroach

sql/stats: use merged and forcasted stats when populating `crdb_internal.table_row_statistics`

Open
#152,078 0 comments 0 reactions 0 assignees View on GitHub
A-sql-table-stats C-enhancement T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

We currently pull the latest (full) statistic for each table from `system.table_statistics` when populating row counts in `crdb_internal.table_row_statistics`, which is used by `SHOW TABLES`. We should pull `estimated_row_count` from merged or forecasted stats if they exist, similar to [SHOW STATISTICS](https://github.com/cockroachdb/cockroach/blob/22f815bbda846fc1a8b831ec99325f10ccd3dfe3/pkg/sql/show_stats.go#L67).

Jira issue: CRDB-53633

Contributor guide

Open the contributing guide

Research direction

Compare the row-count population for crdb_internal.table_row_statistics with the SHOW STATISTICS logic in pkg/sql/show_stats.go, focusing on system.table_statistics and estimated_row_count. Done means SHOW TABLES uses merged or forecasted statistics when available, while retaining the existing full statistic behavior otherwise.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.