The canary window
When CockroachDB generates new statistics on a table, they begin in canary status. Thesql_stats_canary_window sets a canary window defining how long the statistics remain in canary status before being promoted to stable status. However, if new statistics are generated, the previous statistics are automatically promoted to stable status even if their canary window has not yet elapsed. If sql_stats_canary_window is set to 0, the canary statistics feature is disabled.
Example usage:
Queries with canary statistics
When the makes a plan for a query, it must determine whether to use canary statistics or stable statistics in its calculations. This determination is based on a probability configured in the . Queries do not mix stastistics types, so if a query is selected to use canary statistics, it uses them for all tables. Settingsql.stats.canary_fraction to 0 disables canary statistics across all queries.
Example usage:
canary_stats_mode . Set canary_stats_mode to force_canary to use only canary statistics for the duration of the session, or set it to force_stable to use only stable statistics. This variable is useful for debugging or troubleshooting specific queries.
Example usage:

