query-design

Installation
SKILL.md

Design queries around round trips

Count round trips before writing SQL. Small tables can still produce slow runs when each row needs several database calls.

round trips per call × calls per run × RTT = wall time

RTT means round-trip time. This arithmetic estimates serial network time; query execution, decoding, and connection acquisition add costs.

Consider an illustrative scan of about 9k threads:

  • Per-thread reads: 5 round trips × about 9.3k threads × 81 ms ≈ 63 minutes.
  • Paged and batched reads: 2 round trips × 93 pages × about 100 ms ≈ 20 seconds.
  • These are planning inputs. Measure RTT where the caller runs before choosing its budget.

A capability call has a constant round-trip budget, independent of result size. State that number and bound its result. A scan costs O(pages), never O(rows). Count transaction control statements and any final empty-page probe too.

Done means the store implementation matches a written query plan, and checks detect violations of its statement and access-path budgets.

Installs
8
GitHub Stars
146
First Seen
Oct 13, 2026