[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-cockroachdb-auditing-table-statistics":3,"mdc--3afk6t-key":39,"related-org-cockroachdb-auditing-table-statistics":3715,"related-repo-cockroachdb-auditing-table-statistics":3870},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":25,"repoUrl":26,"updatedAt":27,"license":28,"forks":29,"topics":30,"repo":34,"sourceUrl":37,"mdContent":38},"auditing-table-statistics","audit optimizer table statistics","Audits optimizer table statistics for staleness, missing coverage, and data quality issues using SHOW STATISTICS. Use when diagnosing poor query performance, unexpected plan changes, or after bulk data changes to identify stale statistics requiring refresh via CREATE STATISTICS.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"cockroachdb","CockroachDB","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fcockroachdb.png",[12,16,19,22],{"name":13,"slug":14,"type":15},"Performance","performance","tag",{"name":17,"slug":18,"type":15},"Audit","audit",{"name":20,"slug":21,"type":15},"Data Analysis","data-analysis",{"name":23,"slug":24,"type":15},"Database","database",3,"https:\u002F\u002Fgithub.com\u002Fcockroachdb\u002Fclaude-plugin","2026-07-12T07:57:16.190081",null,2,[31,32,8,33],"claude","cockroach-cloud","developer-tools",{"repoUrl":26,"stars":25,"forks":29,"topics":35,"description":36},[31,32,8,33],"CockroachDB development plugin for Claude","https:\u002F\u002Fgithub.com\u002Fcockroachdb\u002Fclaude-plugin\u002Ftree\u002FHEAD\u002Fskills\u002Fcockroachdb-observability-and-diagnostics\u002Fauditing-table-statistics","---\nname: auditing-table-statistics\ndescription: Audits optimizer table statistics for staleness, missing coverage, and data quality issues using SHOW STATISTICS. Use when diagnosing poor query performance, unexpected plan changes, or after bulk data changes to identify stale statistics requiring refresh via CREATE STATISTICS.\ncompatibility: Requires SQL access with any privilege on target tables (SELECT, INSERT, UPDATE, DELETE, or admin). Uses SHOW STATISTICS (production-safe, read-only).\nmetadata:\n  author: cockroachdb\n  version: \"1.0\"\n---\n\n# Auditing Table Statistics\n\nAudits optimizer table statistics for staleness, missing column coverage, and row count drift to diagnose poor query performance caused by outdated or incomplete statistics. Uses `SHOW STATISTICS` for read-only SQL analysis of table-level and column-level statistics freshness, entirely without requiring DB Console access.\n\n**Complement to profiling-statement-fingerprints:** This skill diagnoses optimizer statistics issues; for identifying historically slow queries, see [profiling-statement-fingerprints](..\u002Fprofiling-statement-fingerprints\u002FSKILL.md).\n\n## Prerequisites\n\n- SQL connection with any privilege on target tables\n- Automatic statistics collection enabled (default): `sql.stats.automatic_collection.enabled = true`\n\n**Related skills:** [profiling-statement-fingerprints](..\u002Fprofiling-statement-fingerprints\u002FSKILL.md) for historical query analysis, [triaging-live-sql-activity](..\u002Ftriaging-live-sql-activity\u002FSKILL.md) for live triage.\n\n## Core Concepts\n\n**CockroachDB-specific defaults:**\n- Automatic collection triggers at ~20% row count change (`sql.stats.automatic_collection.fraction_stale_rows`)\n- Auto-collection covers index column groups (when `sql.stats.multi_column_collection.enabled = true`, the default); ad-hoc multi-column stats on non-indexed columns require manual `CREATE STATISTICS`\n- Large tables (>10M rows) may have delayed auto-collection\n- Staleness thresholds: refresh if >7 days (OLTP) or >30 days (OLAP), or >20-30% row count drift\n\nSee [references\u002Fstatistics-thresholds.md](references\u002Fstatistics-thresholds.md) for workload-specific guidance.\n\n## Core Diagnostic Queries\n\n### Query 1: Identify Tables with Stale or Missing Statistics\n\nFinds tables with outdated statistics or no statistics at all, ranked by staleness.\n\n```sql\nWITH table_stats AS (\n  SELECT\n    table_catalog,\n    table_schema,\n    table_name,\n    column_names,\n    row_count,\n    created,\n    now() - created AS stats_age\n  FROM [SHOW STATISTICS FOR TABLE database_name.*]  -- Replace database_name\n  WHERE column_names = '{}'  -- Table-level stats only (empty array)\n)\nSELECT\n  table_schema || '.' || table_name AS full_table_name,\n  row_count,\n  created AS stats_created_at,\n  stats_age,\n  CASE\n    WHEN created IS NULL THEN 'Missing statistics'\n    WHEN stats_age > INTERVAL '30 days' THEN 'Very stale (>30d)'\n    WHEN stats_age > INTERVAL '7 days' THEN 'Stale (>7d)'\n    ELSE 'Fresh'\n  END AS staleness_status\nFROM table_stats\nWHERE stats_age > INTERVAL '7 days' OR created IS NULL  -- Adjust threshold\nORDER BY stats_age DESC NULLS FIRST\nLIMIT 50;\n```\n\n**Customization:**\n- Replace `database_name.*` with specific schema pattern (e.g., `mydb.public.*`)\n- Adjust staleness threshold: `INTERVAL '7 days'` for OLTP, `'30 days'` for OLAP\n- Increase `LIMIT` to see more tables\n\n**Key columns:**\n- `staleness_status`: Quick classification of statistics freshness\n- `stats_age`: Exact time since last collection\n- `row_count`: Last known table size\n\n### Query 2: Audit Statistics for Specific Table\n\nShows all statistics for a single table, including table-level and per-column details.\n\n```sql\nSELECT\n  column_names,\n  row_count,\n  distinct_count,\n  null_count,\n  created,\n  now() - created AS stats_age,\n  CASE\n    WHEN histogram_id IS NOT NULL THEN 'Yes'\n    ELSE 'No'\n  END AS has_histogram\nFROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\nORDER BY\n  CASE WHEN column_names = '{}' THEN 0 ELSE 1 END,  -- Table-level first\n  created DESC;\n```\n\n**Customization:**\n- Replace `database_name.schema_name.table_name` with fully-qualified table name\n\n**Key columns:**\n- `column_names`: Empty `{}` = table-level, single element = column-level\n- `distinct_count`: Cardinality for selectivity estimates\n- `null_count`: NULL value count for IS NULL predicates\n- `has_histogram`: Distribution data availability\n\n**Interpretation:**\n- First row (column_names = '{}') shows table-level row_count\n- Subsequent rows show per-column statistics\n- Missing columns indicate no statistics collected yet\n\n### Query 3: Detect Row Count Drift\n\nCompares current table row count against cached statistics to identify significant drift.\n\n```sql\nWITH current_count AS (\n  SELECT count(*) AS actual_rows\n  FROM database_name.schema_name.table_name  -- Replace with target table\n),\nstats_count AS (\n  SELECT row_count, created\n  FROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\n  WHERE column_names = '{}'  -- Table-level stats\n  ORDER BY created DESC\n  LIMIT 1\n)\nSELECT\n  c.actual_rows,\n  s.row_count AS stats_rows,\n  s.created AS stats_created_at,\n  now() - s.created AS stats_age,\n  ABS(c.actual_rows - s.row_count) AS drift_absolute,\n  ROUND(\n    ABS(c.actual_rows - s.row_count)::NUMERIC \u002F\n    NULLIF(s.row_count, 0) * 100,\n    2\n  ) AS drift_pct,\n  CASE\n    WHEN ABS(c.actual_rows - s.row_count)::NUMERIC \u002F NULLIF(s.row_count, 0) > 0.30 THEN 'High drift (>30%)'\n    WHEN ABS(c.actual_rows - s.row_count)::NUMERIC \u002F NULLIF(s.row_count, 0) > 0.20 THEN 'Medium drift (>20%)'\n    WHEN ABS(c.actual_rows - s.row_count)::NUMERIC \u002F NULLIF(s.row_count, 0) > 0.10 THEN 'Low drift (>10%)'\n    ELSE 'Minimal drift (\u003C10%)'\n  END AS drift_status\nFROM current_count c, stats_count s;\n```\n\n**Customization:**\n- Replace table name in both CTEs\n- Adjust drift thresholds (30%, 20%, 10%) based on workload tolerance\n\n**Key columns:**\n- `drift_pct`: Percentage difference between current and cached row count\n- `drift_status`: Classification for prioritization\n- `stats_age`: Time since statistics last refreshed\n\n**Interpretation:**\n- **>30% drift**: Urgent refresh recommended, optimizer estimates likely very inaccurate\n- **20-30% drift**: Consider refresh if experiencing performance issues\n- **10-20% drift**: Monitor for trends, may trigger automatic collection soon\n- **\u003C10% drift**: Normal variance, no action needed\n\n### Query 4: Identify Missing Column-Level Statistics\n\nFinds table columns without statistics, focusing on columns frequently used in WHERE\u002FJOIN clauses.\n\n```sql\nWITH table_columns AS (\n  SELECT column_name\n  FROM information_schema.columns\n  WHERE table_schema = 'schema_name'  -- Replace\n    AND table_name = 'table_name'    -- Replace\n    AND is_hidden = 'NO'             -- Exclude internal columns\n),\nstats_columns AS (\n  SELECT UNNEST(column_names) AS column_name\n  FROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\n  WHERE column_names != '{}'  -- Exclude table-level stats\n)\nSELECT\n  tc.column_name AS missing_column,\n  'No statistics available' AS status\nFROM table_columns tc\nWHERE tc.column_name NOT IN (SELECT column_name FROM stats_columns)\nORDER BY tc.column_name;\n```\n\n**Customization:**\n- Replace schema_name, table_name, and database_name with target table\n\n**Interpretation:**\n- Columns returned have no optimizer statistics\n- Prioritize creating statistics for columns used in:\n  - WHERE clause predicates (`WHERE user_id = 123`)\n  - JOIN conditions (`JOIN orders ON users.id = orders.user_id`)\n  - GROUP BY \u002F ORDER BY expressions\n\n**Action:** Generate CREATE STATISTICS commands (see Query 7)\n\n### Query 5: Histogram Coverage Analysis\n\nIdentifies columns with\u002Fwithout histogram data for range query optimization.\n\n```sql\nSELECT\n  UNNEST(column_names) AS column_name,\n  created,\n  now() - created AS stats_age,\n  CASE\n    WHEN histogram_id IS NOT NULL THEN 'Has histogram'\n    ELSE 'Missing histogram'\n  END AS histogram_status\nFROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\nWHERE column_names != '{}'  -- Exclude table-level stats\nORDER BY\n  CASE WHEN histogram_id IS NULL THEN 0 ELSE 1 END,  -- Missing first\n  created DESC;\n```\n\n**Customization:**\n- Replace database_name.schema_name.table_name\n\n**Key columns:**\n- `histogram_status`: Indicates distribution data availability\n- `stats_age`: Time since histogram last updated\n\n**Interpretation:**\n- **Has histogram**: Optimizer can estimate range scan selectivity (BETWEEN, >, \u003C)\n- **Missing histogram**: Optimizer uses uniform distribution assumption (less accurate)\n- Automatic collection creates histograms; missing indicates very new column or disabled collection\n\n### Query 6: Multi-Column Statistics Detection\n\nIdentifies existing multi-column (composite) statistics for correlated columns.\n\n```sql\nSELECT\n  column_names,\n  created,\n  now() - created AS stats_age,\n  row_count,\n  ARRAY_LENGTH(column_names, 1) AS column_count\nFROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\nWHERE ARRAY_LENGTH(column_names, 1) > 1  -- Multi-column only\nORDER BY created DESC;\n```\n\n**Customization:**\n- Replace database_name.schema_name.table_name\n\n**Key columns:**\n- `column_names`: Array of correlated columns\n- `column_count`: Number of columns in composite statistic\n\n**Interpretation:**\n- **Present**: Multi-column statistics exist — either auto-collected for an index column group or manually created\n- **Absent**: No multi-column stats yet; may need manual creation for correlated non-indexed columns (e.g., city + state + zip)\n- Common use case: Manual stats on correlated columns that aren't covered by an index\n\nSee [references\u002Fcreate-statistics-examples.md](references\u002Fcreate-statistics-examples.md) for multi-column creation patterns.\n\n### Query 7: Generate CREATE STATISTICS Recommendations\n\nProduces ready-to-run CREATE STATISTICS commands for tables with stale or missing statistics.\n\n```sql\nWITH stale_tables AS (\n  SELECT\n    table_schema,\n    table_name,\n    created,\n    now() - created AS stats_age\n  FROM [SHOW STATISTICS FOR TABLE database_name.*]\n  WHERE column_names = '{}'\n    AND (created IS NULL OR now() - created > INTERVAL '7 days')  -- Adjust threshold\n)\nSELECT\n  table_schema || '.' || table_name AS full_table_name,\n  stats_age,\n  'CREATE STATISTICS __auto__ FROM ' || table_schema || '.' || table_name || ';' AS create_command\nFROM stale_tables\nORDER BY stats_age DESC NULLS FIRST\nLIMIT 50;\n```\n\n**Customization:**\n- Replace `database_name.*` with schema pattern\n- Adjust `INTERVAL '7 days'` staleness threshold\n- Increase `LIMIT` for more recommendations\n\n**Output:**\n- `create_command`: Copy-paste ready SQL command\n- `__auto__`: Uses automatic column selection (recommended default)\n\n**Execution:**\n- Review generated commands before execution\n- Run during low-traffic periods for large tables (>10M rows)\n- Monitor job progress (see Query 6 for job monitoring)\n\n## Common Workflows\n\n### Workflow 1: Post-Bulk-Load Statistics Audit\n\n**Scenario:** After bulk INSERT\u002FCOPY\u002FIMPORT operation, validate statistics are current.\n\n**Steps:**\n\n1. **Identify affected tables:**\n   ```sql\n   -- List tables modified in last 24 hours\n   SELECT DISTINCT table_schema || '.' || table_name AS full_table_name\n   FROM [SHOW TABLES]\n   WHERE table_schema = 'target_schema';  -- Replace\n   ```\n\n2. **Check row count drift (Query 3):**\n   Run drift detection query for each affected table.\n\n3. **Generate and execute refresh commands (Query 7):**\n   ```sql\n   CREATE STATISTICS __auto__ FROM schema_name.table_name;  -- From Query 7 output\n   ```\n\n4. **Monitor collection job:**\n   ```sql\n   SELECT job_id, status, fraction_completed, running_status\n   FROM [SHOW JOBS]\n   WHERE job_type = 'CREATE STATS'\n     AND created > now() - INTERVAL '1 hour'\n   ORDER BY created DESC\n   LIMIT 10;\n   ```\n\n5. **Verify refresh (Query 2):**\n   Re-run statistics audit to confirm `created` timestamp updated.\n\n**Expected outcome:** Statistics age \u003C1 hour, drift_pct \u003C5%.\n\n### Workflow 2: Diagnose Unexpected Query Plan Changes\n\n**Scenario:** Query performance suddenly degrades; EXPLAIN shows different plan.\n\n**Steps:**\n\n1. **Identify affected query from [profiling-statement-fingerprints](..\u002Fprofiling-statement-fingerprints\u002FSKILL.md):**\n   Find query with latency spike or plan hash change.\n\n2. **Extract table references:**\n   Parse query text to identify tables in FROM\u002FJOIN clauses.\n\n3. **Audit statistics for each table (Query 2):**\n   Check staleness and row count currency.\n\n4. **Compare historical vs current row counts:**\n   ```sql\n   -- Example: Check if table grew significantly\n   SELECT row_count, created\n   FROM [SHOW STATISTICS FOR TABLE users]\n   WHERE column_names = '{}'\n   ORDER BY created DESC\n   LIMIT 5;  -- Last 5 collections\n   ```\n\n5. **Refresh stale statistics (Query 7):**\n   Execute CREATE STATISTICS for tables with high drift.\n\n6. **Validate plan stability:**\n   Re-run EXPLAIN to verify plan returns to expected structure.\n\n**Expected outcome:** Plan hash stabilizes, latency returns to baseline after statistics refresh.\n\n### Workflow 3: Routine Statistics Health Check\n\n**Scenario:** Periodic audit to proactively identify statistics issues before performance degrades.\n\n**Steps:**\n\n1. **Run cluster-wide staleness scan (Query 1):**\n   ```sql\n   -- All databases\n   SHOW STATISTICS FOR TABLE *.*;  -- Warning: May be slow on large clusters\n   ```\n\n2. **Prioritize critical tables:**\n   Focus on high-traffic tables from [profiling-statement-fingerprints](..\u002Fprofiling-statement-fingerprints\u002FSKILL.md).\n\n3. **Check automatic collection is enabled:**\n   ```sql\n   SHOW CLUSTER SETTING sql.stats.automatic_collection.enabled;  -- Should be true\n   ```\n\n4. **Review pending auto-collection jobs:**\n   ```sql\n   SELECT job_id, description, status, fraction_completed\n   FROM [SHOW JOBS]\n   WHERE job_type = 'AUTO CREATE STATS'\n     AND status IN ('pending', 'running')\n   ORDER BY created DESC;\n   ```\n\n5. **Generate batch refresh script (Query 7):**\n   Save output to file for scheduled execution.\n\n6. **Schedule refresh during maintenance window:**\n   Execute generated CREATE STATISTICS commands during low-traffic period.\n\n**Frequency:** Weekly for OLTP, monthly for OLAP.\n\n## Safety Considerations\n\n### Production-Safe Operations\n\n**SHOW STATISTICS:**\n- **Impact:** Read-only, no cluster impact\n- **Safe for production:** Yes, run anytime without restrictions\n\n**CREATE STATISTICS:**\n- **Impact:** CPU\u002FIO-intensive, non-blocking table scans\n- **Safety:**\n  - Does NOT lock table or block writes\n  - Consumes resources (CPU, network, disk I\u002FO)\n  - May impact query performance during collection on large tables\n- **Best practices:**\n  - Run during low-traffic periods for tables >10M rows\n  - Stagger execution (avoid creating statistics on many tables simultaneously)\n  - Monitor job progress and resource utilization\n\n### Resource Consumption\n\n**Small tables (\u003C10K rows):** Negligible impact, safe anytime\n\n**Medium tables (10K-10M rows):** Seconds to minutes, minor impact\n\n**Large tables (>10M rows):** Minutes to hours, plan accordingly:\n- Schedule during maintenance windows\n- Monitor cluster metrics (CPU, disk I\u002FO) during collection\n- Use `SHOW JOBS` to track progress\n\n**Cancellation (if needed):**\n```sql\n-- Find job ID\nSELECT job_id, status, fraction_completed\nFROM [SHOW JOBS]\nWHERE job_type = 'CREATE STATS' AND status = 'running';\n\n-- Cancel job (non-destructive, existing statistics remain)\nCANCEL JOB 123456789012345678;\n```\n\n### Batch Collection Best Practices\n\n**Avoid overwhelming cluster:**\n- Collect statistics for 3-5 tables concurrently maximum\n- Wait for completion before starting next batch\n- Monitor cluster health metrics between batches\n\n**Example staggered script:**\n```bash\n# Collect statistics in batches with delays\nfor table in table1 table2 table3; do\n  cockroach sql -e \"CREATE STATISTICS __auto__ FROM $table;\" &\ndone\nwait  # Wait for batch to complete\n\nsleep 60  # Delay between batches\n\nfor table in table4 table5 table6; do\n  cockroach sql -e \"CREATE STATISTICS __auto__ FROM $table;\" &\ndone\nwait\n```\n\nSee [references\u002Fcreate-statistics-examples.md](references\u002Fcreate-statistics-examples.md) for detailed batch patterns.\n\n## Troubleshooting\n\n| Issue | Likely Cause | Fix |\n|-------|--------------|-----|\n| **SHOW STATISTICS returns empty** | No statistics ever collected | Run `CREATE STATISTICS __auto__ FROM table_name;` |\n| **row_count shows 0 for non-empty table** | Statistics out of sync | Refresh: `CREATE STATISTICS __auto__ FROM table_name;` |\n| **Permission denied error** | No privileges on table | Grant any privilege: `GRANT SELECT ON table_name TO user;` |\n| **CREATE STATISTICS job stuck** | Large table with high write volume | Check `SHOW JOBS` status; consider `CANCEL JOB` and retry during low-traffic period |\n| **Automatic collection not triggering** | Setting disabled or threshold not met | Verify `sql.stats.automatic_collection.enabled = true` and check row count drift |\n| **Statistics exist but query plans still poor** | Stale statistics or missing multi-column stats | Refresh existing; create multi-column for correlated columns (see Query 6) |\n| **High drift but recent created timestamp** | Extreme write volume between collections | Lower automatic collection threshold or increase manual refresh frequency |\n\n### Defensive Query Patterns\n\n**Handle missing statistics:**\n```sql\n-- Use COALESCE for NULL created timestamps\nSELECT COALESCE(created, '1970-01-01'::TIMESTAMP) AS stats_created_at\nFROM [SHOW STATISTICS FOR TABLE table_name]\nWHERE column_names = '{}';\n```\n\n**Avoid division by zero in drift calculations:**\n```sql\n-- Use NULLIF to prevent divide-by-zero errors\nSELECT\n  ABS(actual - stats)::NUMERIC \u002F NULLIF(stats, 0) * 100 AS drift_pct\nFROM ...;\n```\n\n## Key Considerations\n\n- **Auto vs manual:** Keep automatic collection enabled for baseline; use manual `CREATE STATISTICS` for ad-hoc post-bulk-load refresh and critical tables\n- **Multi-column statistics:** Auto-collection covers index column groups; manual `CREATE STATISTICS` is needed for correlated non-indexed columns queried together (e.g., `CREATE STATISTICS city_state_stats ON city, state FROM addresses;`)\n- **Large tables (>10M rows):** Schedule `CREATE STATISTICS` during maintenance windows; monitor with `SHOW JOBS WHERE job_type = 'CREATE STATS'`\n- **Staleness tuning:** OLTP: 3-7 days, OLAP: 14-30 days, hybrid: critical tables 3-7 days, archive 30+ days\n- **Privilege:** Any table privilege (SELECT, INSERT, etc.) grants statistics visibility\n\nSee [references\u002Fcreate-statistics-examples.md](references\u002Fcreate-statistics-examples.md) and [references\u002Fstatistics-thresholds.md](references\u002Fstatistics-thresholds.md) for detailed guidance.\n\n## References\n\n**Official CockroachDB Documentation:**\n- [SHOW STATISTICS](https:\u002F\u002Fwww.cockroachlabs.com\u002Fdocs\u002Fstable\u002Fshow-statistics.html) - Complete syntax and output schema\n- [CREATE STATISTICS](https:\u002F\u002Fwww.cockroachlabs.com\u002Fdocs\u002Fstable\u002Fcreate-statistics.html) - Manual statistics collection guide\n- [Cost-Based Optimizer](https:\u002F\u002Fwww.cockroachlabs.com\u002Fdocs\u002Fstable\u002Fcost-based-optimizer.html) - How optimizer uses statistics\n- [Table Statistics](https:\u002F\u002Fwww.cockroachlabs.com\u002Fdocs\u002Fstable\u002Fcost-based-optimizer.html#table-statistics) - Statistics impact on query planning\n- [SHOW JOBS](https:\u002F\u002Fwww.cockroachlabs.com\u002Fdocs\u002Fstable\u002Fshow-jobs.html) - Job monitoring and management\n\n**Related Skills:**\n- [profiling-statement-fingerprints](..\u002Fprofiling-statement-fingerprints\u002FSKILL.md) - Identify slow query patterns\n- [triaging-live-sql-activity](..\u002Ftriaging-live-sql-activity\u002FSKILL.md) - Real-time query triage\n\n**Supplementary References:**\n- [Statistics Thresholds Guide](references\u002Fstatistics-thresholds.md) - Workload-specific staleness and drift thresholds\n- [CREATE STATISTICS Examples](references\u002Fcreate-statistics-examples.md) - Comprehensive collection patterns and batch strategies\n",{"data":40,"body":44},{"name":4,"description":6,"compatibility":41,"metadata":42},"Requires SQL access with any privilege on target tables (SELECT, INSERT, UPDATE, DELETE, or admin). Uses SHOW STATISTICS (production-safe, read-only).",{"author":8,"version":43},"1.0",{"type":45,"children":46},"root",[47,55,70,90,97,118,142,148,156,201,213,219,226,231,485,493,550,558,594,600,605,729,736,751,758,813,821,839,845,850,1088,1095,1108,1115,1150,1157,1200,1206,1211,1358,1365,1373,1380,1425,1435,1441,1446,1550,1557,1565,1572,1596,1603,1631,1637,1642,1715,1722,1729,1736,1760,1767,1795,1806,1812,1817,1949,1956,1993,2001,2026,2034,2052,2058,2064,2074,2082,2246,2256,2262,2271,2278,2399,2408,2414,2423,2430,2574,2584,2590,2596,2604,2627,2635,2699,2705,2715,2725,2735,2761,2769,2832,2838,2846,2864,2872,3132,3142,3148,3367,3373,3381,3420,3428,3466,3472,3558,3574,3580,3588,3649,3657,3678,3686,3709],{"type":48,"tag":49,"props":50,"children":51},"element","h1",{"id":4},[52],{"type":53,"value":54},"text","Auditing Table Statistics",{"type":48,"tag":56,"props":57,"children":58},"p",{},[59,61,68],{"type":53,"value":60},"Audits optimizer table statistics for staleness, missing column coverage, and row count drift to diagnose poor query performance caused by outdated or incomplete statistics. Uses ",{"type":48,"tag":62,"props":63,"children":65},"code",{"className":64},[],[66],{"type":53,"value":67},"SHOW STATISTICS",{"type":53,"value":69}," for read-only SQL analysis of table-level and column-level statistics freshness, entirely without requiring DB Console access.",{"type":48,"tag":56,"props":71,"children":72},{},[73,79,81,88],{"type":48,"tag":74,"props":75,"children":76},"strong",{},[77],{"type":53,"value":78},"Complement to profiling-statement-fingerprints:",{"type":53,"value":80}," This skill diagnoses optimizer statistics issues; for identifying historically slow queries, see ",{"type":48,"tag":82,"props":83,"children":85},"a",{"href":84},"..\u002Fprofiling-statement-fingerprints\u002FSKILL.md",[86],{"type":53,"value":87},"profiling-statement-fingerprints",{"type":53,"value":89},".",{"type":48,"tag":91,"props":92,"children":94},"h2",{"id":93},"prerequisites",[95],{"type":53,"value":96},"Prerequisites",{"type":48,"tag":98,"props":99,"children":100},"ul",{},[101,107],{"type":48,"tag":102,"props":103,"children":104},"li",{},[105],{"type":53,"value":106},"SQL connection with any privilege on target tables",{"type":48,"tag":102,"props":108,"children":109},{},[110,112],{"type":53,"value":111},"Automatic statistics collection enabled (default): ",{"type":48,"tag":62,"props":113,"children":115},{"className":114},[],[116],{"type":53,"value":117},"sql.stats.automatic_collection.enabled = true",{"type":48,"tag":56,"props":119,"children":120},{},[121,126,128,132,134,140],{"type":48,"tag":74,"props":122,"children":123},{},[124],{"type":53,"value":125},"Related skills:",{"type":53,"value":127}," ",{"type":48,"tag":82,"props":129,"children":130},{"href":84},[131],{"type":53,"value":87},{"type":53,"value":133}," for historical query analysis, ",{"type":48,"tag":82,"props":135,"children":137},{"href":136},"..\u002Ftriaging-live-sql-activity\u002FSKILL.md",[138],{"type":53,"value":139},"triaging-live-sql-activity",{"type":53,"value":141}," for live triage.",{"type":48,"tag":91,"props":143,"children":145},{"id":144},"core-concepts",[146],{"type":53,"value":147},"Core Concepts",{"type":48,"tag":56,"props":149,"children":150},{},[151],{"type":48,"tag":74,"props":152,"children":153},{},[154],{"type":53,"value":155},"CockroachDB-specific defaults:",{"type":48,"tag":98,"props":157,"children":158},{},[159,172,191,196],{"type":48,"tag":102,"props":160,"children":161},{},[162,164,170],{"type":53,"value":163},"Automatic collection triggers at ~20% row count change (",{"type":48,"tag":62,"props":165,"children":167},{"className":166},[],[168],{"type":53,"value":169},"sql.stats.automatic_collection.fraction_stale_rows",{"type":53,"value":171},")",{"type":48,"tag":102,"props":173,"children":174},{},[175,177,183,185],{"type":53,"value":176},"Auto-collection covers index column groups (when ",{"type":48,"tag":62,"props":178,"children":180},{"className":179},[],[181],{"type":53,"value":182},"sql.stats.multi_column_collection.enabled = true",{"type":53,"value":184},", the default); ad-hoc multi-column stats on non-indexed columns require manual ",{"type":48,"tag":62,"props":186,"children":188},{"className":187},[],[189],{"type":53,"value":190},"CREATE STATISTICS",{"type":48,"tag":102,"props":192,"children":193},{},[194],{"type":53,"value":195},"Large tables (>10M rows) may have delayed auto-collection",{"type":48,"tag":102,"props":197,"children":198},{},[199],{"type":53,"value":200},"Staleness thresholds: refresh if >7 days (OLTP) or >30 days (OLAP), or >20-30% row count drift",{"type":48,"tag":56,"props":202,"children":203},{},[204,206,211],{"type":53,"value":205},"See ",{"type":48,"tag":82,"props":207,"children":209},{"href":208},"references\u002Fstatistics-thresholds.md",[210],{"type":53,"value":208},{"type":53,"value":212}," for workload-specific guidance.",{"type":48,"tag":91,"props":214,"children":216},{"id":215},"core-diagnostic-queries",[217],{"type":53,"value":218},"Core Diagnostic Queries",{"type":48,"tag":220,"props":221,"children":223},"h3",{"id":222},"query-1-identify-tables-with-stale-or-missing-statistics",[224],{"type":53,"value":225},"Query 1: Identify Tables with Stale or Missing Statistics",{"type":48,"tag":56,"props":227,"children":228},{},[229],{"type":53,"value":230},"Finds tables with outdated statistics or no statistics at all, ranked by staleness.",{"type":48,"tag":232,"props":233,"children":238},"pre",{"className":234,"code":235,"language":236,"meta":237,"style":237},"language-sql shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","WITH table_stats AS (\n  SELECT\n    table_catalog,\n    table_schema,\n    table_name,\n    column_names,\n    row_count,\n    created,\n    now() - created AS stats_age\n  FROM [SHOW STATISTICS FOR TABLE database_name.*]  -- Replace database_name\n  WHERE column_names = '{}'  -- Table-level stats only (empty array)\n)\nSELECT\n  table_schema || '.' || table_name AS full_table_name,\n  row_count,\n  created AS stats_created_at,\n  stats_age,\n  CASE\n    WHEN created IS NULL THEN 'Missing statistics'\n    WHEN stats_age > INTERVAL '30 days' THEN 'Very stale (>30d)'\n    WHEN stats_age > INTERVAL '7 days' THEN 'Stale (>7d)'\n    ELSE 'Fresh'\n  END AS staleness_status\nFROM table_stats\nWHERE stats_age > INTERVAL '7 days' OR created IS NULL  -- Adjust threshold\nORDER BY stats_age DESC NULLS FIRST\nLIMIT 50;\n","sql","",[239],{"type":48,"tag":62,"props":240,"children":241},{"__ignoreMap":237},[242,253,261,269,278,287,296,305,314,323,332,341,350,359,368,377,386,395,404,413,422,431,440,449,458,467,476],{"type":48,"tag":243,"props":244,"children":247},"span",{"class":245,"line":246},"line",1,[248],{"type":48,"tag":243,"props":249,"children":250},{},[251],{"type":53,"value":252},"WITH table_stats AS (\n",{"type":48,"tag":243,"props":254,"children":255},{"class":245,"line":29},[256],{"type":48,"tag":243,"props":257,"children":258},{},[259],{"type":53,"value":260},"  SELECT\n",{"type":48,"tag":243,"props":262,"children":263},{"class":245,"line":25},[264],{"type":48,"tag":243,"props":265,"children":266},{},[267],{"type":53,"value":268},"    table_catalog,\n",{"type":48,"tag":243,"props":270,"children":272},{"class":245,"line":271},4,[273],{"type":48,"tag":243,"props":274,"children":275},{},[276],{"type":53,"value":277},"    table_schema,\n",{"type":48,"tag":243,"props":279,"children":281},{"class":245,"line":280},5,[282],{"type":48,"tag":243,"props":283,"children":284},{},[285],{"type":53,"value":286},"    table_name,\n",{"type":48,"tag":243,"props":288,"children":290},{"class":245,"line":289},6,[291],{"type":48,"tag":243,"props":292,"children":293},{},[294],{"type":53,"value":295},"    column_names,\n",{"type":48,"tag":243,"props":297,"children":299},{"class":245,"line":298},7,[300],{"type":48,"tag":243,"props":301,"children":302},{},[303],{"type":53,"value":304},"    row_count,\n",{"type":48,"tag":243,"props":306,"children":308},{"class":245,"line":307},8,[309],{"type":48,"tag":243,"props":310,"children":311},{},[312],{"type":53,"value":313},"    created,\n",{"type":48,"tag":243,"props":315,"children":317},{"class":245,"line":316},9,[318],{"type":48,"tag":243,"props":319,"children":320},{},[321],{"type":53,"value":322},"    now() - created AS stats_age\n",{"type":48,"tag":243,"props":324,"children":326},{"class":245,"line":325},10,[327],{"type":48,"tag":243,"props":328,"children":329},{},[330],{"type":53,"value":331},"  FROM [SHOW STATISTICS FOR TABLE database_name.*]  -- Replace database_name\n",{"type":48,"tag":243,"props":333,"children":335},{"class":245,"line":334},11,[336],{"type":48,"tag":243,"props":337,"children":338},{},[339],{"type":53,"value":340},"  WHERE column_names = '{}'  -- Table-level stats only (empty array)\n",{"type":48,"tag":243,"props":342,"children":344},{"class":245,"line":343},12,[345],{"type":48,"tag":243,"props":346,"children":347},{},[348],{"type":53,"value":349},")\n",{"type":48,"tag":243,"props":351,"children":353},{"class":245,"line":352},13,[354],{"type":48,"tag":243,"props":355,"children":356},{},[357],{"type":53,"value":358},"SELECT\n",{"type":48,"tag":243,"props":360,"children":362},{"class":245,"line":361},14,[363],{"type":48,"tag":243,"props":364,"children":365},{},[366],{"type":53,"value":367},"  table_schema || '.' || table_name AS full_table_name,\n",{"type":48,"tag":243,"props":369,"children":371},{"class":245,"line":370},15,[372],{"type":48,"tag":243,"props":373,"children":374},{},[375],{"type":53,"value":376},"  row_count,\n",{"type":48,"tag":243,"props":378,"children":380},{"class":245,"line":379},16,[381],{"type":48,"tag":243,"props":382,"children":383},{},[384],{"type":53,"value":385},"  created AS stats_created_at,\n",{"type":48,"tag":243,"props":387,"children":389},{"class":245,"line":388},17,[390],{"type":48,"tag":243,"props":391,"children":392},{},[393],{"type":53,"value":394},"  stats_age,\n",{"type":48,"tag":243,"props":396,"children":398},{"class":245,"line":397},18,[399],{"type":48,"tag":243,"props":400,"children":401},{},[402],{"type":53,"value":403},"  CASE\n",{"type":48,"tag":243,"props":405,"children":407},{"class":245,"line":406},19,[408],{"type":48,"tag":243,"props":409,"children":410},{},[411],{"type":53,"value":412},"    WHEN created IS NULL THEN 'Missing statistics'\n",{"type":48,"tag":243,"props":414,"children":416},{"class":245,"line":415},20,[417],{"type":48,"tag":243,"props":418,"children":419},{},[420],{"type":53,"value":421},"    WHEN stats_age > INTERVAL '30 days' THEN 'Very stale (>30d)'\n",{"type":48,"tag":243,"props":423,"children":425},{"class":245,"line":424},21,[426],{"type":48,"tag":243,"props":427,"children":428},{},[429],{"type":53,"value":430},"    WHEN stats_age > INTERVAL '7 days' THEN 'Stale (>7d)'\n",{"type":48,"tag":243,"props":432,"children":434},{"class":245,"line":433},22,[435],{"type":48,"tag":243,"props":436,"children":437},{},[438],{"type":53,"value":439},"    ELSE 'Fresh'\n",{"type":48,"tag":243,"props":441,"children":443},{"class":245,"line":442},23,[444],{"type":48,"tag":243,"props":445,"children":446},{},[447],{"type":53,"value":448},"  END AS staleness_status\n",{"type":48,"tag":243,"props":450,"children":452},{"class":245,"line":451},24,[453],{"type":48,"tag":243,"props":454,"children":455},{},[456],{"type":53,"value":457},"FROM table_stats\n",{"type":48,"tag":243,"props":459,"children":461},{"class":245,"line":460},25,[462],{"type":48,"tag":243,"props":463,"children":464},{},[465],{"type":53,"value":466},"WHERE stats_age > INTERVAL '7 days' OR created IS NULL  -- Adjust threshold\n",{"type":48,"tag":243,"props":468,"children":470},{"class":245,"line":469},26,[471],{"type":48,"tag":243,"props":472,"children":473},{},[474],{"type":53,"value":475},"ORDER BY stats_age DESC NULLS FIRST\n",{"type":48,"tag":243,"props":477,"children":479},{"class":245,"line":478},27,[480],{"type":48,"tag":243,"props":481,"children":482},{},[483],{"type":53,"value":484},"LIMIT 50;\n",{"type":48,"tag":56,"props":486,"children":487},{},[488],{"type":48,"tag":74,"props":489,"children":490},{},[491],{"type":53,"value":492},"Customization:",{"type":48,"tag":98,"props":494,"children":495},{},[496,516,537],{"type":48,"tag":102,"props":497,"children":498},{},[499,501,507,509,515],{"type":53,"value":500},"Replace ",{"type":48,"tag":62,"props":502,"children":504},{"className":503},[],[505],{"type":53,"value":506},"database_name.*",{"type":53,"value":508}," with specific schema pattern (e.g., ",{"type":48,"tag":62,"props":510,"children":512},{"className":511},[],[513],{"type":53,"value":514},"mydb.public.*",{"type":53,"value":171},{"type":48,"tag":102,"props":517,"children":518},{},[519,521,527,529,535],{"type":53,"value":520},"Adjust staleness threshold: ",{"type":48,"tag":62,"props":522,"children":524},{"className":523},[],[525],{"type":53,"value":526},"INTERVAL '7 days'",{"type":53,"value":528}," for OLTP, ",{"type":48,"tag":62,"props":530,"children":532},{"className":531},[],[533],{"type":53,"value":534},"'30 days'",{"type":53,"value":536}," for OLAP",{"type":48,"tag":102,"props":538,"children":539},{},[540,542,548],{"type":53,"value":541},"Increase ",{"type":48,"tag":62,"props":543,"children":545},{"className":544},[],[546],{"type":53,"value":547},"LIMIT",{"type":53,"value":549}," to see more tables",{"type":48,"tag":56,"props":551,"children":552},{},[553],{"type":48,"tag":74,"props":554,"children":555},{},[556],{"type":53,"value":557},"Key columns:",{"type":48,"tag":98,"props":559,"children":560},{},[561,572,583],{"type":48,"tag":102,"props":562,"children":563},{},[564,570],{"type":48,"tag":62,"props":565,"children":567},{"className":566},[],[568],{"type":53,"value":569},"staleness_status",{"type":53,"value":571},": Quick classification of statistics freshness",{"type":48,"tag":102,"props":573,"children":574},{},[575,581],{"type":48,"tag":62,"props":576,"children":578},{"className":577},[],[579],{"type":53,"value":580},"stats_age",{"type":53,"value":582},": Exact time since last collection",{"type":48,"tag":102,"props":584,"children":585},{},[586,592],{"type":48,"tag":62,"props":587,"children":589},{"className":588},[],[590],{"type":53,"value":591},"row_count",{"type":53,"value":593},": Last known table size",{"type":48,"tag":220,"props":595,"children":597},{"id":596},"query-2-audit-statistics-for-specific-table",[598],{"type":53,"value":599},"Query 2: Audit Statistics for Specific Table",{"type":48,"tag":56,"props":601,"children":602},{},[603],{"type":53,"value":604},"Shows all statistics for a single table, including table-level and per-column details.",{"type":48,"tag":232,"props":606,"children":608},{"className":234,"code":607,"language":236,"meta":237,"style":237},"SELECT\n  column_names,\n  row_count,\n  distinct_count,\n  null_count,\n  created,\n  now() - created AS stats_age,\n  CASE\n    WHEN histogram_id IS NOT NULL THEN 'Yes'\n    ELSE 'No'\n  END AS has_histogram\nFROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\nORDER BY\n  CASE WHEN column_names = '{}' THEN 0 ELSE 1 END,  -- Table-level first\n  created DESC;\n",[609],{"type":48,"tag":62,"props":610,"children":611},{"__ignoreMap":237},[612,619,627,634,642,650,658,666,673,681,689,697,705,713,721],{"type":48,"tag":243,"props":613,"children":614},{"class":245,"line":246},[615],{"type":48,"tag":243,"props":616,"children":617},{},[618],{"type":53,"value":358},{"type":48,"tag":243,"props":620,"children":621},{"class":245,"line":29},[622],{"type":48,"tag":243,"props":623,"children":624},{},[625],{"type":53,"value":626},"  column_names,\n",{"type":48,"tag":243,"props":628,"children":629},{"class":245,"line":25},[630],{"type":48,"tag":243,"props":631,"children":632},{},[633],{"type":53,"value":376},{"type":48,"tag":243,"props":635,"children":636},{"class":245,"line":271},[637],{"type":48,"tag":243,"props":638,"children":639},{},[640],{"type":53,"value":641},"  distinct_count,\n",{"type":48,"tag":243,"props":643,"children":644},{"class":245,"line":280},[645],{"type":48,"tag":243,"props":646,"children":647},{},[648],{"type":53,"value":649},"  null_count,\n",{"type":48,"tag":243,"props":651,"children":652},{"class":245,"line":289},[653],{"type":48,"tag":243,"props":654,"children":655},{},[656],{"type":53,"value":657},"  created,\n",{"type":48,"tag":243,"props":659,"children":660},{"class":245,"line":298},[661],{"type":48,"tag":243,"props":662,"children":663},{},[664],{"type":53,"value":665},"  now() - created AS stats_age,\n",{"type":48,"tag":243,"props":667,"children":668},{"class":245,"line":307},[669],{"type":48,"tag":243,"props":670,"children":671},{},[672],{"type":53,"value":403},{"type":48,"tag":243,"props":674,"children":675},{"class":245,"line":316},[676],{"type":48,"tag":243,"props":677,"children":678},{},[679],{"type":53,"value":680},"    WHEN histogram_id IS NOT NULL THEN 'Yes'\n",{"type":48,"tag":243,"props":682,"children":683},{"class":245,"line":325},[684],{"type":48,"tag":243,"props":685,"children":686},{},[687],{"type":53,"value":688},"    ELSE 'No'\n",{"type":48,"tag":243,"props":690,"children":691},{"class":245,"line":334},[692],{"type":48,"tag":243,"props":693,"children":694},{},[695],{"type":53,"value":696},"  END AS has_histogram\n",{"type":48,"tag":243,"props":698,"children":699},{"class":245,"line":343},[700],{"type":48,"tag":243,"props":701,"children":702},{},[703],{"type":53,"value":704},"FROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\n",{"type":48,"tag":243,"props":706,"children":707},{"class":245,"line":352},[708],{"type":48,"tag":243,"props":709,"children":710},{},[711],{"type":53,"value":712},"ORDER BY\n",{"type":48,"tag":243,"props":714,"children":715},{"class":245,"line":361},[716],{"type":48,"tag":243,"props":717,"children":718},{},[719],{"type":53,"value":720},"  CASE WHEN column_names = '{}' THEN 0 ELSE 1 END,  -- Table-level first\n",{"type":48,"tag":243,"props":722,"children":723},{"class":245,"line":370},[724],{"type":48,"tag":243,"props":725,"children":726},{},[727],{"type":53,"value":728},"  created DESC;\n",{"type":48,"tag":56,"props":730,"children":731},{},[732],{"type":48,"tag":74,"props":733,"children":734},{},[735],{"type":53,"value":492},{"type":48,"tag":98,"props":737,"children":738},{},[739],{"type":48,"tag":102,"props":740,"children":741},{},[742,743,749],{"type":53,"value":500},{"type":48,"tag":62,"props":744,"children":746},{"className":745},[],[747],{"type":53,"value":748},"database_name.schema_name.table_name",{"type":53,"value":750}," with fully-qualified table name",{"type":48,"tag":56,"props":752,"children":753},{},[754],{"type":48,"tag":74,"props":755,"children":756},{},[757],{"type":53,"value":557},{"type":48,"tag":98,"props":759,"children":760},{},[761,780,791,802],{"type":48,"tag":102,"props":762,"children":763},{},[764,770,772,778],{"type":48,"tag":62,"props":765,"children":767},{"className":766},[],[768],{"type":53,"value":769},"column_names",{"type":53,"value":771},": Empty ",{"type":48,"tag":62,"props":773,"children":775},{"className":774},[],[776],{"type":53,"value":777},"{}",{"type":53,"value":779}," = table-level, single element = column-level",{"type":48,"tag":102,"props":781,"children":782},{},[783,789],{"type":48,"tag":62,"props":784,"children":786},{"className":785},[],[787],{"type":53,"value":788},"distinct_count",{"type":53,"value":790},": Cardinality for selectivity estimates",{"type":48,"tag":102,"props":792,"children":793},{},[794,800],{"type":48,"tag":62,"props":795,"children":797},{"className":796},[],[798],{"type":53,"value":799},"null_count",{"type":53,"value":801},": NULL value count for IS NULL predicates",{"type":48,"tag":102,"props":803,"children":804},{},[805,811],{"type":48,"tag":62,"props":806,"children":808},{"className":807},[],[809],{"type":53,"value":810},"has_histogram",{"type":53,"value":812},": Distribution data availability",{"type":48,"tag":56,"props":814,"children":815},{},[816],{"type":48,"tag":74,"props":817,"children":818},{},[819],{"type":53,"value":820},"Interpretation:",{"type":48,"tag":98,"props":822,"children":823},{},[824,829,834],{"type":48,"tag":102,"props":825,"children":826},{},[827],{"type":53,"value":828},"First row (column_names = '{}') shows table-level row_count",{"type":48,"tag":102,"props":830,"children":831},{},[832],{"type":53,"value":833},"Subsequent rows show per-column statistics",{"type":48,"tag":102,"props":835,"children":836},{},[837],{"type":53,"value":838},"Missing columns indicate no statistics collected yet",{"type":48,"tag":220,"props":840,"children":842},{"id":841},"query-3-detect-row-count-drift",[843],{"type":53,"value":844},"Query 3: Detect Row Count Drift",{"type":48,"tag":56,"props":846,"children":847},{},[848],{"type":53,"value":849},"Compares current table row count against cached statistics to identify significant drift.",{"type":48,"tag":232,"props":851,"children":853},{"className":234,"code":852,"language":236,"meta":237,"style":237},"WITH current_count AS (\n  SELECT count(*) AS actual_rows\n  FROM database_name.schema_name.table_name  -- Replace with target table\n),\nstats_count AS (\n  SELECT row_count, created\n  FROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\n  WHERE column_names = '{}'  -- Table-level stats\n  ORDER BY created DESC\n  LIMIT 1\n)\nSELECT\n  c.actual_rows,\n  s.row_count AS stats_rows,\n  s.created AS stats_created_at,\n  now() - s.created AS stats_age,\n  ABS(c.actual_rows - s.row_count) AS drift_absolute,\n  ROUND(\n    ABS(c.actual_rows - s.row_count)::NUMERIC \u002F\n    NULLIF(s.row_count, 0) * 100,\n    2\n  ) AS drift_pct,\n  CASE\n    WHEN ABS(c.actual_rows - s.row_count)::NUMERIC \u002F NULLIF(s.row_count, 0) > 0.30 THEN 'High drift (>30%)'\n    WHEN ABS(c.actual_rows - s.row_count)::NUMERIC \u002F NULLIF(s.row_count, 0) > 0.20 THEN 'Medium drift (>20%)'\n    WHEN ABS(c.actual_rows - s.row_count)::NUMERIC \u002F NULLIF(s.row_count, 0) > 0.10 THEN 'Low drift (>10%)'\n    ELSE 'Minimal drift (\u003C10%)'\n  END AS drift_status\nFROM current_count c, stats_count s;\n",[854],{"type":48,"tag":62,"props":855,"children":856},{"__ignoreMap":237},[857,865,873,881,889,897,905,913,921,929,937,944,951,959,967,975,983,991,999,1007,1015,1023,1031,1038,1046,1054,1062,1070,1079],{"type":48,"tag":243,"props":858,"children":859},{"class":245,"line":246},[860],{"type":48,"tag":243,"props":861,"children":862},{},[863],{"type":53,"value":864},"WITH current_count AS (\n",{"type":48,"tag":243,"props":866,"children":867},{"class":245,"line":29},[868],{"type":48,"tag":243,"props":869,"children":870},{},[871],{"type":53,"value":872},"  SELECT count(*) AS actual_rows\n",{"type":48,"tag":243,"props":874,"children":875},{"class":245,"line":25},[876],{"type":48,"tag":243,"props":877,"children":878},{},[879],{"type":53,"value":880},"  FROM database_name.schema_name.table_name  -- Replace with target table\n",{"type":48,"tag":243,"props":882,"children":883},{"class":245,"line":271},[884],{"type":48,"tag":243,"props":885,"children":886},{},[887],{"type":53,"value":888},"),\n",{"type":48,"tag":243,"props":890,"children":891},{"class":245,"line":280},[892],{"type":48,"tag":243,"props":893,"children":894},{},[895],{"type":53,"value":896},"stats_count AS (\n",{"type":48,"tag":243,"props":898,"children":899},{"class":245,"line":289},[900],{"type":48,"tag":243,"props":901,"children":902},{},[903],{"type":53,"value":904},"  SELECT row_count, created\n",{"type":48,"tag":243,"props":906,"children":907},{"class":245,"line":298},[908],{"type":48,"tag":243,"props":909,"children":910},{},[911],{"type":53,"value":912},"  FROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\n",{"type":48,"tag":243,"props":914,"children":915},{"class":245,"line":307},[916],{"type":48,"tag":243,"props":917,"children":918},{},[919],{"type":53,"value":920},"  WHERE column_names = '{}'  -- Table-level stats\n",{"type":48,"tag":243,"props":922,"children":923},{"class":245,"line":316},[924],{"type":48,"tag":243,"props":925,"children":926},{},[927],{"type":53,"value":928},"  ORDER BY created DESC\n",{"type":48,"tag":243,"props":930,"children":931},{"class":245,"line":325},[932],{"type":48,"tag":243,"props":933,"children":934},{},[935],{"type":53,"value":936},"  LIMIT 1\n",{"type":48,"tag":243,"props":938,"children":939},{"class":245,"line":334},[940],{"type":48,"tag":243,"props":941,"children":942},{},[943],{"type":53,"value":349},{"type":48,"tag":243,"props":945,"children":946},{"class":245,"line":343},[947],{"type":48,"tag":243,"props":948,"children":949},{},[950],{"type":53,"value":358},{"type":48,"tag":243,"props":952,"children":953},{"class":245,"line":352},[954],{"type":48,"tag":243,"props":955,"children":956},{},[957],{"type":53,"value":958},"  c.actual_rows,\n",{"type":48,"tag":243,"props":960,"children":961},{"class":245,"line":361},[962],{"type":48,"tag":243,"props":963,"children":964},{},[965],{"type":53,"value":966},"  s.row_count AS stats_rows,\n",{"type":48,"tag":243,"props":968,"children":969},{"class":245,"line":370},[970],{"type":48,"tag":243,"props":971,"children":972},{},[973],{"type":53,"value":974},"  s.created AS stats_created_at,\n",{"type":48,"tag":243,"props":976,"children":977},{"class":245,"line":379},[978],{"type":48,"tag":243,"props":979,"children":980},{},[981],{"type":53,"value":982},"  now() - s.created AS stats_age,\n",{"type":48,"tag":243,"props":984,"children":985},{"class":245,"line":388},[986],{"type":48,"tag":243,"props":987,"children":988},{},[989],{"type":53,"value":990},"  ABS(c.actual_rows - s.row_count) AS drift_absolute,\n",{"type":48,"tag":243,"props":992,"children":993},{"class":245,"line":397},[994],{"type":48,"tag":243,"props":995,"children":996},{},[997],{"type":53,"value":998},"  ROUND(\n",{"type":48,"tag":243,"props":1000,"children":1001},{"class":245,"line":406},[1002],{"type":48,"tag":243,"props":1003,"children":1004},{},[1005],{"type":53,"value":1006},"    ABS(c.actual_rows - s.row_count)::NUMERIC \u002F\n",{"type":48,"tag":243,"props":1008,"children":1009},{"class":245,"line":415},[1010],{"type":48,"tag":243,"props":1011,"children":1012},{},[1013],{"type":53,"value":1014},"    NULLIF(s.row_count, 0) * 100,\n",{"type":48,"tag":243,"props":1016,"children":1017},{"class":245,"line":424},[1018],{"type":48,"tag":243,"props":1019,"children":1020},{},[1021],{"type":53,"value":1022},"    2\n",{"type":48,"tag":243,"props":1024,"children":1025},{"class":245,"line":433},[1026],{"type":48,"tag":243,"props":1027,"children":1028},{},[1029],{"type":53,"value":1030},"  ) AS drift_pct,\n",{"type":48,"tag":243,"props":1032,"children":1033},{"class":245,"line":442},[1034],{"type":48,"tag":243,"props":1035,"children":1036},{},[1037],{"type":53,"value":403},{"type":48,"tag":243,"props":1039,"children":1040},{"class":245,"line":451},[1041],{"type":48,"tag":243,"props":1042,"children":1043},{},[1044],{"type":53,"value":1045},"    WHEN ABS(c.actual_rows - s.row_count)::NUMERIC \u002F NULLIF(s.row_count, 0) > 0.30 THEN 'High drift (>30%)'\n",{"type":48,"tag":243,"props":1047,"children":1048},{"class":245,"line":460},[1049],{"type":48,"tag":243,"props":1050,"children":1051},{},[1052],{"type":53,"value":1053},"    WHEN ABS(c.actual_rows - s.row_count)::NUMERIC \u002F NULLIF(s.row_count, 0) > 0.20 THEN 'Medium drift (>20%)'\n",{"type":48,"tag":243,"props":1055,"children":1056},{"class":245,"line":469},[1057],{"type":48,"tag":243,"props":1058,"children":1059},{},[1060],{"type":53,"value":1061},"    WHEN ABS(c.actual_rows - s.row_count)::NUMERIC \u002F NULLIF(s.row_count, 0) > 0.10 THEN 'Low drift (>10%)'\n",{"type":48,"tag":243,"props":1063,"children":1064},{"class":245,"line":478},[1065],{"type":48,"tag":243,"props":1066,"children":1067},{},[1068],{"type":53,"value":1069},"    ELSE 'Minimal drift (\u003C10%)'\n",{"type":48,"tag":243,"props":1071,"children":1073},{"class":245,"line":1072},28,[1074],{"type":48,"tag":243,"props":1075,"children":1076},{},[1077],{"type":53,"value":1078},"  END AS drift_status\n",{"type":48,"tag":243,"props":1080,"children":1082},{"class":245,"line":1081},29,[1083],{"type":48,"tag":243,"props":1084,"children":1085},{},[1086],{"type":53,"value":1087},"FROM current_count c, stats_count s;\n",{"type":48,"tag":56,"props":1089,"children":1090},{},[1091],{"type":48,"tag":74,"props":1092,"children":1093},{},[1094],{"type":53,"value":492},{"type":48,"tag":98,"props":1096,"children":1097},{},[1098,1103],{"type":48,"tag":102,"props":1099,"children":1100},{},[1101],{"type":53,"value":1102},"Replace table name in both CTEs",{"type":48,"tag":102,"props":1104,"children":1105},{},[1106],{"type":53,"value":1107},"Adjust drift thresholds (30%, 20%, 10%) based on workload tolerance",{"type":48,"tag":56,"props":1109,"children":1110},{},[1111],{"type":48,"tag":74,"props":1112,"children":1113},{},[1114],{"type":53,"value":557},{"type":48,"tag":98,"props":1116,"children":1117},{},[1118,1129,1140],{"type":48,"tag":102,"props":1119,"children":1120},{},[1121,1127],{"type":48,"tag":62,"props":1122,"children":1124},{"className":1123},[],[1125],{"type":53,"value":1126},"drift_pct",{"type":53,"value":1128},": Percentage difference between current and cached row count",{"type":48,"tag":102,"props":1130,"children":1131},{},[1132,1138],{"type":48,"tag":62,"props":1133,"children":1135},{"className":1134},[],[1136],{"type":53,"value":1137},"drift_status",{"type":53,"value":1139},": Classification for prioritization",{"type":48,"tag":102,"props":1141,"children":1142},{},[1143,1148],{"type":48,"tag":62,"props":1144,"children":1146},{"className":1145},[],[1147],{"type":53,"value":580},{"type":53,"value":1149},": Time since statistics last refreshed",{"type":48,"tag":56,"props":1151,"children":1152},{},[1153],{"type":48,"tag":74,"props":1154,"children":1155},{},[1156],{"type":53,"value":820},{"type":48,"tag":98,"props":1158,"children":1159},{},[1160,1170,1180,1190],{"type":48,"tag":102,"props":1161,"children":1162},{},[1163,1168],{"type":48,"tag":74,"props":1164,"children":1165},{},[1166],{"type":53,"value":1167},">30% drift",{"type":53,"value":1169},": Urgent refresh recommended, optimizer estimates likely very inaccurate",{"type":48,"tag":102,"props":1171,"children":1172},{},[1173,1178],{"type":48,"tag":74,"props":1174,"children":1175},{},[1176],{"type":53,"value":1177},"20-30% drift",{"type":53,"value":1179},": Consider refresh if experiencing performance issues",{"type":48,"tag":102,"props":1181,"children":1182},{},[1183,1188],{"type":48,"tag":74,"props":1184,"children":1185},{},[1186],{"type":53,"value":1187},"10-20% drift",{"type":53,"value":1189},": Monitor for trends, may trigger automatic collection soon",{"type":48,"tag":102,"props":1191,"children":1192},{},[1193,1198],{"type":48,"tag":74,"props":1194,"children":1195},{},[1196],{"type":53,"value":1197},"\u003C10% drift",{"type":53,"value":1199},": Normal variance, no action needed",{"type":48,"tag":220,"props":1201,"children":1203},{"id":1202},"query-4-identify-missing-column-level-statistics",[1204],{"type":53,"value":1205},"Query 4: Identify Missing Column-Level Statistics",{"type":48,"tag":56,"props":1207,"children":1208},{},[1209],{"type":53,"value":1210},"Finds table columns without statistics, focusing on columns frequently used in WHERE\u002FJOIN clauses.",{"type":48,"tag":232,"props":1212,"children":1214},{"className":234,"code":1213,"language":236,"meta":237,"style":237},"WITH table_columns AS (\n  SELECT column_name\n  FROM information_schema.columns\n  WHERE table_schema = 'schema_name'  -- Replace\n    AND table_name = 'table_name'    -- Replace\n    AND is_hidden = 'NO'             -- Exclude internal columns\n),\nstats_columns AS (\n  SELECT UNNEST(column_names) AS column_name\n  FROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\n  WHERE column_names != '{}'  -- Exclude table-level stats\n)\nSELECT\n  tc.column_name AS missing_column,\n  'No statistics available' AS status\nFROM table_columns tc\nWHERE tc.column_name NOT IN (SELECT column_name FROM stats_columns)\nORDER BY tc.column_name;\n",[1215],{"type":48,"tag":62,"props":1216,"children":1217},{"__ignoreMap":237},[1218,1226,1234,1242,1250,1258,1266,1273,1281,1289,1296,1304,1311,1318,1326,1334,1342,1350],{"type":48,"tag":243,"props":1219,"children":1220},{"class":245,"line":246},[1221],{"type":48,"tag":243,"props":1222,"children":1223},{},[1224],{"type":53,"value":1225},"WITH table_columns AS (\n",{"type":48,"tag":243,"props":1227,"children":1228},{"class":245,"line":29},[1229],{"type":48,"tag":243,"props":1230,"children":1231},{},[1232],{"type":53,"value":1233},"  SELECT column_name\n",{"type":48,"tag":243,"props":1235,"children":1236},{"class":245,"line":25},[1237],{"type":48,"tag":243,"props":1238,"children":1239},{},[1240],{"type":53,"value":1241},"  FROM information_schema.columns\n",{"type":48,"tag":243,"props":1243,"children":1244},{"class":245,"line":271},[1245],{"type":48,"tag":243,"props":1246,"children":1247},{},[1248],{"type":53,"value":1249},"  WHERE table_schema = 'schema_name'  -- Replace\n",{"type":48,"tag":243,"props":1251,"children":1252},{"class":245,"line":280},[1253],{"type":48,"tag":243,"props":1254,"children":1255},{},[1256],{"type":53,"value":1257},"    AND table_name = 'table_name'    -- Replace\n",{"type":48,"tag":243,"props":1259,"children":1260},{"class":245,"line":289},[1261],{"type":48,"tag":243,"props":1262,"children":1263},{},[1264],{"type":53,"value":1265},"    AND is_hidden = 'NO'             -- Exclude internal columns\n",{"type":48,"tag":243,"props":1267,"children":1268},{"class":245,"line":298},[1269],{"type":48,"tag":243,"props":1270,"children":1271},{},[1272],{"type":53,"value":888},{"type":48,"tag":243,"props":1274,"children":1275},{"class":245,"line":307},[1276],{"type":48,"tag":243,"props":1277,"children":1278},{},[1279],{"type":53,"value":1280},"stats_columns AS (\n",{"type":48,"tag":243,"props":1282,"children":1283},{"class":245,"line":316},[1284],{"type":48,"tag":243,"props":1285,"children":1286},{},[1287],{"type":53,"value":1288},"  SELECT UNNEST(column_names) AS column_name\n",{"type":48,"tag":243,"props":1290,"children":1291},{"class":245,"line":325},[1292],{"type":48,"tag":243,"props":1293,"children":1294},{},[1295],{"type":53,"value":912},{"type":48,"tag":243,"props":1297,"children":1298},{"class":245,"line":334},[1299],{"type":48,"tag":243,"props":1300,"children":1301},{},[1302],{"type":53,"value":1303},"  WHERE column_names != '{}'  -- Exclude table-level stats\n",{"type":48,"tag":243,"props":1305,"children":1306},{"class":245,"line":343},[1307],{"type":48,"tag":243,"props":1308,"children":1309},{},[1310],{"type":53,"value":349},{"type":48,"tag":243,"props":1312,"children":1313},{"class":245,"line":352},[1314],{"type":48,"tag":243,"props":1315,"children":1316},{},[1317],{"type":53,"value":358},{"type":48,"tag":243,"props":1319,"children":1320},{"class":245,"line":361},[1321],{"type":48,"tag":243,"props":1322,"children":1323},{},[1324],{"type":53,"value":1325},"  tc.column_name AS missing_column,\n",{"type":48,"tag":243,"props":1327,"children":1328},{"class":245,"line":370},[1329],{"type":48,"tag":243,"props":1330,"children":1331},{},[1332],{"type":53,"value":1333},"  'No statistics available' AS status\n",{"type":48,"tag":243,"props":1335,"children":1336},{"class":245,"line":379},[1337],{"type":48,"tag":243,"props":1338,"children":1339},{},[1340],{"type":53,"value":1341},"FROM table_columns tc\n",{"type":48,"tag":243,"props":1343,"children":1344},{"class":245,"line":388},[1345],{"type":48,"tag":243,"props":1346,"children":1347},{},[1348],{"type":53,"value":1349},"WHERE tc.column_name NOT IN (SELECT column_name FROM stats_columns)\n",{"type":48,"tag":243,"props":1351,"children":1352},{"class":245,"line":397},[1353],{"type":48,"tag":243,"props":1354,"children":1355},{},[1356],{"type":53,"value":1357},"ORDER BY tc.column_name;\n",{"type":48,"tag":56,"props":1359,"children":1360},{},[1361],{"type":48,"tag":74,"props":1362,"children":1363},{},[1364],{"type":53,"value":492},{"type":48,"tag":98,"props":1366,"children":1367},{},[1368],{"type":48,"tag":102,"props":1369,"children":1370},{},[1371],{"type":53,"value":1372},"Replace schema_name, table_name, and database_name with target table",{"type":48,"tag":56,"props":1374,"children":1375},{},[1376],{"type":48,"tag":74,"props":1377,"children":1378},{},[1379],{"type":53,"value":820},{"type":48,"tag":98,"props":1381,"children":1382},{},[1383,1388],{"type":48,"tag":102,"props":1384,"children":1385},{},[1386],{"type":53,"value":1387},"Columns returned have no optimizer statistics",{"type":48,"tag":102,"props":1389,"children":1390},{},[1391,1393],{"type":53,"value":1392},"Prioritize creating statistics for columns used in:\n",{"type":48,"tag":98,"props":1394,"children":1395},{},[1396,1408,1420],{"type":48,"tag":102,"props":1397,"children":1398},{},[1399,1401,1407],{"type":53,"value":1400},"WHERE clause predicates (",{"type":48,"tag":62,"props":1402,"children":1404},{"className":1403},[],[1405],{"type":53,"value":1406},"WHERE user_id = 123",{"type":53,"value":171},{"type":48,"tag":102,"props":1409,"children":1410},{},[1411,1413,1419],{"type":53,"value":1412},"JOIN conditions (",{"type":48,"tag":62,"props":1414,"children":1416},{"className":1415},[],[1417],{"type":53,"value":1418},"JOIN orders ON users.id = orders.user_id",{"type":53,"value":171},{"type":48,"tag":102,"props":1421,"children":1422},{},[1423],{"type":53,"value":1424},"GROUP BY \u002F ORDER BY expressions",{"type":48,"tag":56,"props":1426,"children":1427},{},[1428,1433],{"type":48,"tag":74,"props":1429,"children":1430},{},[1431],{"type":53,"value":1432},"Action:",{"type":53,"value":1434}," Generate CREATE STATISTICS commands (see Query 7)",{"type":48,"tag":220,"props":1436,"children":1438},{"id":1437},"query-5-histogram-coverage-analysis",[1439],{"type":53,"value":1440},"Query 5: Histogram Coverage Analysis",{"type":48,"tag":56,"props":1442,"children":1443},{},[1444],{"type":53,"value":1445},"Identifies columns with\u002Fwithout histogram data for range query optimization.",{"type":48,"tag":232,"props":1447,"children":1449},{"className":234,"code":1448,"language":236,"meta":237,"style":237},"SELECT\n  UNNEST(column_names) AS column_name,\n  created,\n  now() - created AS stats_age,\n  CASE\n    WHEN histogram_id IS NOT NULL THEN 'Has histogram'\n    ELSE 'Missing histogram'\n  END AS histogram_status\nFROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\nWHERE column_names != '{}'  -- Exclude table-level stats\nORDER BY\n  CASE WHEN histogram_id IS NULL THEN 0 ELSE 1 END,  -- Missing first\n  created DESC;\n",[1450],{"type":48,"tag":62,"props":1451,"children":1452},{"__ignoreMap":237},[1453,1460,1468,1475,1482,1489,1497,1505,1513,1520,1528,1535,1543],{"type":48,"tag":243,"props":1454,"children":1455},{"class":245,"line":246},[1456],{"type":48,"tag":243,"props":1457,"children":1458},{},[1459],{"type":53,"value":358},{"type":48,"tag":243,"props":1461,"children":1462},{"class":245,"line":29},[1463],{"type":48,"tag":243,"props":1464,"children":1465},{},[1466],{"type":53,"value":1467},"  UNNEST(column_names) AS column_name,\n",{"type":48,"tag":243,"props":1469,"children":1470},{"class":245,"line":25},[1471],{"type":48,"tag":243,"props":1472,"children":1473},{},[1474],{"type":53,"value":657},{"type":48,"tag":243,"props":1476,"children":1477},{"class":245,"line":271},[1478],{"type":48,"tag":243,"props":1479,"children":1480},{},[1481],{"type":53,"value":665},{"type":48,"tag":243,"props":1483,"children":1484},{"class":245,"line":280},[1485],{"type":48,"tag":243,"props":1486,"children":1487},{},[1488],{"type":53,"value":403},{"type":48,"tag":243,"props":1490,"children":1491},{"class":245,"line":289},[1492],{"type":48,"tag":243,"props":1493,"children":1494},{},[1495],{"type":53,"value":1496},"    WHEN histogram_id IS NOT NULL THEN 'Has histogram'\n",{"type":48,"tag":243,"props":1498,"children":1499},{"class":245,"line":298},[1500],{"type":48,"tag":243,"props":1501,"children":1502},{},[1503],{"type":53,"value":1504},"    ELSE 'Missing histogram'\n",{"type":48,"tag":243,"props":1506,"children":1507},{"class":245,"line":307},[1508],{"type":48,"tag":243,"props":1509,"children":1510},{},[1511],{"type":53,"value":1512},"  END AS histogram_status\n",{"type":48,"tag":243,"props":1514,"children":1515},{"class":245,"line":316},[1516],{"type":48,"tag":243,"props":1517,"children":1518},{},[1519],{"type":53,"value":704},{"type":48,"tag":243,"props":1521,"children":1522},{"class":245,"line":325},[1523],{"type":48,"tag":243,"props":1524,"children":1525},{},[1526],{"type":53,"value":1527},"WHERE column_names != '{}'  -- Exclude table-level stats\n",{"type":48,"tag":243,"props":1529,"children":1530},{"class":245,"line":334},[1531],{"type":48,"tag":243,"props":1532,"children":1533},{},[1534],{"type":53,"value":712},{"type":48,"tag":243,"props":1536,"children":1537},{"class":245,"line":343},[1538],{"type":48,"tag":243,"props":1539,"children":1540},{},[1541],{"type":53,"value":1542},"  CASE WHEN histogram_id IS NULL THEN 0 ELSE 1 END,  -- Missing first\n",{"type":48,"tag":243,"props":1544,"children":1545},{"class":245,"line":352},[1546],{"type":48,"tag":243,"props":1547,"children":1548},{},[1549],{"type":53,"value":728},{"type":48,"tag":56,"props":1551,"children":1552},{},[1553],{"type":48,"tag":74,"props":1554,"children":1555},{},[1556],{"type":53,"value":492},{"type":48,"tag":98,"props":1558,"children":1559},{},[1560],{"type":48,"tag":102,"props":1561,"children":1562},{},[1563],{"type":53,"value":1564},"Replace database_name.schema_name.table_name",{"type":48,"tag":56,"props":1566,"children":1567},{},[1568],{"type":48,"tag":74,"props":1569,"children":1570},{},[1571],{"type":53,"value":557},{"type":48,"tag":98,"props":1573,"children":1574},{},[1575,1586],{"type":48,"tag":102,"props":1576,"children":1577},{},[1578,1584],{"type":48,"tag":62,"props":1579,"children":1581},{"className":1580},[],[1582],{"type":53,"value":1583},"histogram_status",{"type":53,"value":1585},": Indicates distribution data availability",{"type":48,"tag":102,"props":1587,"children":1588},{},[1589,1594],{"type":48,"tag":62,"props":1590,"children":1592},{"className":1591},[],[1593],{"type":53,"value":580},{"type":53,"value":1595},": Time since histogram last updated",{"type":48,"tag":56,"props":1597,"children":1598},{},[1599],{"type":48,"tag":74,"props":1600,"children":1601},{},[1602],{"type":53,"value":820},{"type":48,"tag":98,"props":1604,"children":1605},{},[1606,1616,1626],{"type":48,"tag":102,"props":1607,"children":1608},{},[1609,1614],{"type":48,"tag":74,"props":1610,"children":1611},{},[1612],{"type":53,"value":1613},"Has histogram",{"type":53,"value":1615},": Optimizer can estimate range scan selectivity (BETWEEN, >, \u003C)",{"type":48,"tag":102,"props":1617,"children":1618},{},[1619,1624],{"type":48,"tag":74,"props":1620,"children":1621},{},[1622],{"type":53,"value":1623},"Missing histogram",{"type":53,"value":1625},": Optimizer uses uniform distribution assumption (less accurate)",{"type":48,"tag":102,"props":1627,"children":1628},{},[1629],{"type":53,"value":1630},"Automatic collection creates histograms; missing indicates very new column or disabled collection",{"type":48,"tag":220,"props":1632,"children":1634},{"id":1633},"query-6-multi-column-statistics-detection",[1635],{"type":53,"value":1636},"Query 6: Multi-Column Statistics Detection",{"type":48,"tag":56,"props":1638,"children":1639},{},[1640],{"type":53,"value":1641},"Identifies existing multi-column (composite) statistics for correlated columns.",{"type":48,"tag":232,"props":1643,"children":1645},{"className":234,"code":1644,"language":236,"meta":237,"style":237},"SELECT\n  column_names,\n  created,\n  now() - created AS stats_age,\n  row_count,\n  ARRAY_LENGTH(column_names, 1) AS column_count\nFROM [SHOW STATISTICS FOR TABLE database_name.schema_name.table_name]\nWHERE ARRAY_LENGTH(column_names, 1) > 1  -- Multi-column only\nORDER BY created DESC;\n",[1646],{"type":48,"tag":62,"props":1647,"children":1648},{"__ignoreMap":237},[1649,1656,1663,1670,1677,1684,1692,1699,1707],{"type":48,"tag":243,"props":1650,"children":1651},{"class":245,"line":246},[1652],{"type":48,"tag":243,"props":1653,"children":1654},{},[1655],{"type":53,"value":358},{"type":48,"tag":243,"props":1657,"children":1658},{"class":245,"line":29},[1659],{"type":48,"tag":243,"props":1660,"children":1661},{},[1662],{"type":53,"value":626},{"type":48,"tag":243,"props":1664,"children":1665},{"class":245,"line":25},[1666],{"type":48,"tag":243,"props":1667,"children":1668},{},[1669],{"type":53,"value":657},{"type":48,"tag":243,"props":1671,"children":1672},{"class":245,"line":271},[1673],{"type":48,"tag":243,"props":1674,"children":1675},{},[1676],{"type":53,"value":665},{"type":48,"tag":243,"props":1678,"children":1679},{"class":245,"line":280},[1680],{"type":48,"tag":243,"props":1681,"children":1682},{},[1683],{"type":53,"value":376},{"type":48,"tag":243,"props":1685,"children":1686},{"class":245,"line":289},[1687],{"type":48,"tag":243,"props":1688,"children":1689},{},[1690],{"type":53,"value":1691},"  ARRAY_LENGTH(column_names, 1) AS column_count\n",{"type":48,"tag":243,"props":1693,"children":1694},{"class":245,"line":298},[1695],{"type":48,"tag":243,"props":1696,"children":1697},{},[1698],{"type":53,"value":704},{"type":48,"tag":243,"props":1700,"children":1701},{"class":245,"line":307},[1702],{"type":48,"tag":243,"props":1703,"children":1704},{},[1705],{"type":53,"value":1706},"WHERE ARRAY_LENGTH(column_names, 1) > 1  -- Multi-column only\n",{"type":48,"tag":243,"props":1708,"children":1709},{"class":245,"line":316},[1710],{"type":48,"tag":243,"props":1711,"children":1712},{},[1713],{"type":53,"value":1714},"ORDER BY created DESC;\n",{"type":48,"tag":56,"props":1716,"children":1717},{},[1718],{"type":48,"tag":74,"props":1719,"children":1720},{},[1721],{"type":53,"value":492},{"type":48,"tag":98,"props":1723,"children":1724},{},[1725],{"type":48,"tag":102,"props":1726,"children":1727},{},[1728],{"type":53,"value":1564},{"type":48,"tag":56,"props":1730,"children":1731},{},[1732],{"type":48,"tag":74,"props":1733,"children":1734},{},[1735],{"type":53,"value":557},{"type":48,"tag":98,"props":1737,"children":1738},{},[1739,1749],{"type":48,"tag":102,"props":1740,"children":1741},{},[1742,1747],{"type":48,"tag":62,"props":1743,"children":1745},{"className":1744},[],[1746],{"type":53,"value":769},{"type":53,"value":1748},": Array of correlated columns",{"type":48,"tag":102,"props":1750,"children":1751},{},[1752,1758],{"type":48,"tag":62,"props":1753,"children":1755},{"className":1754},[],[1756],{"type":53,"value":1757},"column_count",{"type":53,"value":1759},": Number of columns in composite statistic",{"type":48,"tag":56,"props":1761,"children":1762},{},[1763],{"type":48,"tag":74,"props":1764,"children":1765},{},[1766],{"type":53,"value":820},{"type":48,"tag":98,"props":1768,"children":1769},{},[1770,1780,1790],{"type":48,"tag":102,"props":1771,"children":1772},{},[1773,1778],{"type":48,"tag":74,"props":1774,"children":1775},{},[1776],{"type":53,"value":1777},"Present",{"type":53,"value":1779},": Multi-column statistics exist — either auto-collected for an index column group or manually created",{"type":48,"tag":102,"props":1781,"children":1782},{},[1783,1788],{"type":48,"tag":74,"props":1784,"children":1785},{},[1786],{"type":53,"value":1787},"Absent",{"type":53,"value":1789},": No multi-column stats yet; may need manual creation for correlated non-indexed columns (e.g., city + state + zip)",{"type":48,"tag":102,"props":1791,"children":1792},{},[1793],{"type":53,"value":1794},"Common use case: Manual stats on correlated columns that aren't covered by an index",{"type":48,"tag":56,"props":1796,"children":1797},{},[1798,1799,1804],{"type":53,"value":205},{"type":48,"tag":82,"props":1800,"children":1802},{"href":1801},"references\u002Fcreate-statistics-examples.md",[1803],{"type":53,"value":1801},{"type":53,"value":1805}," for multi-column creation patterns.",{"type":48,"tag":220,"props":1807,"children":1809},{"id":1808},"query-7-generate-create-statistics-recommendations",[1810],{"type":53,"value":1811},"Query 7: Generate CREATE STATISTICS Recommendations",{"type":48,"tag":56,"props":1813,"children":1814},{},[1815],{"type":53,"value":1816},"Produces ready-to-run CREATE STATISTICS commands for tables with stale or missing statistics.",{"type":48,"tag":232,"props":1818,"children":1820},{"className":234,"code":1819,"language":236,"meta":237,"style":237},"WITH stale_tables AS (\n  SELECT\n    table_schema,\n    table_name,\n    created,\n    now() - created AS stats_age\n  FROM [SHOW STATISTICS FOR TABLE database_name.*]\n  WHERE column_names = '{}'\n    AND (created IS NULL OR now() - created > INTERVAL '7 days')  -- Adjust threshold\n)\nSELECT\n  table_schema || '.' || table_name AS full_table_name,\n  stats_age,\n  'CREATE STATISTICS __auto__ FROM ' || table_schema || '.' || table_name || ';' AS create_command\nFROM stale_tables\nORDER BY stats_age DESC NULLS FIRST\nLIMIT 50;\n",[1821],{"type":48,"tag":62,"props":1822,"children":1823},{"__ignoreMap":237},[1824,1832,1839,1846,1853,1860,1867,1875,1883,1891,1898,1905,1912,1919,1927,1935,1942],{"type":48,"tag":243,"props":1825,"children":1826},{"class":245,"line":246},[1827],{"type":48,"tag":243,"props":1828,"children":1829},{},[1830],{"type":53,"value":1831},"WITH stale_tables AS (\n",{"type":48,"tag":243,"props":1833,"children":1834},{"class":245,"line":29},[1835],{"type":48,"tag":243,"props":1836,"children":1837},{},[1838],{"type":53,"value":260},{"type":48,"tag":243,"props":1840,"children":1841},{"class":245,"line":25},[1842],{"type":48,"tag":243,"props":1843,"children":1844},{},[1845],{"type":53,"value":277},{"type":48,"tag":243,"props":1847,"children":1848},{"class":245,"line":271},[1849],{"type":48,"tag":243,"props":1850,"children":1851},{},[1852],{"type":53,"value":286},{"type":48,"tag":243,"props":1854,"children":1855},{"class":245,"line":280},[1856],{"type":48,"tag":243,"props":1857,"children":1858},{},[1859],{"type":53,"value":313},{"type":48,"tag":243,"props":1861,"children":1862},{"class":245,"line":289},[1863],{"type":48,"tag":243,"props":1864,"children":1865},{},[1866],{"type":53,"value":322},{"type":48,"tag":243,"props":1868,"children":1869},{"class":245,"line":298},[1870],{"type":48,"tag":243,"props":1871,"children":1872},{},[1873],{"type":53,"value":1874},"  FROM [SHOW STATISTICS FOR TABLE database_name.*]\n",{"type":48,"tag":243,"props":1876,"children":1877},{"class":245,"line":307},[1878],{"type":48,"tag":243,"props":1879,"children":1880},{},[1881],{"type":53,"value":1882},"  WHERE column_names = '{}'\n",{"type":48,"tag":243,"props":1884,"children":1885},{"class":245,"line":316},[1886],{"type":48,"tag":243,"props":1887,"children":1888},{},[1889],{"type":53,"value":1890},"    AND (created IS NULL OR now() - created > INTERVAL '7 days')  -- Adjust threshold\n",{"type":48,"tag":243,"props":1892,"children":1893},{"class":245,"line":325},[1894],{"type":48,"tag":243,"props":1895,"children":1896},{},[1897],{"type":53,"value":349},{"type":48,"tag":243,"props":1899,"children":1900},{"class":245,"line":334},[1901],{"type":48,"tag":243,"props":1902,"children":1903},{},[1904],{"type":53,"value":358},{"type":48,"tag":243,"props":1906,"children":1907},{"class":245,"line":343},[1908],{"type":48,"tag":243,"props":1909,"children":1910},{},[1911],{"type":53,"value":367},{"type":48,"tag":243,"props":1913,"children":1914},{"class":245,"line":352},[1915],{"type":48,"tag":243,"props":1916,"children":1917},{},[1918],{"type":53,"value":394},{"type":48,"tag":243,"props":1920,"children":1921},{"class":245,"line":361},[1922],{"type":48,"tag":243,"props":1923,"children":1924},{},[1925],{"type":53,"value":1926},"  'CREATE STATISTICS __auto__ FROM ' || table_schema || '.' || table_name || ';' AS create_command\n",{"type":48,"tag":243,"props":1928,"children":1929},{"class":245,"line":370},[1930],{"type":48,"tag":243,"props":1931,"children":1932},{},[1933],{"type":53,"value":1934},"FROM stale_tables\n",{"type":48,"tag":243,"props":1936,"children":1937},{"class":245,"line":379},[1938],{"type":48,"tag":243,"props":1939,"children":1940},{},[1941],{"type":53,"value":475},{"type":48,"tag":243,"props":1943,"children":1944},{"class":245,"line":388},[1945],{"type":48,"tag":243,"props":1946,"children":1947},{},[1948],{"type":53,"value":484},{"type":48,"tag":56,"props":1950,"children":1951},{},[1952],{"type":48,"tag":74,"props":1953,"children":1954},{},[1955],{"type":53,"value":492},{"type":48,"tag":98,"props":1957,"children":1958},{},[1959,1970,1982],{"type":48,"tag":102,"props":1960,"children":1961},{},[1962,1963,1968],{"type":53,"value":500},{"type":48,"tag":62,"props":1964,"children":1966},{"className":1965},[],[1967],{"type":53,"value":506},{"type":53,"value":1969}," with schema pattern",{"type":48,"tag":102,"props":1971,"children":1972},{},[1973,1975,1980],{"type":53,"value":1974},"Adjust ",{"type":48,"tag":62,"props":1976,"children":1978},{"className":1977},[],[1979],{"type":53,"value":526},{"type":53,"value":1981}," staleness threshold",{"type":48,"tag":102,"props":1983,"children":1984},{},[1985,1986,1991],{"type":53,"value":541},{"type":48,"tag":62,"props":1987,"children":1989},{"className":1988},[],[1990],{"type":53,"value":547},{"type":53,"value":1992}," for more recommendations",{"type":48,"tag":56,"props":1994,"children":1995},{},[1996],{"type":48,"tag":74,"props":1997,"children":1998},{},[1999],{"type":53,"value":2000},"Output:",{"type":48,"tag":98,"props":2002,"children":2003},{},[2004,2015],{"type":48,"tag":102,"props":2005,"children":2006},{},[2007,2013],{"type":48,"tag":62,"props":2008,"children":2010},{"className":2009},[],[2011],{"type":53,"value":2012},"create_command",{"type":53,"value":2014},": Copy-paste ready SQL command",{"type":48,"tag":102,"props":2016,"children":2017},{},[2018,2024],{"type":48,"tag":62,"props":2019,"children":2021},{"className":2020},[],[2022],{"type":53,"value":2023},"__auto__",{"type":53,"value":2025},": Uses automatic column selection (recommended default)",{"type":48,"tag":56,"props":2027,"children":2028},{},[2029],{"type":48,"tag":74,"props":2030,"children":2031},{},[2032],{"type":53,"value":2033},"Execution:",{"type":48,"tag":98,"props":2035,"children":2036},{},[2037,2042,2047],{"type":48,"tag":102,"props":2038,"children":2039},{},[2040],{"type":53,"value":2041},"Review generated commands before execution",{"type":48,"tag":102,"props":2043,"children":2044},{},[2045],{"type":53,"value":2046},"Run during low-traffic periods for large tables (>10M rows)",{"type":48,"tag":102,"props":2048,"children":2049},{},[2050],{"type":53,"value":2051},"Monitor job progress (see Query 6 for job monitoring)",{"type":48,"tag":91,"props":2053,"children":2055},{"id":2054},"common-workflows",[2056],{"type":53,"value":2057},"Common Workflows",{"type":48,"tag":220,"props":2059,"children":2061},{"id":2060},"workflow-1-post-bulk-load-statistics-audit",[2062],{"type":53,"value":2063},"Workflow 1: Post-Bulk-Load Statistics Audit",{"type":48,"tag":56,"props":2065,"children":2066},{},[2067,2072],{"type":48,"tag":74,"props":2068,"children":2069},{},[2070],{"type":53,"value":2071},"Scenario:",{"type":53,"value":2073}," After bulk INSERT\u002FCOPY\u002FIMPORT operation, validate statistics are current.",{"type":48,"tag":56,"props":2075,"children":2076},{},[2077],{"type":48,"tag":74,"props":2078,"children":2079},{},[2080],{"type":53,"value":2081},"Steps:",{"type":48,"tag":2083,"props":2084,"children":2085},"ol",{},[2086,2133,2143,2165,2228],{"type":48,"tag":102,"props":2087,"children":2088},{},[2089,2094],{"type":48,"tag":74,"props":2090,"children":2091},{},[2092],{"type":53,"value":2093},"Identify affected tables:",{"type":48,"tag":232,"props":2095,"children":2097},{"className":234,"code":2096,"language":236,"meta":237,"style":237},"-- List tables modified in last 24 hours\nSELECT DISTINCT table_schema || '.' || table_name AS full_table_name\nFROM [SHOW TABLES]\nWHERE table_schema = 'target_schema';  -- Replace\n",[2098],{"type":48,"tag":62,"props":2099,"children":2100},{"__ignoreMap":237},[2101,2109,2117,2125],{"type":48,"tag":243,"props":2102,"children":2103},{"class":245,"line":246},[2104],{"type":48,"tag":243,"props":2105,"children":2106},{},[2107],{"type":53,"value":2108},"-- List tables modified in last 24 hours\n",{"type":48,"tag":243,"props":2110,"children":2111},{"class":245,"line":29},[2112],{"type":48,"tag":243,"props":2113,"children":2114},{},[2115],{"type":53,"value":2116},"SELECT DISTINCT table_schema || '.' || table_name AS full_table_name\n",{"type":48,"tag":243,"props":2118,"children":2119},{"class":245,"line":25},[2120],{"type":48,"tag":243,"props":2121,"children":2122},{},[2123],{"type":53,"value":2124},"FROM [SHOW TABLES]\n",{"type":48,"tag":243,"props":2126,"children":2127},{"class":245,"line":271},[2128],{"type":48,"tag":243,"props":2129,"children":2130},{},[2131],{"type":53,"value":2132},"WHERE table_schema = 'target_schema';  -- Replace\n",{"type":48,"tag":102,"props":2134,"children":2135},{},[2136,2141],{"type":48,"tag":74,"props":2137,"children":2138},{},[2139],{"type":53,"value":2140},"Check row count drift (Query 3):",{"type":53,"value":2142},"\nRun drift detection query for each affected table.",{"type":48,"tag":102,"props":2144,"children":2145},{},[2146,2151],{"type":48,"tag":74,"props":2147,"children":2148},{},[2149],{"type":53,"value":2150},"Generate and execute refresh commands (Query 7):",{"type":48,"tag":232,"props":2152,"children":2154},{"className":234,"code":2153,"language":236,"meta":237,"style":237},"CREATE STATISTICS __auto__ FROM schema_name.table_name;  -- From Query 7 output\n",[2155],{"type":48,"tag":62,"props":2156,"children":2157},{"__ignoreMap":237},[2158],{"type":48,"tag":243,"props":2159,"children":2160},{"class":245,"line":246},[2161],{"type":48,"tag":243,"props":2162,"children":2163},{},[2164],{"type":53,"value":2153},{"type":48,"tag":102,"props":2166,"children":2167},{},[2168,2173],{"type":48,"tag":74,"props":2169,"children":2170},{},[2171],{"type":53,"value":2172},"Monitor collection job:",{"type":48,"tag":232,"props":2174,"children":2176},{"className":234,"code":2175,"language":236,"meta":237,"style":237},"SELECT job_id, status, fraction_completed, running_status\nFROM [SHOW JOBS]\nWHERE job_type = 'CREATE STATS'\n  AND created > now() - INTERVAL '1 hour'\nORDER BY created DESC\nLIMIT 10;\n",[2177],{"type":48,"tag":62,"props":2178,"children":2179},{"__ignoreMap":237},[2180,2188,2196,2204,2212,2220],{"type":48,"tag":243,"props":2181,"children":2182},{"class":245,"line":246},[2183],{"type":48,"tag":243,"props":2184,"children":2185},{},[2186],{"type":53,"value":2187},"SELECT job_id, status, fraction_completed, running_status\n",{"type":48,"tag":243,"props":2189,"children":2190},{"class":245,"line":29},[2191],{"type":48,"tag":243,"props":2192,"children":2193},{},[2194],{"type":53,"value":2195},"FROM [SHOW JOBS]\n",{"type":48,"tag":243,"props":2197,"children":2198},{"class":245,"line":25},[2199],{"type":48,"tag":243,"props":2200,"children":2201},{},[2202],{"type":53,"value":2203},"WHERE job_type = 'CREATE STATS'\n",{"type":48,"tag":243,"props":2205,"children":2206},{"class":245,"line":271},[2207],{"type":48,"tag":243,"props":2208,"children":2209},{},[2210],{"type":53,"value":2211},"  AND created > now() - INTERVAL '1 hour'\n",{"type":48,"tag":243,"props":2213,"children":2214},{"class":245,"line":280},[2215],{"type":48,"tag":243,"props":2216,"children":2217},{},[2218],{"type":53,"value":2219},"ORDER BY created DESC\n",{"type":48,"tag":243,"props":2221,"children":2222},{"class":245,"line":289},[2223],{"type":48,"tag":243,"props":2224,"children":2225},{},[2226],{"type":53,"value":2227},"LIMIT 10;\n",{"type":48,"tag":102,"props":2229,"children":2230},{},[2231,2236,2238,2244],{"type":48,"tag":74,"props":2232,"children":2233},{},[2234],{"type":53,"value":2235},"Verify refresh (Query 2):",{"type":53,"value":2237},"\nRe-run statistics audit to confirm ",{"type":48,"tag":62,"props":2239,"children":2241},{"className":2240},[],[2242],{"type":53,"value":2243},"created",{"type":53,"value":2245}," timestamp updated.",{"type":48,"tag":56,"props":2247,"children":2248},{},[2249,2254],{"type":48,"tag":74,"props":2250,"children":2251},{},[2252],{"type":53,"value":2253},"Expected outcome:",{"type":53,"value":2255}," Statistics age \u003C1 hour, drift_pct \u003C5%.",{"type":48,"tag":220,"props":2257,"children":2259},{"id":2258},"workflow-2-diagnose-unexpected-query-plan-changes",[2260],{"type":53,"value":2261},"Workflow 2: Diagnose Unexpected Query Plan Changes",{"type":48,"tag":56,"props":2263,"children":2264},{},[2265,2269],{"type":48,"tag":74,"props":2266,"children":2267},{},[2268],{"type":53,"value":2071},{"type":53,"value":2270}," Query performance suddenly degrades; EXPLAIN shows different plan.",{"type":48,"tag":56,"props":2272,"children":2273},{},[2274],{"type":48,"tag":74,"props":2275,"children":2276},{},[2277],{"type":53,"value":2081},{"type":48,"tag":2083,"props":2279,"children":2280},{},[2281,2297,2307,2317,2379,2389],{"type":48,"tag":102,"props":2282,"children":2283},{},[2284,2295],{"type":48,"tag":74,"props":2285,"children":2286},{},[2287,2289,2293],{"type":53,"value":2288},"Identify affected query from ",{"type":48,"tag":82,"props":2290,"children":2291},{"href":84},[2292],{"type":53,"value":87},{"type":53,"value":2294},":",{"type":53,"value":2296},"\nFind query with latency spike or plan hash change.",{"type":48,"tag":102,"props":2298,"children":2299},{},[2300,2305],{"type":48,"tag":74,"props":2301,"children":2302},{},[2303],{"type":53,"value":2304},"Extract table references:",{"type":53,"value":2306},"\nParse query text to identify tables in FROM\u002FJOIN clauses.",{"type":48,"tag":102,"props":2308,"children":2309},{},[2310,2315],{"type":48,"tag":74,"props":2311,"children":2312},{},[2313],{"type":53,"value":2314},"Audit statistics for each table (Query 2):",{"type":53,"value":2316},"\nCheck staleness and row count currency.",{"type":48,"tag":102,"props":2318,"children":2319},{},[2320,2325],{"type":48,"tag":74,"props":2321,"children":2322},{},[2323],{"type":53,"value":2324},"Compare historical vs current row counts:",{"type":48,"tag":232,"props":2326,"children":2328},{"className":234,"code":2327,"language":236,"meta":237,"style":237},"-- Example: Check if table grew significantly\nSELECT row_count, created\nFROM [SHOW STATISTICS FOR TABLE users]\nWHERE column_names = '{}'\nORDER BY created DESC\nLIMIT 5;  -- Last 5 collections\n",[2329],{"type":48,"tag":62,"props":2330,"children":2331},{"__ignoreMap":237},[2332,2340,2348,2356,2364,2371],{"type":48,"tag":243,"props":2333,"children":2334},{"class":245,"line":246},[2335],{"type":48,"tag":243,"props":2336,"children":2337},{},[2338],{"type":53,"value":2339},"-- Example: Check if table grew significantly\n",{"type":48,"tag":243,"props":2341,"children":2342},{"class":245,"line":29},[2343],{"type":48,"tag":243,"props":2344,"children":2345},{},[2346],{"type":53,"value":2347},"SELECT row_count, created\n",{"type":48,"tag":243,"props":2349,"children":2350},{"class":245,"line":25},[2351],{"type":48,"tag":243,"props":2352,"children":2353},{},[2354],{"type":53,"value":2355},"FROM [SHOW STATISTICS FOR TABLE users]\n",{"type":48,"tag":243,"props":2357,"children":2358},{"class":245,"line":271},[2359],{"type":48,"tag":243,"props":2360,"children":2361},{},[2362],{"type":53,"value":2363},"WHERE column_names = '{}'\n",{"type":48,"tag":243,"props":2365,"children":2366},{"class":245,"line":280},[2367],{"type":48,"tag":243,"props":2368,"children":2369},{},[2370],{"type":53,"value":2219},{"type":48,"tag":243,"props":2372,"children":2373},{"class":245,"line":289},[2374],{"type":48,"tag":243,"props":2375,"children":2376},{},[2377],{"type":53,"value":2378},"LIMIT 5;  -- Last 5 collections\n",{"type":48,"tag":102,"props":2380,"children":2381},{},[2382,2387],{"type":48,"tag":74,"props":2383,"children":2384},{},[2385],{"type":53,"value":2386},"Refresh stale statistics (Query 7):",{"type":53,"value":2388},"\nExecute CREATE STATISTICS for tables with high drift.",{"type":48,"tag":102,"props":2390,"children":2391},{},[2392,2397],{"type":48,"tag":74,"props":2393,"children":2394},{},[2395],{"type":53,"value":2396},"Validate plan stability:",{"type":53,"value":2398},"\nRe-run EXPLAIN to verify plan returns to expected structure.",{"type":48,"tag":56,"props":2400,"children":2401},{},[2402,2406],{"type":48,"tag":74,"props":2403,"children":2404},{},[2405],{"type":53,"value":2253},{"type":53,"value":2407}," Plan hash stabilizes, latency returns to baseline after statistics refresh.",{"type":48,"tag":220,"props":2409,"children":2411},{"id":2410},"workflow-3-routine-statistics-health-check",[2412],{"type":53,"value":2413},"Workflow 3: Routine Statistics Health Check",{"type":48,"tag":56,"props":2415,"children":2416},{},[2417,2421],{"type":48,"tag":74,"props":2418,"children":2419},{},[2420],{"type":53,"value":2071},{"type":53,"value":2422}," Periodic audit to proactively identify statistics issues before performance degrades.",{"type":48,"tag":56,"props":2424,"children":2425},{},[2426],{"type":48,"tag":74,"props":2427,"children":2428},{},[2429],{"type":53,"value":2081},{"type":48,"tag":2083,"props":2431,"children":2432},{},[2433,2464,2479,2501,2554,2564],{"type":48,"tag":102,"props":2434,"children":2435},{},[2436,2441],{"type":48,"tag":74,"props":2437,"children":2438},{},[2439],{"type":53,"value":2440},"Run cluster-wide staleness scan (Query 1):",{"type":48,"tag":232,"props":2442,"children":2444},{"className":234,"code":2443,"language":236,"meta":237,"style":237},"-- All databases\nSHOW STATISTICS FOR TABLE *.*;  -- Warning: May be slow on large clusters\n",[2445],{"type":48,"tag":62,"props":2446,"children":2447},{"__ignoreMap":237},[2448,2456],{"type":48,"tag":243,"props":2449,"children":2450},{"class":245,"line":246},[2451],{"type":48,"tag":243,"props":2452,"children":2453},{},[2454],{"type":53,"value":2455},"-- All databases\n",{"type":48,"tag":243,"props":2457,"children":2458},{"class":245,"line":29},[2459],{"type":48,"tag":243,"props":2460,"children":2461},{},[2462],{"type":53,"value":2463},"SHOW STATISTICS FOR TABLE *.*;  -- Warning: May be slow on large clusters\n",{"type":48,"tag":102,"props":2465,"children":2466},{},[2467,2472,2474,2478],{"type":48,"tag":74,"props":2468,"children":2469},{},[2470],{"type":53,"value":2471},"Prioritize critical tables:",{"type":53,"value":2473},"\nFocus on high-traffic tables from ",{"type":48,"tag":82,"props":2475,"children":2476},{"href":84},[2477],{"type":53,"value":87},{"type":53,"value":89},{"type":48,"tag":102,"props":2480,"children":2481},{},[2482,2487],{"type":48,"tag":74,"props":2483,"children":2484},{},[2485],{"type":53,"value":2486},"Check automatic collection is enabled:",{"type":48,"tag":232,"props":2488,"children":2490},{"className":234,"code":2489,"language":236,"meta":237,"style":237},"SHOW CLUSTER SETTING sql.stats.automatic_collection.enabled;  -- Should be true\n",[2491],{"type":48,"tag":62,"props":2492,"children":2493},{"__ignoreMap":237},[2494],{"type":48,"tag":243,"props":2495,"children":2496},{"class":245,"line":246},[2497],{"type":48,"tag":243,"props":2498,"children":2499},{},[2500],{"type":53,"value":2489},{"type":48,"tag":102,"props":2502,"children":2503},{},[2504,2509],{"type":48,"tag":74,"props":2505,"children":2506},{},[2507],{"type":53,"value":2508},"Review pending auto-collection jobs:",{"type":48,"tag":232,"props":2510,"children":2512},{"className":234,"code":2511,"language":236,"meta":237,"style":237},"SELECT job_id, description, status, fraction_completed\nFROM [SHOW JOBS]\nWHERE job_type = 'AUTO CREATE STATS'\n  AND status IN ('pending', 'running')\nORDER BY created DESC;\n",[2513],{"type":48,"tag":62,"props":2514,"children":2515},{"__ignoreMap":237},[2516,2524,2531,2539,2547],{"type":48,"tag":243,"props":2517,"children":2518},{"class":245,"line":246},[2519],{"type":48,"tag":243,"props":2520,"children":2521},{},[2522],{"type":53,"value":2523},"SELECT job_id, description, status, fraction_completed\n",{"type":48,"tag":243,"props":2525,"children":2526},{"class":245,"line":29},[2527],{"type":48,"tag":243,"props":2528,"children":2529},{},[2530],{"type":53,"value":2195},{"type":48,"tag":243,"props":2532,"children":2533},{"class":245,"line":25},[2534],{"type":48,"tag":243,"props":2535,"children":2536},{},[2537],{"type":53,"value":2538},"WHERE job_type = 'AUTO CREATE STATS'\n",{"type":48,"tag":243,"props":2540,"children":2541},{"class":245,"line":271},[2542],{"type":48,"tag":243,"props":2543,"children":2544},{},[2545],{"type":53,"value":2546},"  AND status IN ('pending', 'running')\n",{"type":48,"tag":243,"props":2548,"children":2549},{"class":245,"line":280},[2550],{"type":48,"tag":243,"props":2551,"children":2552},{},[2553],{"type":53,"value":1714},{"type":48,"tag":102,"props":2555,"children":2556},{},[2557,2562],{"type":48,"tag":74,"props":2558,"children":2559},{},[2560],{"type":53,"value":2561},"Generate batch refresh script (Query 7):",{"type":53,"value":2563},"\nSave output to file for scheduled execution.",{"type":48,"tag":102,"props":2565,"children":2566},{},[2567,2572],{"type":48,"tag":74,"props":2568,"children":2569},{},[2570],{"type":53,"value":2571},"Schedule refresh during maintenance window:",{"type":53,"value":2573},"\nExecute generated CREATE STATISTICS commands during low-traffic period.",{"type":48,"tag":56,"props":2575,"children":2576},{},[2577,2582],{"type":48,"tag":74,"props":2578,"children":2579},{},[2580],{"type":53,"value":2581},"Frequency:",{"type":53,"value":2583}," Weekly for OLTP, monthly for OLAP.",{"type":48,"tag":91,"props":2585,"children":2587},{"id":2586},"safety-considerations",[2588],{"type":53,"value":2589},"Safety Considerations",{"type":48,"tag":220,"props":2591,"children":2593},{"id":2592},"production-safe-operations",[2594],{"type":53,"value":2595},"Production-Safe Operations",{"type":48,"tag":56,"props":2597,"children":2598},{},[2599],{"type":48,"tag":74,"props":2600,"children":2601},{},[2602],{"type":53,"value":2603},"SHOW STATISTICS:",{"type":48,"tag":98,"props":2605,"children":2606},{},[2607,2617],{"type":48,"tag":102,"props":2608,"children":2609},{},[2610,2615],{"type":48,"tag":74,"props":2611,"children":2612},{},[2613],{"type":53,"value":2614},"Impact:",{"type":53,"value":2616}," Read-only, no cluster impact",{"type":48,"tag":102,"props":2618,"children":2619},{},[2620,2625],{"type":48,"tag":74,"props":2621,"children":2622},{},[2623],{"type":53,"value":2624},"Safe for production:",{"type":53,"value":2626}," Yes, run anytime without restrictions",{"type":48,"tag":56,"props":2628,"children":2629},{},[2630],{"type":48,"tag":74,"props":2631,"children":2632},{},[2633],{"type":53,"value":2634},"CREATE STATISTICS:",{"type":48,"tag":98,"props":2636,"children":2637},{},[2638,2647,2673],{"type":48,"tag":102,"props":2639,"children":2640},{},[2641,2645],{"type":48,"tag":74,"props":2642,"children":2643},{},[2644],{"type":53,"value":2614},{"type":53,"value":2646}," CPU\u002FIO-intensive, non-blocking table scans",{"type":48,"tag":102,"props":2648,"children":2649},{},[2650,2655],{"type":48,"tag":74,"props":2651,"children":2652},{},[2653],{"type":53,"value":2654},"Safety:",{"type":48,"tag":98,"props":2656,"children":2657},{},[2658,2663,2668],{"type":48,"tag":102,"props":2659,"children":2660},{},[2661],{"type":53,"value":2662},"Does NOT lock table or block writes",{"type":48,"tag":102,"props":2664,"children":2665},{},[2666],{"type":53,"value":2667},"Consumes resources (CPU, network, disk I\u002FO)",{"type":48,"tag":102,"props":2669,"children":2670},{},[2671],{"type":53,"value":2672},"May impact query performance during collection on large tables",{"type":48,"tag":102,"props":2674,"children":2675},{},[2676,2681],{"type":48,"tag":74,"props":2677,"children":2678},{},[2679],{"type":53,"value":2680},"Best practices:",{"type":48,"tag":98,"props":2682,"children":2683},{},[2684,2689,2694],{"type":48,"tag":102,"props":2685,"children":2686},{},[2687],{"type":53,"value":2688},"Run during low-traffic periods for tables >10M rows",{"type":48,"tag":102,"props":2690,"children":2691},{},[2692],{"type":53,"value":2693},"Stagger execution (avoid creating statistics on many tables simultaneously)",{"type":48,"tag":102,"props":2695,"children":2696},{},[2697],{"type":53,"value":2698},"Monitor job progress and resource utilization",{"type":48,"tag":220,"props":2700,"children":2702},{"id":2701},"resource-consumption",[2703],{"type":53,"value":2704},"Resource Consumption",{"type":48,"tag":56,"props":2706,"children":2707},{},[2708,2713],{"type":48,"tag":74,"props":2709,"children":2710},{},[2711],{"type":53,"value":2712},"Small tables (\u003C10K rows):",{"type":53,"value":2714}," Negligible impact, safe anytime",{"type":48,"tag":56,"props":2716,"children":2717},{},[2718,2723],{"type":48,"tag":74,"props":2719,"children":2720},{},[2721],{"type":53,"value":2722},"Medium tables (10K-10M rows):",{"type":53,"value":2724}," Seconds to minutes, minor impact",{"type":48,"tag":56,"props":2726,"children":2727},{},[2728,2733],{"type":48,"tag":74,"props":2729,"children":2730},{},[2731],{"type":53,"value":2732},"Large tables (>10M rows):",{"type":53,"value":2734}," Minutes to hours, plan accordingly:",{"type":48,"tag":98,"props":2736,"children":2737},{},[2738,2743,2748],{"type":48,"tag":102,"props":2739,"children":2740},{},[2741],{"type":53,"value":2742},"Schedule during maintenance windows",{"type":48,"tag":102,"props":2744,"children":2745},{},[2746],{"type":53,"value":2747},"Monitor cluster metrics (CPU, disk I\u002FO) during collection",{"type":48,"tag":102,"props":2749,"children":2750},{},[2751,2753,2759],{"type":53,"value":2752},"Use ",{"type":48,"tag":62,"props":2754,"children":2756},{"className":2755},[],[2757],{"type":53,"value":2758},"SHOW JOBS",{"type":53,"value":2760}," to track progress",{"type":48,"tag":56,"props":2762,"children":2763},{},[2764],{"type":48,"tag":74,"props":2765,"children":2766},{},[2767],{"type":53,"value":2768},"Cancellation (if needed):",{"type":48,"tag":232,"props":2770,"children":2772},{"className":234,"code":2771,"language":236,"meta":237,"style":237},"-- Find job ID\nSELECT job_id, status, fraction_completed\nFROM [SHOW JOBS]\nWHERE job_type = 'CREATE STATS' AND status = 'running';\n\n-- Cancel job (non-destructive, existing statistics remain)\nCANCEL JOB 123456789012345678;\n",[2773],{"type":48,"tag":62,"props":2774,"children":2775},{"__ignoreMap":237},[2776,2784,2792,2799,2807,2816,2824],{"type":48,"tag":243,"props":2777,"children":2778},{"class":245,"line":246},[2779],{"type":48,"tag":243,"props":2780,"children":2781},{},[2782],{"type":53,"value":2783},"-- Find job ID\n",{"type":48,"tag":243,"props":2785,"children":2786},{"class":245,"line":29},[2787],{"type":48,"tag":243,"props":2788,"children":2789},{},[2790],{"type":53,"value":2791},"SELECT job_id, status, fraction_completed\n",{"type":48,"tag":243,"props":2793,"children":2794},{"class":245,"line":25},[2795],{"type":48,"tag":243,"props":2796,"children":2797},{},[2798],{"type":53,"value":2195},{"type":48,"tag":243,"props":2800,"children":2801},{"class":245,"line":271},[2802],{"type":48,"tag":243,"props":2803,"children":2804},{},[2805],{"type":53,"value":2806},"WHERE job_type = 'CREATE STATS' AND status = 'running';\n",{"type":48,"tag":243,"props":2808,"children":2809},{"class":245,"line":280},[2810],{"type":48,"tag":243,"props":2811,"children":2813},{"emptyLinePlaceholder":2812},true,[2814],{"type":53,"value":2815},"\n",{"type":48,"tag":243,"props":2817,"children":2818},{"class":245,"line":289},[2819],{"type":48,"tag":243,"props":2820,"children":2821},{},[2822],{"type":53,"value":2823},"-- Cancel job (non-destructive, existing statistics remain)\n",{"type":48,"tag":243,"props":2825,"children":2826},{"class":245,"line":298},[2827],{"type":48,"tag":243,"props":2828,"children":2829},{},[2830],{"type":53,"value":2831},"CANCEL JOB 123456789012345678;\n",{"type":48,"tag":220,"props":2833,"children":2835},{"id":2834},"batch-collection-best-practices",[2836],{"type":53,"value":2837},"Batch Collection Best Practices",{"type":48,"tag":56,"props":2839,"children":2840},{},[2841],{"type":48,"tag":74,"props":2842,"children":2843},{},[2844],{"type":53,"value":2845},"Avoid overwhelming cluster:",{"type":48,"tag":98,"props":2847,"children":2848},{},[2849,2854,2859],{"type":48,"tag":102,"props":2850,"children":2851},{},[2852],{"type":53,"value":2853},"Collect statistics for 3-5 tables concurrently maximum",{"type":48,"tag":102,"props":2855,"children":2856},{},[2857],{"type":53,"value":2858},"Wait for completion before starting next batch",{"type":48,"tag":102,"props":2860,"children":2861},{},[2862],{"type":53,"value":2863},"Monitor cluster health metrics between batches",{"type":48,"tag":56,"props":2865,"children":2866},{},[2867],{"type":48,"tag":74,"props":2868,"children":2869},{},[2870],{"type":53,"value":2871},"Example staggered script:",{"type":48,"tag":232,"props":2873,"children":2877},{"className":2874,"code":2875,"language":2876,"meta":237,"style":237},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","# Collect statistics in batches with delays\nfor table in table1 table2 table3; do\n  cockroach sql -e \"CREATE STATISTICS __auto__ FROM $table;\" &\ndone\nwait  # Wait for batch to complete\n\nsleep 60  # Delay between batches\n\nfor table in table4 table5 table6; do\n  cockroach sql -e \"CREATE STATISTICS __auto__ FROM $table;\" &\ndone\nwait\n","bash",[2878],{"type":48,"tag":62,"props":2879,"children":2880},{"__ignoreMap":237},[2881,2890,2937,2985,2993,3007,3014,3033,3040,3078,3117,3124],{"type":48,"tag":243,"props":2882,"children":2883},{"class":245,"line":246},[2884],{"type":48,"tag":243,"props":2885,"children":2887},{"style":2886},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[2888],{"type":53,"value":2889},"# Collect statistics in batches with delays\n",{"type":48,"tag":243,"props":2891,"children":2892},{"class":245,"line":29},[2893,2899,2905,2910,2916,2921,2926,2932],{"type":48,"tag":243,"props":2894,"children":2896},{"style":2895},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[2897],{"type":53,"value":2898},"for",{"type":48,"tag":243,"props":2900,"children":2902},{"style":2901},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[2903],{"type":53,"value":2904}," table ",{"type":48,"tag":243,"props":2906,"children":2907},{"style":2895},[2908],{"type":53,"value":2909},"in",{"type":48,"tag":243,"props":2911,"children":2913},{"style":2912},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[2914],{"type":53,"value":2915}," table1",{"type":48,"tag":243,"props":2917,"children":2918},{"style":2912},[2919],{"type":53,"value":2920}," table2",{"type":48,"tag":243,"props":2922,"children":2923},{"style":2912},[2924],{"type":53,"value":2925}," table3",{"type":48,"tag":243,"props":2927,"children":2929},{"style":2928},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[2930],{"type":53,"value":2931},";",{"type":48,"tag":243,"props":2933,"children":2934},{"style":2895},[2935],{"type":53,"value":2936}," do\n",{"type":48,"tag":243,"props":2938,"children":2939},{"class":245,"line":25},[2940,2946,2951,2956,2961,2966,2971,2975,2980],{"type":48,"tag":243,"props":2941,"children":2943},{"style":2942},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[2944],{"type":53,"value":2945},"  cockroach",{"type":48,"tag":243,"props":2947,"children":2948},{"style":2912},[2949],{"type":53,"value":2950}," sql",{"type":48,"tag":243,"props":2952,"children":2953},{"style":2912},[2954],{"type":53,"value":2955}," -e",{"type":48,"tag":243,"props":2957,"children":2958},{"style":2928},[2959],{"type":53,"value":2960}," \"",{"type":48,"tag":243,"props":2962,"children":2963},{"style":2912},[2964],{"type":53,"value":2965},"CREATE STATISTICS __auto__ FROM ",{"type":48,"tag":243,"props":2967,"children":2968},{"style":2901},[2969],{"type":53,"value":2970},"$table",{"type":48,"tag":243,"props":2972,"children":2973},{"style":2912},[2974],{"type":53,"value":2931},{"type":48,"tag":243,"props":2976,"children":2977},{"style":2928},[2978],{"type":53,"value":2979},"\"",{"type":48,"tag":243,"props":2981,"children":2982},{"style":2928},[2983],{"type":53,"value":2984}," &\n",{"type":48,"tag":243,"props":2986,"children":2987},{"class":245,"line":271},[2988],{"type":48,"tag":243,"props":2989,"children":2990},{"style":2895},[2991],{"type":53,"value":2992},"done\n",{"type":48,"tag":243,"props":2994,"children":2995},{"class":245,"line":280},[2996,3002],{"type":48,"tag":243,"props":2997,"children":2999},{"style":2998},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[3000],{"type":53,"value":3001},"wait",{"type":48,"tag":243,"props":3003,"children":3004},{"style":2886},[3005],{"type":53,"value":3006},"  # Wait for batch to complete\n",{"type":48,"tag":243,"props":3008,"children":3009},{"class":245,"line":289},[3010],{"type":48,"tag":243,"props":3011,"children":3012},{"emptyLinePlaceholder":2812},[3013],{"type":53,"value":2815},{"type":48,"tag":243,"props":3015,"children":3016},{"class":245,"line":298},[3017,3022,3028],{"type":48,"tag":243,"props":3018,"children":3019},{"style":2942},[3020],{"type":53,"value":3021},"sleep",{"type":48,"tag":243,"props":3023,"children":3025},{"style":3024},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[3026],{"type":53,"value":3027}," 60",{"type":48,"tag":243,"props":3029,"children":3030},{"style":2886},[3031],{"type":53,"value":3032},"  # Delay between batches\n",{"type":48,"tag":243,"props":3034,"children":3035},{"class":245,"line":307},[3036],{"type":48,"tag":243,"props":3037,"children":3038},{"emptyLinePlaceholder":2812},[3039],{"type":53,"value":2815},{"type":48,"tag":243,"props":3041,"children":3042},{"class":245,"line":316},[3043,3047,3051,3055,3060,3065,3070,3074],{"type":48,"tag":243,"props":3044,"children":3045},{"style":2895},[3046],{"type":53,"value":2898},{"type":48,"tag":243,"props":3048,"children":3049},{"style":2901},[3050],{"type":53,"value":2904},{"type":48,"tag":243,"props":3052,"children":3053},{"style":2895},[3054],{"type":53,"value":2909},{"type":48,"tag":243,"props":3056,"children":3057},{"style":2912},[3058],{"type":53,"value":3059}," table4",{"type":48,"tag":243,"props":3061,"children":3062},{"style":2912},[3063],{"type":53,"value":3064}," table5",{"type":48,"tag":243,"props":3066,"children":3067},{"style":2912},[3068],{"type":53,"value":3069}," table6",{"type":48,"tag":243,"props":3071,"children":3072},{"style":2928},[3073],{"type":53,"value":2931},{"type":48,"tag":243,"props":3075,"children":3076},{"style":2895},[3077],{"type":53,"value":2936},{"type":48,"tag":243,"props":3079,"children":3080},{"class":245,"line":325},[3081,3085,3089,3093,3097,3101,3105,3109,3113],{"type":48,"tag":243,"props":3082,"children":3083},{"style":2942},[3084],{"type":53,"value":2945},{"type":48,"tag":243,"props":3086,"children":3087},{"style":2912},[3088],{"type":53,"value":2950},{"type":48,"tag":243,"props":3090,"children":3091},{"style":2912},[3092],{"type":53,"value":2955},{"type":48,"tag":243,"props":3094,"children":3095},{"style":2928},[3096],{"type":53,"value":2960},{"type":48,"tag":243,"props":3098,"children":3099},{"style":2912},[3100],{"type":53,"value":2965},{"type":48,"tag":243,"props":3102,"children":3103},{"style":2901},[3104],{"type":53,"value":2970},{"type":48,"tag":243,"props":3106,"children":3107},{"style":2912},[3108],{"type":53,"value":2931},{"type":48,"tag":243,"props":3110,"children":3111},{"style":2928},[3112],{"type":53,"value":2979},{"type":48,"tag":243,"props":3114,"children":3115},{"style":2928},[3116],{"type":53,"value":2984},{"type":48,"tag":243,"props":3118,"children":3119},{"class":245,"line":334},[3120],{"type":48,"tag":243,"props":3121,"children":3122},{"style":2895},[3123],{"type":53,"value":2992},{"type":48,"tag":243,"props":3125,"children":3126},{"class":245,"line":343},[3127],{"type":48,"tag":243,"props":3128,"children":3129},{"style":2998},[3130],{"type":53,"value":3131},"wait\n",{"type":48,"tag":56,"props":3133,"children":3134},{},[3135,3136,3140],{"type":53,"value":205},{"type":48,"tag":82,"props":3137,"children":3138},{"href":1801},[3139],{"type":53,"value":1801},{"type":53,"value":3141}," for detailed batch patterns.",{"type":48,"tag":91,"props":3143,"children":3145},{"id":3144},"troubleshooting",[3146],{"type":53,"value":3147},"Troubleshooting",{"type":48,"tag":3149,"props":3150,"children":3151},"table",{},[3152,3176],{"type":48,"tag":3153,"props":3154,"children":3155},"thead",{},[3156],{"type":48,"tag":3157,"props":3158,"children":3159},"tr",{},[3160,3166,3171],{"type":48,"tag":3161,"props":3162,"children":3163},"th",{},[3164],{"type":53,"value":3165},"Issue",{"type":48,"tag":3161,"props":3167,"children":3168},{},[3169],{"type":53,"value":3170},"Likely Cause",{"type":48,"tag":3161,"props":3172,"children":3173},{},[3174],{"type":53,"value":3175},"Fix",{"type":48,"tag":3177,"props":3178,"children":3179},"tbody",{},[3180,3208,3234,3261,3297,3325,3346],{"type":48,"tag":3157,"props":3181,"children":3182},{},[3183,3192,3197],{"type":48,"tag":3184,"props":3185,"children":3186},"td",{},[3187],{"type":48,"tag":74,"props":3188,"children":3189},{},[3190],{"type":53,"value":3191},"SHOW STATISTICS returns empty",{"type":48,"tag":3184,"props":3193,"children":3194},{},[3195],{"type":53,"value":3196},"No statistics ever collected",{"type":48,"tag":3184,"props":3198,"children":3199},{},[3200,3202],{"type":53,"value":3201},"Run ",{"type":48,"tag":62,"props":3203,"children":3205},{"className":3204},[],[3206],{"type":53,"value":3207},"CREATE STATISTICS __auto__ FROM table_name;",{"type":48,"tag":3157,"props":3209,"children":3210},{},[3211,3219,3224],{"type":48,"tag":3184,"props":3212,"children":3213},{},[3214],{"type":48,"tag":74,"props":3215,"children":3216},{},[3217],{"type":53,"value":3218},"row_count shows 0 for non-empty table",{"type":48,"tag":3184,"props":3220,"children":3221},{},[3222],{"type":53,"value":3223},"Statistics out of sync",{"type":48,"tag":3184,"props":3225,"children":3226},{},[3227,3229],{"type":53,"value":3228},"Refresh: ",{"type":48,"tag":62,"props":3230,"children":3232},{"className":3231},[],[3233],{"type":53,"value":3207},{"type":48,"tag":3157,"props":3235,"children":3236},{},[3237,3245,3250],{"type":48,"tag":3184,"props":3238,"children":3239},{},[3240],{"type":48,"tag":74,"props":3241,"children":3242},{},[3243],{"type":53,"value":3244},"Permission denied error",{"type":48,"tag":3184,"props":3246,"children":3247},{},[3248],{"type":53,"value":3249},"No privileges on table",{"type":48,"tag":3184,"props":3251,"children":3252},{},[3253,3255],{"type":53,"value":3254},"Grant any privilege: ",{"type":48,"tag":62,"props":3256,"children":3258},{"className":3257},[],[3259],{"type":53,"value":3260},"GRANT SELECT ON table_name TO user;",{"type":48,"tag":3157,"props":3262,"children":3263},{},[3264,3272,3277],{"type":48,"tag":3184,"props":3265,"children":3266},{},[3267],{"type":48,"tag":74,"props":3268,"children":3269},{},[3270],{"type":53,"value":3271},"CREATE STATISTICS job stuck",{"type":48,"tag":3184,"props":3273,"children":3274},{},[3275],{"type":53,"value":3276},"Large table with high write volume",{"type":48,"tag":3184,"props":3278,"children":3279},{},[3280,3282,3287,3289,3295],{"type":53,"value":3281},"Check ",{"type":48,"tag":62,"props":3283,"children":3285},{"className":3284},[],[3286],{"type":53,"value":2758},{"type":53,"value":3288}," status; consider ",{"type":48,"tag":62,"props":3290,"children":3292},{"className":3291},[],[3293],{"type":53,"value":3294},"CANCEL JOB",{"type":53,"value":3296}," and retry during low-traffic period",{"type":48,"tag":3157,"props":3298,"children":3299},{},[3300,3308,3313],{"type":48,"tag":3184,"props":3301,"children":3302},{},[3303],{"type":48,"tag":74,"props":3304,"children":3305},{},[3306],{"type":53,"value":3307},"Automatic collection not triggering",{"type":48,"tag":3184,"props":3309,"children":3310},{},[3311],{"type":53,"value":3312},"Setting disabled or threshold not met",{"type":48,"tag":3184,"props":3314,"children":3315},{},[3316,3318,3323],{"type":53,"value":3317},"Verify ",{"type":48,"tag":62,"props":3319,"children":3321},{"className":3320},[],[3322],{"type":53,"value":117},{"type":53,"value":3324}," and check row count drift",{"type":48,"tag":3157,"props":3326,"children":3327},{},[3328,3336,3341],{"type":48,"tag":3184,"props":3329,"children":3330},{},[3331],{"type":48,"tag":74,"props":3332,"children":3333},{},[3334],{"type":53,"value":3335},"Statistics exist but query plans still poor",{"type":48,"tag":3184,"props":3337,"children":3338},{},[3339],{"type":53,"value":3340},"Stale statistics or missing multi-column stats",{"type":48,"tag":3184,"props":3342,"children":3343},{},[3344],{"type":53,"value":3345},"Refresh existing; create multi-column for correlated columns (see Query 6)",{"type":48,"tag":3157,"props":3347,"children":3348},{},[3349,3357,3362],{"type":48,"tag":3184,"props":3350,"children":3351},{},[3352],{"type":48,"tag":74,"props":3353,"children":3354},{},[3355],{"type":53,"value":3356},"High drift but recent created timestamp",{"type":48,"tag":3184,"props":3358,"children":3359},{},[3360],{"type":53,"value":3361},"Extreme write volume between collections",{"type":48,"tag":3184,"props":3363,"children":3364},{},[3365],{"type":53,"value":3366},"Lower automatic collection threshold or increase manual refresh frequency",{"type":48,"tag":220,"props":3368,"children":3370},{"id":3369},"defensive-query-patterns",[3371],{"type":53,"value":3372},"Defensive Query Patterns",{"type":48,"tag":56,"props":3374,"children":3375},{},[3376],{"type":48,"tag":74,"props":3377,"children":3378},{},[3379],{"type":53,"value":3380},"Handle missing statistics:",{"type":48,"tag":232,"props":3382,"children":3384},{"className":234,"code":3383,"language":236,"meta":237,"style":237},"-- Use COALESCE for NULL created timestamps\nSELECT COALESCE(created, '1970-01-01'::TIMESTAMP) AS stats_created_at\nFROM [SHOW STATISTICS FOR TABLE table_name]\nWHERE column_names = '{}';\n",[3385],{"type":48,"tag":62,"props":3386,"children":3387},{"__ignoreMap":237},[3388,3396,3404,3412],{"type":48,"tag":243,"props":3389,"children":3390},{"class":245,"line":246},[3391],{"type":48,"tag":243,"props":3392,"children":3393},{},[3394],{"type":53,"value":3395},"-- Use COALESCE for NULL created timestamps\n",{"type":48,"tag":243,"props":3397,"children":3398},{"class":245,"line":29},[3399],{"type":48,"tag":243,"props":3400,"children":3401},{},[3402],{"type":53,"value":3403},"SELECT COALESCE(created, '1970-01-01'::TIMESTAMP) AS stats_created_at\n",{"type":48,"tag":243,"props":3405,"children":3406},{"class":245,"line":25},[3407],{"type":48,"tag":243,"props":3408,"children":3409},{},[3410],{"type":53,"value":3411},"FROM [SHOW STATISTICS FOR TABLE table_name]\n",{"type":48,"tag":243,"props":3413,"children":3414},{"class":245,"line":271},[3415],{"type":48,"tag":243,"props":3416,"children":3417},{},[3418],{"type":53,"value":3419},"WHERE column_names = '{}';\n",{"type":48,"tag":56,"props":3421,"children":3422},{},[3423],{"type":48,"tag":74,"props":3424,"children":3425},{},[3426],{"type":53,"value":3427},"Avoid division by zero in drift calculations:",{"type":48,"tag":232,"props":3429,"children":3431},{"className":234,"code":3430,"language":236,"meta":237,"style":237},"-- Use NULLIF to prevent divide-by-zero errors\nSELECT\n  ABS(actual - stats)::NUMERIC \u002F NULLIF(stats, 0) * 100 AS drift_pct\nFROM ...;\n",[3432],{"type":48,"tag":62,"props":3433,"children":3434},{"__ignoreMap":237},[3435,3443,3450,3458],{"type":48,"tag":243,"props":3436,"children":3437},{"class":245,"line":246},[3438],{"type":48,"tag":243,"props":3439,"children":3440},{},[3441],{"type":53,"value":3442},"-- Use NULLIF to prevent divide-by-zero errors\n",{"type":48,"tag":243,"props":3444,"children":3445},{"class":245,"line":29},[3446],{"type":48,"tag":243,"props":3447,"children":3448},{},[3449],{"type":53,"value":358},{"type":48,"tag":243,"props":3451,"children":3452},{"class":245,"line":25},[3453],{"type":48,"tag":243,"props":3454,"children":3455},{},[3456],{"type":53,"value":3457},"  ABS(actual - stats)::NUMERIC \u002F NULLIF(stats, 0) * 100 AS drift_pct\n",{"type":48,"tag":243,"props":3459,"children":3460},{"class":245,"line":271},[3461],{"type":48,"tag":243,"props":3462,"children":3463},{},[3464],{"type":53,"value":3465},"FROM ...;\n",{"type":48,"tag":91,"props":3467,"children":3469},{"id":3468},"key-considerations",[3470],{"type":53,"value":3471},"Key Considerations",{"type":48,"tag":98,"props":3473,"children":3474},{},[3475,3492,3516,3538,3548],{"type":48,"tag":102,"props":3476,"children":3477},{},[3478,3483,3485,3490],{"type":48,"tag":74,"props":3479,"children":3480},{},[3481],{"type":53,"value":3482},"Auto vs manual:",{"type":53,"value":3484}," Keep automatic collection enabled for baseline; use manual ",{"type":48,"tag":62,"props":3486,"children":3488},{"className":3487},[],[3489],{"type":53,"value":190},{"type":53,"value":3491}," for ad-hoc post-bulk-load refresh and critical tables",{"type":48,"tag":102,"props":3493,"children":3494},{},[3495,3500,3502,3507,3509,3515],{"type":48,"tag":74,"props":3496,"children":3497},{},[3498],{"type":53,"value":3499},"Multi-column statistics:",{"type":53,"value":3501}," Auto-collection covers index column groups; manual ",{"type":48,"tag":62,"props":3503,"children":3505},{"className":3504},[],[3506],{"type":53,"value":190},{"type":53,"value":3508}," is needed for correlated non-indexed columns queried together (e.g., ",{"type":48,"tag":62,"props":3510,"children":3512},{"className":3511},[],[3513],{"type":53,"value":3514},"CREATE STATISTICS city_state_stats ON city, state FROM addresses;",{"type":53,"value":171},{"type":48,"tag":102,"props":3517,"children":3518},{},[3519,3523,3525,3530,3532],{"type":48,"tag":74,"props":3520,"children":3521},{},[3522],{"type":53,"value":2732},{"type":53,"value":3524}," Schedule ",{"type":48,"tag":62,"props":3526,"children":3528},{"className":3527},[],[3529],{"type":53,"value":190},{"type":53,"value":3531}," during maintenance windows; monitor with ",{"type":48,"tag":62,"props":3533,"children":3535},{"className":3534},[],[3536],{"type":53,"value":3537},"SHOW JOBS WHERE job_type = 'CREATE STATS'",{"type":48,"tag":102,"props":3539,"children":3540},{},[3541,3546],{"type":48,"tag":74,"props":3542,"children":3543},{},[3544],{"type":53,"value":3545},"Staleness tuning:",{"type":53,"value":3547}," OLTP: 3-7 days, OLAP: 14-30 days, hybrid: critical tables 3-7 days, archive 30+ days",{"type":48,"tag":102,"props":3549,"children":3550},{},[3551,3556],{"type":48,"tag":74,"props":3552,"children":3553},{},[3554],{"type":53,"value":3555},"Privilege:",{"type":53,"value":3557}," Any table privilege (SELECT, INSERT, etc.) grants statistics visibility",{"type":48,"tag":56,"props":3559,"children":3560},{},[3561,3562,3566,3568,3572],{"type":53,"value":205},{"type":48,"tag":82,"props":3563,"children":3564},{"href":1801},[3565],{"type":53,"value":1801},{"type":53,"value":3567}," and ",{"type":48,"tag":82,"props":3569,"children":3570},{"href":208},[3571],{"type":53,"value":208},{"type":53,"value":3573}," for detailed guidance.",{"type":48,"tag":91,"props":3575,"children":3577},{"id":3576},"references",[3578],{"type":53,"value":3579},"References",{"type":48,"tag":56,"props":3581,"children":3582},{},[3583],{"type":48,"tag":74,"props":3584,"children":3585},{},[3586],{"type":53,"value":3587},"Official CockroachDB Documentation:",{"type":48,"tag":98,"props":3589,"children":3590},{},[3591,3603,3614,3626,3638],{"type":48,"tag":102,"props":3592,"children":3593},{},[3594,3601],{"type":48,"tag":82,"props":3595,"children":3599},{"href":3596,"rel":3597},"https:\u002F\u002Fwww.cockroachlabs.com\u002Fdocs\u002Fstable\u002Fshow-statistics.html",[3598],"nofollow",[3600],{"type":53,"value":67},{"type":53,"value":3602}," - Complete syntax and output schema",{"type":48,"tag":102,"props":3604,"children":3605},{},[3606,3612],{"type":48,"tag":82,"props":3607,"children":3610},{"href":3608,"rel":3609},"https:\u002F\u002Fwww.cockroachlabs.com\u002Fdocs\u002Fstable\u002Fcreate-statistics.html",[3598],[3611],{"type":53,"value":190},{"type":53,"value":3613}," - Manual statistics collection guide",{"type":48,"tag":102,"props":3615,"children":3616},{},[3617,3624],{"type":48,"tag":82,"props":3618,"children":3621},{"href":3619,"rel":3620},"https:\u002F\u002Fwww.cockroachlabs.com\u002Fdocs\u002Fstable\u002Fcost-based-optimizer.html",[3598],[3622],{"type":53,"value":3623},"Cost-Based Optimizer",{"type":53,"value":3625}," - How optimizer uses statistics",{"type":48,"tag":102,"props":3627,"children":3628},{},[3629,3636],{"type":48,"tag":82,"props":3630,"children":3633},{"href":3631,"rel":3632},"https:\u002F\u002Fwww.cockroachlabs.com\u002Fdocs\u002Fstable\u002Fcost-based-optimizer.html#table-statistics",[3598],[3634],{"type":53,"value":3635},"Table Statistics",{"type":53,"value":3637}," - Statistics impact on query planning",{"type":48,"tag":102,"props":3639,"children":3640},{},[3641,3647],{"type":48,"tag":82,"props":3642,"children":3645},{"href":3643,"rel":3644},"https:\u002F\u002Fwww.cockroachlabs.com\u002Fdocs\u002Fstable\u002Fshow-jobs.html",[3598],[3646],{"type":53,"value":2758},{"type":53,"value":3648}," - Job monitoring and management",{"type":48,"tag":56,"props":3650,"children":3651},{},[3652],{"type":48,"tag":74,"props":3653,"children":3654},{},[3655],{"type":53,"value":3656},"Related Skills:",{"type":48,"tag":98,"props":3658,"children":3659},{},[3660,3669],{"type":48,"tag":102,"props":3661,"children":3662},{},[3663,3667],{"type":48,"tag":82,"props":3664,"children":3665},{"href":84},[3666],{"type":53,"value":87},{"type":53,"value":3668}," - Identify slow query patterns",{"type":48,"tag":102,"props":3670,"children":3671},{},[3672,3676],{"type":48,"tag":82,"props":3673,"children":3674},{"href":136},[3675],{"type":53,"value":139},{"type":53,"value":3677}," - Real-time query triage",{"type":48,"tag":56,"props":3679,"children":3680},{},[3681],{"type":48,"tag":74,"props":3682,"children":3683},{},[3684],{"type":53,"value":3685},"Supplementary References:",{"type":48,"tag":98,"props":3687,"children":3688},{},[3689,3699],{"type":48,"tag":102,"props":3690,"children":3691},{},[3692,3697],{"type":48,"tag":82,"props":3693,"children":3694},{"href":208},[3695],{"type":53,"value":3696},"Statistics Thresholds Guide",{"type":53,"value":3698}," - Workload-specific staleness and drift thresholds",{"type":48,"tag":102,"props":3700,"children":3701},{},[3702,3707],{"type":48,"tag":82,"props":3703,"children":3704},{"href":1801},[3705],{"type":53,"value":3706},"CREATE STATISTICS Examples",{"type":53,"value":3708}," - Comprehensive collection patterns and batch strategies",{"type":48,"tag":3710,"props":3711,"children":3712},"style",{},[3713],{"type":53,"value":3714},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":3716,"total":3869},[3717,3736,3752,3767,3778,3788,3801,3811,3825,3838,3849,3856],{"slug":3718,"name":3718,"fn":3719,"description":3720,"org":3721,"tags":3722,"stars":3733,"repoUrl":3734,"updatedAt":3735},"collecting-cockroachdb-operator-escalation-packet","collect CockroachDB operator escalation packets","Collects a complete CockroachDB Operator escalation packet for TSC\u002FTSE or operator-team handoff, including Helm state, Kubernetes resources, logs, operation-specific evidence, pprof goroutine dumps, metrics, and a customer action timeline. Use when general diagnosis cannot resolve an operator-managed CockroachDB Helm issue or before restarting a stuck operator.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3723,3724,3727,3730],{"name":23,"slug":24,"type":15},{"name":3725,"slug":3726,"type":15},"Incident Response","incident-response",{"name":3728,"slug":3729,"type":15},"Kubernetes","kubernetes",{"name":3731,"slug":3732,"type":15},"Monitoring","monitoring",105,"https:\u002F\u002Fgithub.com\u002Fcockroachdb\u002Fhelm-charts","2026-07-12T07:57:25.288146",{"slug":3737,"name":3737,"fn":3738,"description":3739,"org":3740,"tags":3741,"stars":3733,"repoUrl":3734,"updatedAt":3751},"configuring-cockroachdb-helm-tls","configure TLS for CockroachDB Helm charts","Selects and validates TLS settings for CockroachDB Helm chart deployments, including self-signer, cert-manager, and external certificate modes. Use when a customer needs secure CockroachDB Helm values, certificate secret mapping, cert-manager integration, or TLS install troubleshooting before deploying the chart.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3742,3745,3748],{"name":3743,"slug":3744,"type":15},"Deployment","deployment",{"name":3746,"slug":3747,"type":15},"Encryption","encryption",{"name":3749,"slug":3750,"type":15},"Security","security","2026-07-12T07:56:37.675396",{"slug":3753,"name":3753,"fn":3754,"description":3755,"org":3756,"tags":3757,"stars":3733,"repoUrl":3734,"updatedAt":3766},"debugging-cockroachdb-operator-migrations","debug CockroachDB Operator migration scenarios","Debugs CockroachDB Operator migration scenarios, including Helm StatefulSet to v1beta1 CrdbNode migration and public operator v1alpha1 to v1beta1 migration. Use when migration labels, migration phases, source StatefulSet ownership, converted CRDs, PVC ownership, or post-migration reconciliation are unclear or stuck.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3758,3759,3762,3763],{"name":23,"slug":24,"type":15},{"name":3760,"slug":3761,"type":15},"Debugging","debugging",{"name":3728,"slug":3729,"type":15},{"name":3764,"slug":3765,"type":15},"Migration","migration","2026-07-12T07:56:48.360871",{"slug":3768,"name":3768,"fn":3769,"description":3770,"org":3771,"tags":3772,"stars":3733,"repoUrl":3734,"updatedAt":3777},"diagnosing-cockroachdb-helm-deployments","diagnose CockroachDB Helm chart deployments","Diagnoses failed or unhealthy CockroachDB Helm chart deployments by checking Helm release state, operator health, CrdbCluster and CrdbNode status, pod readiness, RBAC, webhooks, TLS, upgrades, scaling, PVCs, DNS, and multi-region assumptions. Use when Helm install or upgrade fails, pods are not Ready, or the operator is not reconciling.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3773,3774,3775,3776],{"name":23,"slug":24,"type":15},{"name":3760,"slug":3761,"type":15},{"name":3743,"slug":3744,"type":15},{"name":3728,"slug":3729,"type":15},"2026-07-12T07:57:24.018818",{"slug":3779,"name":3779,"fn":3780,"description":3781,"org":3782,"tags":3783,"stars":3733,"repoUrl":3734,"updatedAt":3787},"installing-cockroachdb-with-helm","install CockroachDB using Helm","Guides customer-facing installation of CockroachDB on Kubernetes using the CockroachDB split Helm charts and operator-managed v1beta1 resources. Use when installing CockroachDB with Helm, choosing between published and local split charts, verifying a new install, or helping an agent complete first-time Kubernetes onboarding.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3784,3785,3786],{"name":23,"slug":24,"type":15},{"name":3743,"slug":3744,"type":15},{"name":3728,"slug":3729,"type":15},"2026-07-12T07:56:45.777567",{"slug":3789,"name":3789,"fn":3790,"description":3791,"org":3792,"tags":3793,"stars":3733,"repoUrl":3734,"updatedAt":3800},"validating-cockroachdb-helm-multiregion","validate CockroachDB multi-region Helm deployments","Validates CockroachDB Helm chart values and Kubernetes prerequisites for operator-managed multi-region deployments. Use before adding a region, deploying CockroachDB across multiple Kubernetes clusters, checking region DNS domains, or confirming that all regions share certificate and networking assumptions.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3794,3795,3796,3797],{"name":23,"slug":24,"type":15},{"name":3743,"slug":3744,"type":15},{"name":3728,"slug":3729,"type":15},{"name":3798,"slug":3799,"type":15},"Operations","operations","2026-07-12T07:56:47.082609",{"slug":3802,"name":3802,"fn":3803,"description":3804,"org":3805,"tags":3806,"stars":25,"repoUrl":26,"updatedAt":3810},"analyzing-range-distribution","analyze CockroachDB range distribution and health","Analyzes CockroachDB range distribution across tables and indexes using SHOW RANGES to identify range count, size patterns, leaseholder placement, and replication health. Use when investigating hotspots, uneven data distribution, range fragmentation, or validating zone configuration effects without DB Console access.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3807,3808,3809],{"name":23,"slug":24,"type":15},{"name":3731,"slug":3732,"type":15},{"name":13,"slug":14,"type":15},"2026-07-12T07:57:18.753533",{"slug":3812,"name":3812,"fn":3813,"description":3814,"org":3815,"tags":3816,"stars":25,"repoUrl":26,"updatedAt":3824},"analyzing-schema-change-storage-risk","analyze schema change storage requirements","Estimates storage requirements for CockroachDB online schema change backfills using SHOW RANGES WITH DETAILS, KEYS, INDEXES. Use before CREATE INDEX, ADD COLUMN with INDEX\u002FUNIQUE, ALTER PRIMARY KEY, CREATE MATERIALIZED VIEW, CREATE TABLE AS, REFRESH, or SET LOCALITY on tables with large per-index footprints, to avoid mid-backfill disk exhaustion.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3817,3820,3821,3822],{"name":3818,"slug":3819,"type":15},"Data Modeling","data-modeling",{"name":23,"slug":24,"type":15},{"name":13,"slug":14,"type":15},{"name":3823,"slug":236,"type":15},"SQL","2026-07-12T07:57:22.763788",{"slug":3826,"name":3826,"fn":3827,"description":3828,"org":3829,"tags":3830,"stars":25,"repoUrl":26,"updatedAt":3837},"auditing-cis-benchmark","audit CockroachDB clusters against CIS benchmarks","Audits a self-hosted CockroachDB cluster against the CIS CockroachDB Benchmark v1.0.0 Level 1 controls. Supports two audit depths — quick automated scans and full CIS audit procedures. Produces a structured PASS\u002FFAIL\u002FMANUAL report covering installation, system hardening, logging, user access, data protection, and CockroachDB settings. Use when preparing for CIS compliance assessments, hardening self-hosted deployments, or validating security posture against industry benchmarks.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3831,3832,3835,3836],{"name":17,"slug":18,"type":15},{"name":3833,"slug":3834,"type":15},"Compliance","compliance",{"name":23,"slug":24,"type":15},{"name":3749,"slug":3750,"type":15},"2026-07-18T05:48:00.862384",{"slug":3839,"name":3839,"fn":3840,"description":3841,"org":3842,"tags":3843,"stars":25,"repoUrl":26,"updatedAt":3848},"auditing-cloud-cluster-security","audit CockroachDB cluster security posture","Audits the security posture of a CockroachDB cluster (Cloud or self-hosted) across network, authentication, authorization, encryption, audit logging, and backup dimensions. Use when assessing cluster security readiness, preparing for compliance reviews, or investigating security configuration gaps.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3844,3845,3846,3847],{"name":17,"slug":18,"type":15},{"name":23,"slug":24,"type":15},{"name":3798,"slug":3799,"type":15},{"name":3749,"slug":3750,"type":15},"2026-07-12T07:57:01.506735",{"slug":4,"name":4,"fn":5,"description":6,"org":3850,"tags":3851,"stars":25,"repoUrl":26,"updatedAt":27},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3852,3853,3854,3855],{"name":17,"slug":18,"type":15},{"name":20,"slug":21,"type":15},{"name":23,"slug":24,"type":15},{"name":13,"slug":14,"type":15},{"slug":3857,"name":3857,"fn":3858,"description":3859,"org":3860,"tags":3861,"stars":25,"repoUrl":26,"updatedAt":3868},"benchmarking-transaction-patterns","benchmark CockroachDB transaction patterns","Guides benchmarking and comparing explicit multi-statement transactions versus single-statement CTE transactions in CockroachDB, with fair test methodology, contention analysis, and performance interpretation. Use when comparing transaction formulations, benchmarking CockroachDB workloads under contention, investigating retry pressure, or deciding whether to rewrite multi-step application flows into single SQL statements.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3862,3863,3866,3867],{"name":23,"slug":24,"type":15},{"name":3864,"slug":3865,"type":15},"Engineering","engineering",{"name":13,"slug":14,"type":15},{"name":3823,"slug":236,"type":15},"2026-07-12T07:57:26.543278",40,{"items":3871,"total":3923},[3872,3878,3885,3892,3899,3906,3913],{"slug":3802,"name":3802,"fn":3803,"description":3804,"org":3873,"tags":3874,"stars":25,"repoUrl":26,"updatedAt":3810},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3875,3876,3877],{"name":23,"slug":24,"type":15},{"name":3731,"slug":3732,"type":15},{"name":13,"slug":14,"type":15},{"slug":3812,"name":3812,"fn":3813,"description":3814,"org":3879,"tags":3880,"stars":25,"repoUrl":26,"updatedAt":3824},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3881,3882,3883,3884],{"name":3818,"slug":3819,"type":15},{"name":23,"slug":24,"type":15},{"name":13,"slug":14,"type":15},{"name":3823,"slug":236,"type":15},{"slug":3826,"name":3826,"fn":3827,"description":3828,"org":3886,"tags":3887,"stars":25,"repoUrl":26,"updatedAt":3837},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3888,3889,3890,3891],{"name":17,"slug":18,"type":15},{"name":3833,"slug":3834,"type":15},{"name":23,"slug":24,"type":15},{"name":3749,"slug":3750,"type":15},{"slug":3839,"name":3839,"fn":3840,"description":3841,"org":3893,"tags":3894,"stars":25,"repoUrl":26,"updatedAt":3848},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3895,3896,3897,3898],{"name":17,"slug":18,"type":15},{"name":23,"slug":24,"type":15},{"name":3798,"slug":3799,"type":15},{"name":3749,"slug":3750,"type":15},{"slug":4,"name":4,"fn":5,"description":6,"org":3900,"tags":3901,"stars":25,"repoUrl":26,"updatedAt":27},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3902,3903,3904,3905],{"name":17,"slug":18,"type":15},{"name":20,"slug":21,"type":15},{"name":23,"slug":24,"type":15},{"name":13,"slug":14,"type":15},{"slug":3857,"name":3857,"fn":3858,"description":3859,"org":3907,"tags":3908,"stars":25,"repoUrl":26,"updatedAt":3868},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3909,3910,3911,3912],{"name":23,"slug":24,"type":15},{"name":3864,"slug":3865,"type":15},{"name":13,"slug":14,"type":15},{"name":3823,"slug":236,"type":15},{"slug":3914,"name":3914,"fn":3915,"description":3916,"org":3917,"tags":3918,"stars":25,"repoUrl":26,"updatedAt":3922},"cockroachdb-sql","write and optimize CockroachDB SQL","Use when writing, generating, or optimizing SQL for CockroachDB, designing CockroachDB schemas, or when the user asks about CockroachDB-specific SQL patterns, type mappings, and distributed database best practices. Also use when encountering CockroachDB anti-patterns like missing primary keys, sequential ID hotspots, or incorrect type usage.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[3919,3920,3921],{"name":23,"slug":24,"type":15},{"name":13,"slug":14,"type":15},{"name":3823,"slug":236,"type":15},"2026-07-25T05:31:22.562808",34]