Skip to content
About
Main content

The unifying fix

What single remedy addresses every cost anti-pattern?

The fix follows from the cause, not from discipline. You cannot make people care about a bill they see thirty days later. You make the meter visible at the moment of authorship:

  • bytes-to-be-scanned shown in the query plan;
  • dry-run estimates shown in the editor;
  • a lint rule that flags unbounded SELECT;
  • a warning on a client that is configured for another region.

This is the of Control and attribution pushed all the way back to the point of decision. That is the only place where the loop delay approaches zero.

A lint rule can be very small. For example, a check in a code-review script that rejects SELECT * on large tables:

import re, sys

BIG_TABLES = {"events", "orders", "clicks"}      # tables known to be large

def check(sql: str) -> list[str]:
    problems = []
    if re.search(r"select\s+\*", sql, re.I):
        for t in BIG_TABLES:
            if re.search(rf"\bfrom\s+{t}\b", sql, re.I):
                problems.append(f"SELECT * on large table '{t}': name the columns")
    return problems

if __name__ == "__main__":
    issues = check(sys.stdin.read())
    print("\n".join(issues) or "ok")
    sys.exit(1 if issues else 0)