query-optimizer

Installation
SKILL.md

Query Optimizer

Fix the queries, prove it with numbers, and add a guard so it doesn't regress.

Step 1: Guard first

Before changing code, write (or reuse from perf-audit) a test that pins the current query count with realistic row counts (at least 10-20 rows, so N+1 is visible):

def test_invoice_list_queries(admin_client_for, org, invoice_factory, django_assert_num_queries):
    invoice_factory.create_batch(20, org=org)
    with django_assert_num_queries(3):   # target after fix
        resp = admin_client_for(org).get("/api/invoices/")
    assert resp.status_code == 200

It fails now (that's the point). Also check the existing tests for the endpoint pass, so you know behavior doesn't change. TestCase projects: with self.assertNumQueries(3):.

Step 2: Fix, by pattern

Installs
1
GitHub Stars
1
First Seen
9 days ago