DBDecoded
About
Lessons
Blog
Sign in
Home
Forum
Forum
Ask a question or start a discussion about any PostgreSQL lesson.
How PostgreSQL executes a SQL statement
Learn how PostgreSQL executes a SQL statement through four stages: parsing, rewriting, planning and optimization, and execution.
Understanding PostgreSQL execution plans
Learn how to use PostgreSQL EXPLAIN to read execution plans and understand plan nodes, estimated costs, row estimates, and other planner information.
Using EXPLAIN ANALYZE to measure actual execution
Learn how to use PostgreSQL EXPLAIN ANALYZE to compare estimates with actual execution times, row counts, loops, buffers, and total runtime.
Improving query performance with indexes
Learn how PostgreSQL indexes improve selective queries by replacing sequential scans with index scans, and understand their storage and write costs.
Paginating results with LIMIT and OFFSET
Learn how to build offset-based pagination in PostgreSQL using ORDER BY, LIMIT, and OFFSET, and why a predictable sort order matters.
Understanding the cost of large OFFSETs
Learn why large PostgreSQL OFFSET values make pagination slower, how much extra work PostgreSQL performs, and why an index doesn’t eliminate that cost.
Introducing keyset pagination
Learn how PostgreSQL keyset pagination uses the last row as a cursor to fetch the next page efficiently and avoid the growing cost of large OFFSETs.
Keyset pagination with multiple sort columns
Learn how to use multiple sort columns for PostgreSQL keyset pagination with a unique tie-breaker and row-value cursor comparisons.
Navigating forward and backward with keyset pagination
Learn how PostgreSQL keyset pagination moves forward and backward using the last or first row as the cursor boundary and adjusting the sort direction.
Choosing between offset and keyset pagination
Compare offset and keyset pagination in PostgreSQL and learn when to use each for numbered pages, direct jumps, large result sets, and sequential navigation.
Why transactions exist
Learn why PostgreSQL transactions are needed when multiple SQL statements must succeed or fail together as a single unit of work.
Using BEGIN, COMMIT, and ROLLBACK
Learn how implicit and explicit PostgreSQL transactions work and how to use BEGIN, COMMIT, and ROLLBACK to save or discard changes.
Why transactions alone don't prevent race conditions
Learn why atomic transactions do not prevent race conditions when concurrent requests read the same state and then make conflicting changes.
Understanding MVCC
Learn how PostgreSQL MVCC creates row versions, uses snapshots to control visibility, lets reads avoid unnecessary blocking, and coordinates writes with locks.
Understanding READ COMMITTED
Learn how PostgreSQL READ COMMITTED gives each statement a new snapshot, hides uncommitted changes, and can still allow read-check-write races.
Preventing race conditions
Learn two ways to prevent PostgreSQL race conditions: lock rows with SELECT FOR UPDATE or move the condition into an atomic UPDATE.
Using REPEATABLE READ and SERIALIZABLE
Compare PostgreSQL READ COMMITTED, REPEATABLE READ, and SERIALIZABLE, including consistent snapshots, serialization failures, and application retries.
Understanding deadlocks
Learn how PostgreSQL deadlocks form, how the database resolves them, why applications may need retries, and how consistent lock ordering reduces risk.
Using savepoints
Learn how PostgreSQL savepoints let you roll back part of a transaction, preserve earlier work, recover from errors, and continue toward COMMIT.