databases
10 minPostgreSQL MVCC and Indexes: Reads, Vacuum, and Query Plans
Connect PostgreSQL's multi-version concurrency control to transaction visibility, vacuum work, index choice, and EXPLAIN output.
Loading page...
databases
10 minConnect PostgreSQL's multi-version concurrency control to transaction visibility, vacuum work, index choice, and EXPLAIN output.
Q&A
Q&APostgreSQL and MySQL commonly use LIMIT; Oracle supports FETCH FIRST and legacy ROWNUM patterns.
PostgreSQL and MySQL support ORDER BY with LIMIT; standard FETCH FIRST syntax is also available in modern versions. Oracle supports FETCH FIRST in current versions; older ROWNUM queries must sort in an inner query before limiting in an outer query. Always specify deterministic ordering and test the exact target version.
Q&A
Q&AAn old transaction snapshot may still need row versions that newer transactions have replaced.
PostgreSQL MVCC keeps row versions visible to active snapshots. A long-running transaction can hold an old snapshot open, so vacuum cannot yet remove some dead versions. Bound transaction lifetimes and investigate idle-in-transaction sessions when table bloat grows.
databases
8 minUse concurrent index builds without assuming they are lock-free or all-or-nothing.
databases
10 minChoose between distinct salary ranking, row ranking, and pagination syntax while handling ties and NULLs explicitly.
databases
5 minInvestigate missing heartbeats with PostgreSQL interval arithmetic and a separate SQLite integer-millisecond contract.
Q&A
Q&ACheck active work and catalog validity before dropping or retrying.
Concurrent builds use multiple phases and can leave an invalid index. Inspect the server error and pg_index readiness/validity, waits, and transactions; do not assume the operation was atomic or load-free.
Q&A
Q&AUse DENSE_RANK for distinct values and state whether you want salary values or employee rows.
Filter out NULL salaries, compute DENSE_RANK() OVER (ORDER BY salary DESC), then select rank 3. DENSE_RANK treats equal salaries as the same rank. PostgreSQL, MySQL 8+, and Oracle support this window-function approach; if you instead mean the third row, use ROW_NUMBER with a deterministic tie-breaker.