auditing-table-statistics

Audit CockroachDB table statistics for staleness, missing coverage, and drift.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Auditing CockroachDB table statistics helps identify stale or missing data distribution information that leads to inaccurate query plans, slow performance, and unexpected plan changes. This skill enables proactive health checks to surface statistics issues before they impact production queries.

Core Features & Use Cases

  • Detects staleness, missing column coverage, and drift in SHOW STATISTICS outputs.
  • Recommends and verifies CREATE STATISTICS commands to restore accurate estimates.
  • Supports monitoring and historical analysis across databases to maintain statistics hygiene.

Quick Start

Run SHOW STATISTICS on your target tables and review any staleness or drift to determine if a CREATE STATISTICS run is needed.

Frequently Asked Questions about auditing-table-statistics

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

FAQPage Schema
Why are my CockroachDB query plans suddenly changing or performing poorly?

Stale or missing table statistics cause the optimizer to generate inaccurate query plans. Auditing SHOW STATISTICS outputs identifies data drift and staleness so you can refresh estimates and restore predictable query performance.

How do I check for stale or missing table statistics in CockroachDB?

Run SHOW STATISTICS on target tables to review data distribution information. The audit detects staleness, missing column coverage, and drift to determine if running CREATE STATISTICS is necessary to restore accurate optimizer estimates.

When should I run a table statistics health check after bulk loading data?

Run a statistics health check post-bulk load to detect distribution drift and missing column coverage. Auditing SHOW STATISTICS outputs identifies stale data, ensuring the optimizer generates accurate query plans for both OLTP and OLAP workloads.

Can I audit table statistics safely without impacting production queries?

Yes, you can audit table statistics safely by applying AS OF SYSTEM TIME options. This enables read-only analysis of SHOW STATISTICS outputs across databases to surface staleness and drift issues without impacting production query performance.

What is the best way to refresh drifted table statistics for accurate query plans?

The best way to fix drifted statistics is generating and verifying CREATE STATISTICS commands based on SHOW STATISTICS audit results. This restores accurate data distribution estimates and corrects optimizer plan deviations.

Do I need special permissions to audit CockroachDB table statistics?

You need access to run SHOW STATISTICS and generate CREATE STATISTICS commands. These permissions allow read-only analysis of table statistics and the application of AS OF SYSTEM TIME options for safe statistics health checks.