profiling-statement-fingerprints

Analyzes historical statement fingerprints in CockroachDB using crdb_internal.statement_statistics to identify slow queries.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Diagnosing recurring database slowness and resource-heavy queries is difficult without DB Console access, especially when you need historical trends rather than a snapshot of currently running queries. ## Core Features & Use Cases - Historical Query Profiling: Ranks statement fingerprints by latency, CPU, contention, admission wait, memory, and failure rate using aggregated SQL statistics. - Optimization Discovery: Surfaces full table scans, index recommendations, and plan hash instability directly from SQL. - Use Case: After users report intermittent slowness overnight, run the top-latency query over a 24-hour window to find the slowest fingerprints, check for full scans, and review generated index recommendations. ## Quick Start Ask the AI to find the slowest statement fingerprints in my CockroachDB cluster over the past 24 hours and show any index recommendations.

Frequently Asked Questions about profiling-statement-fingerprints

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

FAQPage Schema
How do I find the slowest queries in CockroachDB without DB Console?▼

Query crdb_internal.statement_statistics filtered by a time window and ordered by the runLat mean extracted from the statistics JSONB column. This returns the slowest statement fingerprints with execution counts, full scan flags, and index recommendations.

What is a statement fingerprint in CockroachDB?▼

A statement fingerprint is a normalized SQL pattern with parameterized constants, so queries like SELECT with different literal values aggregate into one fingerprint. Statistics are collected per fingerprint in hourly aggregated_ts buckets.

What privileges are needed to query crdb_internal.statement_statistics?▼

You need the VIEWACTIVITY or VIEWACTIVITYREDACTED cluster privilege for cluster-wide visibility. VIEWACTIVITYREDACTED hides query constants, which is recommended for multi-tenant production environments.

Why are CPU and contention metrics sometimes NULL in statement statistics?▼

CPU, contention, memory, and admission metrics live in execution_statistics, which is probabilistically sampled rather than collected for every execution. Filter with WHERE (statistics->'execution_statistics'->>'cnt') IS NOT NULL to exclude unsampled buckets.

How long is statement statistics data retained in CockroachDB?▼

Retention is bounded by row count via the sql.stats.persisted_rows.max cluster setting (default 1,000,000 rows), not by a fixed TTL. The effective time window depends on workload diversity, so always filter by aggregated_ts.

When should I use live query triage instead of statement fingerprint analysis?▼

Use live triage of currently running queries for immediate incident response, such as canceling runaway queries. Statement fingerprint analysis is for historical patterns, trends, and optimization opportunities over hours or days.