/ tag
PostgreSQL
5 posts on this topic.
-
The Postgres features I reach for before I reach for a cache
A slow multi-tenant Rails app usually isn't slow because Postgres is slow. It's slow because the work is being done in Ruby that Postgres would do better. DISTINCT ON, array overlap, and full-text search — with the honest limits.
-
Roles that contain roles: an RBAC resolved by a recursive Postgres query
When a role can inherit other roles, permissions stop being a list and become a graph — and graphs are where the ORM taps out. Here's a role system resolved in one WITH RECURSIVE query, cached per tenant, and enforced through method_missing.
-
Schema-per-tenant Rails, and the bug that only shows up in a background job
Isolating tenants in separate Postgres schemas is the easy 90%. The 10% that bites is keeping that isolation when work leaves the web request and runs on an SQS worker. Here's how we carried the tenant across the queue.
-
Auto-categorizing bank transactions with Postgres fuzzy matching (no ML)
'UBER *EATS 8829' and 'UBER* EATS' are the same recurring expense, but the strings don't match. How I auto-categorize bank feeds with Postgres levenshtein() and soundex() against a user's own history — no machine learning.
-
The availability search that loaded every booking into memory — a Rails date-range fix
A marketplace 'search by dates' feature quietly became O(bookings × listings): it pulled every booking in the database into Ruby and eliminated listings one query at a time. The fix was a single overlap query the codebase already had — and never used.