← Side Quests

October 7, 2026

Pushing work to the database

I came across a codebase recently that had some real performance issues. The code was pulling a bunch of rows from the database and then doing the filtering and pagination in code. It worked! But it was slow and used way too much memory.

So I moved the work into the database instead. Filtering in the WHERE clause, JOINs instead of a bunch of separate queries, and real pagination. LIMIT and OFFSET for the simple cases, and cursor based pagination for the big tables.

Then I tested it myself to make sure it actually helped. And it did. Way less data moving around, and the pages loaded faster.

It was a good reminder. Let the database do its job! It is faster and the code gets simpler.