Query and persist data
Data & storage
Explore queries, indexes, transactions and storage operations using synthetic records.
- concept
SQL primary keys and unique constraints
A primary key requires unique, non-null key values. A unique constraint follows its declared duplicate rule; PostgreSQL 18 default UNIQUE constraints allow multiple NULLs.
Explore the idea - concept
Database indexes and query plans
An index can let a query locate candidate rows without scanning every table row. That can reduce retrieval work, but a planner may still choose a sequential scan when its estimated cost is lower.
Explore the idea - concept
SQL joins explained
INNER JOIN returns one row for every matching left–right pair. LEFT JOIN returns those same pairs and also preserves each unmatched left row with NULLs in the right-side fields. Later filters can still remove rows from that joined result.
Explore the idea - concept
Database transactions and ACID
A transaction groups transactional changes into commit or rollback. ACID names distinct guarantees whose behavior depends on the database, isolation level and persistence configuration.
Explore the idea - comparison
Object, block and file storage
Object storage addresses named objects by key through an API; block storage exposes addressable logical blocks; file storage presents files and directories through paths and filesystem operations.
Explore the idea - comparison
Database backups, snapshots and consistency
A snapshot can be part of a backup, but its existence proves neither consistency nor recovery. The base copy must meet engine requirements, and required change logs must cover the recovery target.
Explore the idea - concept
Database connection pooling
A database connection pool reuses connections and caps how many callers can borrow them at once. When all usable connections are borrowed, additional callers must wait or fail according to the pool's policy.
Explore the idea - concept
MVCC snapshot visibility across concurrent transactions
In PostgreSQL Repeatable Read, a later commit by another transaction does not change an established snapshot. The reader can still see its own earlier writes.
Explore the idea - concept
Write skew and snapshot isolation anomalies
Two doctors can each see the other on call, update different rows, and leave the roster empty. Write skew is about the rule their decisions share, not a collision between their writes.
Explore the idea - concept
WAL commit durability and crash recovery
A changed page can still be unwritten when a transaction commits. What matters for crash recovery is whether the durable log records both the change and its commit—not just whether the client received a reply.
Explore the idea - concept
B-tree page splits and index amplification
One index insert can change two leaves and their parent. Compare a key that fills the last slot with one that forces a B-tree split, and distinguish changed pages from disk writes.
Explore the idea - comparison
Hash join versus merge join under skew
Compare the same rows two ways: a hash join pays for a build or partition that outgrows memory; a merge join pays for missing input order. See which cost changes without treating either score as runtime.
Explore the idea - troubleshooting
Cardinality-estimation errors and optimizer choices
A lookup can be cheap once and costly when repeated. Compare the plan favored by an estimated row count with the plan favored by the actual count, and see when an estimate error matters.
Explore the idea - concept
Database deadlocks and wait-for graphs
Follow the arrows from waiting transactions to their blockers. A path that loops back explains a lock deadlock; a path that ends can still leave transactions waiting.
Explore the idea - concept
LSM-tree compaction and write amplification
Compaction can shrink a set of sorted runs while increasing total bytes written. Follow a four-run merge to separate the cost of rewriting entries from the benefit of having fewer places to look.
Explore the idea - troubleshooting
Hot partitions and shard-key skew
Two shards can own two keys each yet receive 100 requests on one and 20 on the other. Follow one popular key to see why moving it changes the busy shard without dividing its demand.
Explore the idea - procedure
Change-data-capture offsets and replays
A CDC checkpoint tells a consumer where to resume, not which effects survived. Compare it with durable effects and retained history to distinguish a harmless reread from a repeated effect, skipped work, or a gap.
Explore the idea
Read the assumptions and changed conditions before applying any conclusion to a real database or filesystem.