Overview
A good schema prevents more bugs than any amount of application code. I design PostgreSQL schemas whose constraints encode the business rules, and I measure before I optimise.
PAISAPAID's 139 tables use composite foreign keys for tenant safety and a trigger that keeps written commission lines unchangeable. NovaGate's benchmark measured 0.76 ms median overhead at 500 requests per second, and the write-up reports the slow tail and the defect behind it too.
What's included
- Schema design, indexes and migrations with Prisma
- Constraints and triggers that enforce business rules in the database
- Exact money handling: integer minor units and append-only ledgers
- Query tuning from slow-query logs and query plans
- Caching, counters and rate limits in Redis
- Load tests at fixed request rates, with warm-ups and repeated rounds
- CI checks that stop edited migrations from reaching production
How I work
- 01
Measure, then change
Fixed-rate load tests with warm-ups and several rounds, compared against a direct baseline. NovaGate's benchmark took three attempts before the numbers could be trusted.
- 02
Report the tail
Medians look good on every chart. I report p99 as well, and what's behind it.
- 03
Money is integers
Amounts in minor units with BigInt and the rounding written out. Never floats.
Shipped proof
- PAISAPAID139 tables, 177 migrations, an append-only commission ledger in integer paise, and a CI check that fails if an applied migration changes.UI design set by the client, not my own.
- NovaGate0.76 ms median gateway overhead at 500 req/s with zero errors across 180,000 requests, and the p99 tail published alongside.
Questions
- Our API is slow. Where do you start?
- With measurements: timings per route, slow-query logs and a load test at a realistic rate. Slowness usually traces to a few queries or a missing index, and fixing those beats rewriting code.
- Prisma or raw SQL?
- Prisma for most of an app: typed queries and reviewed migrations. Raw SQL where a query needs it, behind code that checks what Prisma can't.
- Do you work with MongoDB?
- Yes, though I reach for PostgreSQL when the data has relations and rules that must always hold.