auditing-table-statistics

Audit table statistics for staleness and coverage using SHOW STATISTICS.

18|8|Updated Feb 19, 2026
One-click install
npx skills add https://github.com/cockroachlabs/cockroachdb-skills --skill auditing-table-statistics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auditing-table-statistics
Source: https://github.com/cockroachlabs/cockroachdb-skills/tree/main/skills/observability-and-diagnostics/auditing-table-statistics
Command: npx skills add https://github.com/cockroachlabs/cockroachdb-skills --skill auditing-table-statistics

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Audits optimizer table statistics to detect staleness, missing coverage, and data quality issues, helping diagnose poor query performance and plan changes. This skill surfaces when statistics are outdated or incomplete and guides remediation with targeted CREATE STATISTICS commands.

Core Features & Use Cases

  • Detects stale table statistics and missing column histograms to improve cardinality estimates.
  • Highlights drift between actual row counts and cached statistics, enabling targeted refresh.
  • Provides workflows for post-bulk-load validation, performance triage, and routine health checks.
  • Generates ready-to-run remediation commands (CREATE STATISTICS) and monitors auto-collection status.

Quick Start

Run a statistics audit on target tables to surface stale or missing statistics and refresh them with CREATE STATISTICS as needed.

Frequently Asked Questions about auditing-table-statistics

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check if CockroachDB table statistics are stale or outdated?

To detect stale CockroachDB table statistics, audit them using SHOW STATISTICS to inspect metrics, calculate age and data drift, and identify outdated cardinality estimates that degrade query performance.

Why does my query plan suddenly change after a bulk data load?

Your query plan changes after a bulk load because cached optimizer statistics become stale and no longer reflect actual row counts. Auditing table statistics for staleness and drift helps diagnose this performance triage issue.

How do I refresh missing column statistics in CockroachDB?

To refresh missing column statistics in CockroachDB, audit your schemas to find missing histograms, then generate and run targeted CREATE STATISTICS commands to remediate the outdated data and update cardinality estimates.

Do I need special privileges to run a statistics health check on database schemas?

You need SQL access with any privilege on the target tables to run a routine statistics health check. This allows you to inspect metrics using SHOW STATISTICS and monitor auto-collection job status.

What is the best way to fix inaccurate cardinality estimates in the CockroachDB optimizer?

The best way to fix inaccurate cardinality estimates is to audit table statistics for coverage and drift, then execute generated CREATE STATISTICS commands to refresh the missing or outdated optimizer data.