sql-optimization

Installation
SKILL.md

SQL Query & Data Model Optimization

Expert-level guidance for optimizing SQL queries and database schemas based on the principles from use-the-index-luke.com. This skill focuses on practical, proven techniques for achieving optimal database performance through proper indexing strategies, query optimization, and data model design.

Core Principles

The Three Powers of Indexing

  1. B-Tree Traversal (Tree Search)

    • Provides logarithmic scalability - tree depth grows very slowly compared to data volume
    • Real-world indexes with millions of records typically have tree depths of 4-5 levels
    • The tree is always balanced - databases maintain balance automatically
    • Myth Debunked: Indexes do NOT "degenerate" over time. Rebuilding indexes rarely improves performance (0-2% improvement for typical queries)
  2. Data Clustering

    • Indexes cluster rows with similar values together
    • Reduces I/O operations by storing consecutently accessed data close together
    • Key technique: Index-Only Scan (Covering Index) - include all queried columns in the index to avoid table access entirely
Installs
1
First Seen
Aug 28, 2026