analyzing-range-distribution

Analyzes CockroachDB range distribution, leaseholder placement, and replication health using SHOW RANGES SQL queries.

2|1|Updated Mar 11, 2026
One-click install
npx skills add https://github.com/cockroachdb/cursor-plugin --skill analyzing-range-distribution-cockroachdb
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: analyzing-range-distribution
Source: https://github.com/cockroachdb/cursor-plugin/tree/main/skills/cockroachdb-observability-and-diagnostics/analyzing-range-distribution
Command: npx skills add https://github.com/cockroachdb/cursor-plugin --skill analyzing-range-distribution-cockroachdb

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Diagnosing hotspots, uneven data distribution, and range fragmentation in CockroachDB normally requires DB Console access, which is not always available. This Skill provides SQL-only diagnostics using SHOW RANGES and SHOW ZONE CONFIGURATIONS to identify range count anomalies, leaseholder concentration, and replication issues directly from a SQL connection. ## Core Features & Use Cases - Range Distribution Analysis: Count ranges per table and index, measure range sizes, and calculate ranges-per-GB fragmentation metrics. - Hotspot Detection: Identify leaseholder concentration on single nodes and validate zone configuration placement against actual replica distribution. - Replication Health Checks: Detect under-replicated or over-replicated ranges that signal node failures or zone config mismatches. - Production-Safe Guardrails: Built-in safety tiers distinguish metadata-only queries from expensive WITH DETAILS queries, with mandatory LIMIT guidance. - Use Case: A DBA notices high CPU on one node and slow reads on the orders table. Using this Skill, they run a leaseholder distribution query, discover 80% of leaseholders sit on node 1, then apply lease_preferences zone config to spread the load. ## Quick Start Ask the AI to analyze the range distribution and leaseholder placement for a specific CockroachDB table to check for hotspots or fragmentation.

Frequently Asked Questions about analyzing-range-distribution

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

FAQPage Schema
How do I check range distribution in CockroachDB without DB Console?▼

Use SHOW RANGES FROM TABLE followed by your table name to list range counts, boundaries, and leaseholders via SQL. Grouping by lease_holder reveals distribution across nodes, and adding WITH DETAILS exposes range sizes, though DETAILS requires a LIMIT clause for safety.

How to detect leaseholder hotspots in CockroachDB?▼

Run SELECT lease_holder, COUNT(*) FROM [SHOW RANGES FROM TABLE your_table] GROUP BY lease_holder to compute per-node percentages. A single node holding over 40% of leaseholders in a balanced cluster indicates a hotspot, fixable with lease_preferences zone configs.

What privileges are needed for SHOW RANGES in CockroachDB?▼

SHOW RANGES requires the admin role or the ZONECONFIG system privilege. Granting ZONECONFIG via GRANT SYSTEM ZONECONFIG TO user is the recommended least-privilege approach for read-only range analysis without write access.

Is SHOW RANGES WITH DETAILS safe to run in production?▼

WITH DETAILS computes span statistics on-demand, causing high CPU and memory usage proportional to range count. It is safe only when targeted at a specific table with a LIMIT of 50-100 during low-traffic windows; never run it cluster-wide without LIMIT.

Why does my CockroachDB table have so many small ranges?▼

Excessive small ranges indicate fragmentation from load-based splitting during high write throughput or sequential inserts. Calculate ranges per GB to assess severity: 1-15 is healthy, while 50+ suggests severe fragmentation that may warrant tuning range_max_bytes.

How do I find under-replicated ranges in CockroachDB?▼

Query SHOW RANGES and filter where array_length(replicas, 1) is less than your replication factor, typically 3. Under-replicated ranges signal node failures, decommissioning operations, or zone config constraint mismatches requiring investigation.