docs
docs copied to clipboard
sql: improve docs around partial statistics
I noticed that we don't talk about partial statistics much in our docs. This feature was enabled initially in 25.1, and should probably be discussed in this page where we talk about stats: https://www.cockroachlabs.com/docs/stable/cost-based-optimizer#table-statistics. Automatic collection of partial stats is controlled with cluster settings sql.stats.automatic_partial_collection.enabled, sql.stats.automatic_partial_collection.min_stale_rows, and sql.stats.automatic_partial_collection.fraction_stale_rows; and table settings sql_stats_automatic_partial_collection_enabled, sql_stats_automatic_partial_collection_min_stale_rows, and sql_stats_automatic_partial_collection_fraction_stale_rows. Use of partial stats in the optimizer is controlled by optimizer_use_merged_partial_statistics. Partial stats can also be manually collected by using CREATE STATISTICS .... USING EXTREMES (and in 25.4 we'll also support CREATE STATISTICS .... WHERE <predicate>).
Here are a couple of relevant PRs: https://github.com/cockroachdb/cockroach/pull/133988 https://github.com/cockroachdb/cockroach/pull/142924 https://github.com/cockroachdb/cockroach/pull/139925 https://github.com/cockroachdb/cockroach/pull/127850
Jira issue: DOC-14809
cc @taroface
The RFC may be helpful too: https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/20220126_partial_statistics_collection.md
And the most recent QA: https://gist.github.com/rytaft/0798b8d2fc7db3d1a0a097c001cece1b