query-budget-enforcer

Installation
SKILL.md

Query Budget Enforcer Protocol

This skill acts as the financial and operational conscience of the database. It reviews queries not just for speed, but for computational cost, lock duration, and hardware limits.

Core assumption: In cloud data warehouses (Snowflake, BigQuery), bad queries cost actual money. In OLTP (PostgreSQL), bad queries crash the server.


1. Budget Categories (Static vs Dynamic)

  • Default (Static): Analyze queries textually based on known engine constraints (e.g. flagging SELECT * without WHERE for BigQuery or lack of LIMIT).
  • Dynamic (On-Demand): Connect to the database or metrics API (e.g. pg_stat_statements) to read historical query execution costs or dry-run estimates only if requested.
  • When evaluating a query, enforce limits based on the context:

A. Data Warehouse Constraints (BigQuery / Snowflake)

  • Terabytes Scanned: Did they use a SELECT * without partition filters (WHERE date = ...)?
  • Cost Estimation: "This query scans 4TB. At $5/TB, this single run costs $20."

B. OLTP Constraints (PostgreSQL / MySQL)

  • Rows Examined vs Returned: If a query examines 100,000 rows (Rows Removed by Filter: 99990) to return 10 rows, it violates the efficiency budget.
Related skills

More from fatih-developer/fth-skills

Installs
3
GitHub Stars
4
First Seen
Mar 3, 2026