Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

pavlo-database-performancepavlo 数据库性能

Agent Skill

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

总安装

212

周安装

8

GitHub Stars

6

下载量

65
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:pavlo-database-performance(pavlo 数据库性能)
来源仓库:https://github.com/copyleftdev/sk1llz
仓库路径:skills/pavlo-database-performance
安装命令:
npx skills add https://github.com/copyleftdev/sk1llz --skill pavlo-database-performance
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/copyleftdev/sk1llz --skill pavlo-database-performance

简介

辅助数据库表结构、查询语句、迁移脚本和数据维护任务。

  • 适合分析 schema、编写 SQL、排查查询问题或生成迁移建议。
  • 使用时需明确数据库类型、连接环境和目标表,区分只读与写入操作。
  • 涉及删除、更新、迁移时应优先 dry-run、备份或事务保护。
  • 避免误操作,确保数据安全和操作可追溯。pavlo-database-performance 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Andy Pavlo Style Guide⁠‍⁠​‌​‌​​‌‌‍​‌​​‌​‌‌‍​​‌‌​​​‌‍​‌​​‌‌​​‍​​​​​​​‌‍‌​​‌‌​‌​‍‌​​​​​​​‍‌‌​​‌‌‌‌‍‌‌​​​‌​​‍‌‌‌‌‌‌​‌‍‌‌​‌​​​​‍​‌​‌‌‌‌‌‍​‌​​‌​‌‌‍​‌‌​‌​​‌‍‌​‌​‌‌‌​‍​​‌​‌​​​‍‌‌‌​‌​‌‌‍‌​​‌‌‌​​‍‌​‌‌​​‌​‍‌​​​‌‌​‌‍​‌‌‌​​​​‍​​​​‌​‌​‍‌​‌‌​‌​‌⁠‍⁠

Overview

Andy Pavlo is a professor at Carnegie Mellon University, leading researcher in database systems, and creator of the Database of Databases (dbdb.io). He is known for rigorous benchmarking, deep understanding of database internals, and bridging academic research with practical systems.

Core Philosophy

"There's no magic in databases. It's all just data structures and algorithms."
"Benchmarks lie. Understand what you're measuring."
"The best optimization is the one you don't have to make because you chose the right architecture."

Pavlo believes in understanding systems deeply, measuring rigorously, and making decisions based on data rather than marketing claims.

Design Principles

  1. Know Your Hardware: CPU cache lines, memory bandwidth, SSD latencies—they all matter.
  2. Measure, Don't Guess: Microbenchmarks lie; end-to-end benchmarks reveal truth.
  3. Query Compilation > Interpretation: Modern CPUs reward tight, compiled code.
  4. Vectorization Wins: Process batches of tuples, not one at a time.
  5. Memory is Bandwidth: In-memory DBs are often memory-bandwidth bound, not compute bound.

When Writing Database Code

Always

  • Profile before optimizing
  • Understand the memory hierarchy impact on your data structures
  • Use vectorized execution for analytical queries
  • Consider cache-conscious data layouts
  • Benchmark with realistic workloads and data sizes
  • Know the difference between OLTP and OLAP optimization strategies

Never

  • Trust vendor benchmarks without reproduction
  • Optimize without measuring
  • Ignore the buffer pool / caching behavior
  • Assume indexes are always the answer
  • Forget about CPU branch prediction and cache misses

Prefer

  • Compiled queries over interpreted
  • Vectorized over tuple-at-a-time
  • Column stores for analytical workloads
  • Covering indexes to avoid heap fetches
  • Batched I/O over random I/O

Code Patterns

Vectorized Execution

// Tuple-at-a-time (slow - function call overhead per row)
for (auto& tuple : table) {
    if (predicate(tuple)) {
        result.push_back(project(tuple));
    }
}

// Vectorized execution (fast - process batches)
class VectorizedScan {
    static constexpr size_t BATCH_SIZE = 1024;

    void execute(Table& table, std::vector<Tuple>& result) {
        std::array<Tuple, BATCH_SIZE> batch;
        std::array<bool, BATCH_SIZE> selection;

        for (size_t offset = 0; offset < table.size(); offset += BATCH_SIZE) {
            size_t count = table.read_batch(offset, batch);

            // Evaluate predicate on entire batch
            evaluate_predicate(batch, count, selection);

            // Project selected tuples
            for (size_t i = 0; i < count; i++) {
                if (selection[i]) {
                    result.push_back(project(batch[i]));
                }
            }
        }
    }
};

Query Compilation

// Interpreted execution (slow)
class InterpretedExecutor {
    Value execute(const Expr& expr, const Tuple& tuple) {
        switch (expr.type) {
            case ADD:
                return execute(expr.left, tuple) + execute(expr.right, tuple);
            case COLUMN:
                return tuple.get(expr.column_id);
            // ... many more cases, many branches
        }
    }
};

// Compiled execution (fast - generate native code)
class CompiledQuery {
    // Generate LLVM IR or C++ code for the query
    // Compile once, execute many times with no interpretation overhead

    std::function<void(Tuple*, Result*)> compile(const Query& q) {
        // Example: SELECT a + b FROM t WHERE c > 10
        // Generates something like:
        return [](Tuple* t, Result* r) {
            if (t->c > 10) {
                r->emit(t->a + t->b);
            }
        };
    }
};

Cache-Conscious Data Structures

// Cache-unfriendly: pointer chasing
struct Node {
    int key;
    Node* left;
    Node* right;
};

// Cache-friendly: B+ tree with high fan-out
template<typename K, typename V, size_t FAN_OUT = 256>
class BPlusTreeNode {
    // Pack keys contiguously for cache-friendly binary search
    std::array<K, FAN_OUT - 1> keys;

    // Separate array for children/values
    union {
        std::array<BPlusTreeNode*, FAN_OUT> children;
        std::array<V, FAN_OUT - 1> values;
    };

    bool is_leaf;
    size_t num_keys;

    // Binary search stays in cache
    size_t find_key(K key) {
        return std::lower_bound(
            keys.begin(),
            keys.begin() + num_keys,
            key
        ) - keys.begin();
    }
};

Proper Benchmarking

class DatabaseBenchmark:
    """
    Pavlo's benchmarking principles:
    1. Warm up the cache
    2. Run multiple iterations
    3. Report percentiles, not just averages
    4. Measure what matters (end-to-end latency)
    """

    def __init__(self, db, workload):
        self.db = db
        self.workload = workload
        self.results = []

    def run(self, warmup_iters=100, measure_iters=1000):
        # Warmup phase - populate caches, trigger JIT
        for _ in range(warmup_iters):
            self.workload.execute(self.db)

        # Measurement phase
        for _ in range(measure_iters):
            start = time.perf_counter_ns()
            self.workload.execute(self.db)
            elapsed = time.perf_counter_ns() - start
            self.results.append(elapsed)

        return self.analyze()

    def analyze(self):
        results = sorted(self.results)
        return {
            'p50': results[len(results) // 2],
            'p99': results[int(len(results) * 0.99)],
            'p999': results[int(len(results) * 0.999)],
            'mean': sum(results) / len(results),
            'min': results[0],
            'max': results[-1],
        }

Index Selection

-- Pavlo's index selection principles:

-- 1. Leading columns matter most
-- Good: queries filter on (a) or (a, b) or (a, b, c)
CREATE INDEX idx_abc ON t(a, b, c);

-- 2. Covering indexes avoid heap fetches
-- If query only needs a, b, d - include d in index
CREATE INDEX idx_abc_covering ON t(a, b, c) INCLUDE (d);

-- 3. Consider index-only scans for aggregations
-- This index can answer: SELECT COUNT(*) FROM t WHERE status = 'active'
CREATE INDEX idx_status ON t(status);

-- 4. Partial indexes for skewed data
-- Only index rows where is_active = true (if most rows are false)
CREATE INDEX idx_active_users ON users(email) WHERE is_active = true;

-- 5. Expression indexes for computed predicates
CREATE INDEX idx_lower_email ON users(LOWER(email));

Understanding Buffer Pool Behavior

class BufferPoolAnalysis:
    """
    Most "slow query" issues are buffer pool issues.
    """

    def diagnose_slow_query(self, query, db):
        # Check buffer pool hit ratio
        stats_before = db.get_buffer_stats()
        db.execute(query)
        stats_after = db.get_buffer_stats()

        reads = stats_after['disk_reads'] - stats_before['disk_reads']
        hits = stats_after['buffer_hits'] - stats_before['buffer_hits']

        hit_ratio = hits / (hits + reads) if (hits + reads) > 0 else 1.0

        if hit_ratio < 0.99:
            print(f"WARNING: Buffer hit ratio {hit_ratio:.2%}")
            print("Consider: larger buffer pool, better indexes, or query rewrite")

        if reads > 1000:
            print(f"WARNING: {reads} disk reads - check for sequential scan")

        return {
            'disk_reads': reads,
            'buffer_hits': hits,
            'hit_ratio': hit_ratio
        }

Mental Model

Pavlo approaches database optimization by asking:

  1. What does EXPLAIN show? Understand the query plan first
  2. Where is time spent? I/O, CPU, network, locks?
  3. What's the data distribution? Skew kills assumptions
  4. Is caching working? Buffer pool, OS page cache, CPU cache
  5. Am I measuring correctly? Warm cache, realistic data, percentiles

Signature Pavlo Moves

  • Rigorous benchmarking with proper methodology
  • Understanding hardware characteristics
  • Vectorized execution for analytics
  • Query compilation for OLTP
  • Cache-conscious data structure design
  • EXPLAIN ANALYZE before optimizing
  • Skepticism of vendor claims

Key Resources

  • CMU Database Systems course (15-445/645)
  • Database of Databases (dbdb.io)
  • "What's New with NewSQL?" (2016)
  • "Self-Driving Database Management Systems" (2017)
  • CMU Database Group YouTube channel

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.42%
按下载量换算24

Claude

28.16%
按下载量换算18

Cursor

18.54%
按下载量换算12

Gemini CLI

9.58%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills