Databases
- Databases5 min read
Caching strategies
Where caches live, the patterns for using them (cache-aside, read-through, write-through, write-behind), choosing TTLs, eviction policies, keeping caches correct after writes, and the stampede and stale-data problems that bite in production.
- Databases6 min read
Cassandra explained
How Apache Cassandra stores huge amounts of data across many machines: the masterless ring, partition keys and clustering columns, query-first data modelling, replication factor and tunable consistency, the write path with commit log, memtables and SSTables, compaction and tombstones, CQL, and when Cassandra is the right choice.
- Databases6 min read
Connection pooling
Why applications reuse database connections instead of opening one per request: the cost of a connection, how a pool works, HikariCP and other pools, sizing a pool correctly, timeouts and leak detection, PgBouncer for many application instances, serverless pitfalls, and monitoring.
- Databases5 min read
Database indexes
Why a missing index turns a millisecond query into seconds: how B-tree indexes find rows, what they cost on writes, composite indexes and column order, covering indexes, when the database ignores an index, and how to check with EXPLAIN.
- Databases6 min read
Database migrations with Flyway
Manage database schema changes like code with Flyway: why migrations exist, versioned and repeatable migration files, naming rules, the schema history table, using Flyway with Spring Boot, the CLI and Maven or Gradle, checksums and validation, baselining an existing database, and writing safe migrations for zero-downtime deploys.
- Databases6 min read
Elasticsearch explained
How Elasticsearch powers fast full-text search: documents and indices, the inverted index, analyzers and tokenisation, mappings, match and bool queries, relevance scoring with BM25, aggregations, shards and replicas, keeping it in sync with your database, and when to use it.
- Databases5 min read
Isolation levels
Transaction isolation levels in practice: the anomalies they prevent (dirty reads, non-repeatable reads, phantoms, lost updates and write skew), how read committed, repeatable read and serializable behave in PostgreSQL and MySQL, and how to choose.
- Databases5 min read
MongoDB for beginners
Get started with MongoDB, the most popular document database: documents and collections, running it with Docker, the mongosh shell, inserting and querying with filters and projections, updates and operators, indexes, the aggregation pipeline, schema design by embedding or referencing, and when to choose it.
- Databases6 min read
Normalisation
Database normalisation explained with one messy table refactored step by step: the update, insert and delete anomalies it causes, first, second and third normal form, BCNF in brief, and when deliberate denormalisation is the right choice.
- Databases5 min read
PostgreSQL for beginners
Get started with PostgreSQL: installing it with Docker or natively, connecting with psql, creating databases, users and tables, essential data types, inserting and querying data, indexes, constraints, JSONB, backups, and the psql commands you will use every day.
- Databases7 min read
Reading a query plan
How to read EXPLAIN and EXPLAIN ANALYZE output to find out why a query is slow: plan trees, sequential and index scans, index-only and bitmap scans, nested loop, hash and merge joins, estimated versus actual rows, buffers, sorting and memory, and a step-by-step method for fixing slow queries in PostgreSQL and MySQL.
- Databases5 min read
Redis data structures
A practical tour of Redis's types: strings, lists, sets, hashes, sorted sets, streams, bitmaps and HyperLogLog, with the commands, the cost of each, and the real problems each one solves.
- Databases6 min read
Replication
How database replication keeps copies of data on several servers: primaries and replicas, synchronous and asynchronous replication, replication lag and read-your-writes, failover and split brain, multi-primary and leaderless designs, PostgreSQL and MySQL in practice, and what replication does not replace.
- Databases5 min read
Sharding
How sharding splits one database across many servers: when you actually need it, choosing a shard key, range, hash and directory-based sharding, routing queries, cross-shard queries and transactions, rebalancing, hot spots, and the databases that shard for you.
- Databases6 min read
SQL joins
SQL joins explained with two small tables and their exact results: inner, left, right and full outer joins, cross joins, self joins, joining on several conditions, the ON versus WHERE trap, anti-joins for finding missing rows, duplicate rows from one-to-many joins, and performance.
- Databases4 min read
SQL vs NoSQL
What separates relational databases from document, key-value, wide-column and graph stores: schemas, joins, transactions, scaling and consistency, with a practical guide to choosing, and why "both" is often the honest answer.
- Databases5 min read
The CAP theorem
The CAP theorem explained without the myths: consistency, availability and partition tolerance defined precisely, why partitions force a choice, CP and AP systems with real database examples, PACELC and the latency trade-off, tunable consistency, and how to use CAP in design discussions.
- Databases5 min read
The N+1 query problem
What the N+1 query problem is and how to fix it in any stack: how ORMs and lazy loading cause it, spotting it in logs and tests, fixes with joins, fetch joins and entity graphs in JPA, select_related and prefetch_related in Django, eager loading in Prisma and Rails-style ORMs, batching with IN queries and DataLoader, and preventing regressions.
- Databases5 min read
Transactions and ACID
What a database transaction is and the four ACID guarantees behind it: atomicity, consistency, isolation and durability, explained with a money transfer, plus commit and rollback in SQL and code, and the mistakes that leave data half-changed.
- Databases6 min read
Redis from the ground up
What Redis is, why keeping data in memory makes it so fast, the data structures it offers, how it survives a restart, and the jobs it is actually good at.