Database

Reading your own writes with WAIT FOR LSN in Postgres 19

PostgreSQL 19's new WAIT FOR LSN command lets a replica block until it has replayed your write. The read-after-write problem it solves, the workarounds it replaces, and what the timeout, status, and mode options are actually for.

Repositories, transactions, and unit of work in Go

Decoupling business logic from storage in Go, adding transaction support without leaking SQL details, and coordinating atomic writes across multiple repositories using a unit of work.

How do you handle transactions with the repository pattern?

Adding transaction support to a repository interface without leaking storage details.

Do you need a repository layer on top of sqlc?

Decoupling business logic from storage with a small interface in Go.

Hierarchical rate limiting with Redis sorted sets

Build multi-level rate limiting with Redis sorted sets and Lua. Enforce global and category-specific limits with ZREMRANGEBYSCORE and ZCARD commands.

Sorting a Django queryset by a custom sequence of an attribute

Sort Django querysets by custom attribute sequences using Case and When expressions for database-level ordering with SQL CASE statements.

Switching between multiple data streams in a single thread

Poll multiple data sources in a single thread using Python generators with itertools.cycle to alternate between infinite data streams efficiently.

Manipulating text with query expressions in Django

Use Django query expressions like Replace, Upper, Lower, Concat, and Substr for efficient database-level text manipulation without fetching data.

Faster bulk_update in Django

Accelerate Django bulk_update operations by 4x using multiprocessing to parallelize database writes across chunked record batches.

Recipes from Python SQLite docs

Practical SQLite recipes for Python: execute statements, batch operations, transactions, row factories, and context managers with sqlite3.

Pick random values from an array in SQL(ite)

Emulate Python's random.choice in SQLite using JSON arrays and the random() function. Populate tables with realistic test data efficiently.

Bulk operations in Django with process pool

Speed up Django bulk operations with ProcessPoolExecutor while preserving signals and hooks that bulk_create/bulk_update bypass.