Xpersona
S

Sql Optimization

CLAWHUB · Unverified

Deep SQL performance workflow—symptom framing, execution plans, indexing strategy, query rewrite, locking/transaction behavior, statistics, partitioning, and... Skill: Sql Optimization Owner: codekungfu Summary: Deep SQL performance workflow—symptom framing, execution plans, indexing strategy, query rewrite, locking/transaction behavior, statistics, partitioning, and... Tags: latest:1.0.0 Version history: v1.0.0 | 2026-03-24T15:36:25.889Z | auto - Initial release of the SQL Optimization workflow skill. - Provides a structured six-stage process for diagnosing and solving SQL

62
Rank
84
Safety
1.1k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s174hbct7jzfnq4tb6w04gnans83gh5h:sql-optimization
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-codekungfu-sql-optimization/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

8,303 characters of source documentation, loaded on request.

Extracted files

3 files captured from the source.

SKILL.md

---
name: sql-optimization
description: Deep SQL performance workflow—symptom framing, execution plans, indexing strategy, query rewrite, locking/transaction behavior, statistics, partitioning, and verification. Use when queries time out, DB CPU spikes, or migrations change access patterns.
---

# SQL Optimization (Deep Workflow)

Optimization without measurement is guesswork. Structure the work as **observe → explain (plan) → change → verify**, with explicit attention to **correctness**, **locks**, and **write amplification** from indexes.

## When to Offer This Workflow

**Trigger conditions:**

- Slow queries, growing P95/P99, replication lag, lock waits
- ORM-generated SQL surprises; N+1 at DB layer
- Index explosion, bloat, or “we added indexes everywhere”

**Initial offer:**

Use **six stages**: (1) frame the problem, (2) reproduce & measure, (3) read execution plans, (4) schema & indexes, (5) query & transaction tuning, (6) verify & guardrail. Confirm **engine** (PostgreSQL, MySQL, SQL Server, etc.) and **environment** (prod-like data volume).

---

## Stage 1: Frame the Problem

**Goal:** Define **SLO**, **scope**, and **non-goals**.

### Questions

1. Which **queries** or **endpoints** are slow? User-facing vs batch?
2. **Regression**—did deploy, data volume, or stats change?
3. **Isolation level** and **consistency** requirements—can we read replicas?
4. **Write risk**: is this table write-heavy? Index cost?

**Exit condition:** One-line **problem statement** with metric (e.g., “p95 2.4s on `/reports` at 10k RPS”).

---

## Stage 2: Reproduce & Measure

**Goal:** **Stable repro** with representative **cardinality** and **parameters**.

### Actions

- Capture **exact SQL**, parameters, and **frequency**
- Use **EXPLAIN (ANALYZE, BUFFERS)** or equivalent—engine-specific
- Check **buffer cache** effects: cold vs warm cache; run twice when needed
- Compare **prod stats** vs staging—row counts, histograms

### Pitfalls

- Optimizing on empty dev DB
- Different **parameter sniffing** values changing plan choice

**Exit condition:** Baseline numbers + **plan hash** or saved plan for A/B.

---

## Stage 3: Read Execution Plans

**Goal:** Name the **dominant cost**: seq scan, bad join order, sort, hash spill, nested loop explosion.

### Interpret (adapt to engine)

- **Seq scan** on large tables—filter selectivity? missing index? stats?
- **Index scan** vs **bitmap** vs **index only**—covering indexes trade-offs
- **Joins**: wrong order, missing stats, outdated NDV
- **Sort/hash** spills to disk—work_mem / memory grants
- **Locks**: `FOR UPDATE`, long transactions, hot row updates

**Exit condition:** Hypothesis tied to **plan node(s)**, not generic “add index.”

---

## Stage 4: Schema & Indexes

**Goal:** **Right indexes** for read paths without destroying writes.

### Strategy

- **Composite index column order**: equality → range; avoid redundant indexes
- **Partial indexes** for hot subsets
- **Covering** indexes vs table bloat—measure write

_meta.json

{
  "ownerId": "kn79jhw85bss2z4dbpshhxg64x82zn3p",
  "slug": "sql-optimization",
  "version": "1.0.0",
  "publishedAt": 1774366585889
}

skill-card.md

## Description:

Deep SQL performance workflow for symptom framing, execution-plan analysis, indexing strategy, query rewrites, locking and transaction behavior, statistics, partitioning, and verification.

This skill is ready for commercial/non-commercial use.

## Publisher:

[codekungfu](https://clawhub.ai/user/codekungfu)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and database engineers use this skill to diagnose and improve SQL performance by framing symptoms, measuring baselines, reading execution plans, tuning indexes and queries, and verifying changes on realistic data.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: SQL parameters, execution plans, and production diagnostics may contain secrets or unnecessary production values.

Mitigation: Redact secrets and minimize production-specific values before sharing SQL, parameters, plans, or logs with the agent.

Risk: Index or DDL recommendations can affect write performance, locking, storage usage, or availability if applied directly to production.

Mitigation: Test proposed changes in staging or another production-like environment, measure impact, and prepare a rollback path before production rollout.

## Reference(s):

- [ClawHub Skill Page](https://clawhub.ai/codekungfu/skills/sql-optimization)
- [Publisher Profile](https://clawhub.ai/user/codekungfu)

## Skill Output:

**Output Type(s):** [guidance, markdown, shell commands, configuration]

**Output Format:** [Markdown with SQL, DDL, and command examples when useful]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [Produces advisory optimization plans and verification checklists; does not execute database changes itself.]

## Skill Version(s):

1.0.0 (source: server release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to Sql Optimization and adjacent AI workflows.