PgPostgreSQL Lab
GitHub

Understand PostgreSQL by experimenting

Investigate slow queries, changes to stored data, and transaction behavior with PostgreSQL running in your browser. You should already know SELECT, WHERE, ORDER BY, and basic table and index definitions.

Open your browser laboratory to run a query and learn what your edits change.

The first investigation

Your application's order history gets slower as the table grows. Read its plan, design an index for its access pattern, then investigate an estimate that statistics cannot explain one column at a time.

  1. Read a query plan: distinguish work the planner predicts from work the executor performs.
  2. Design for the query: combine filtering and ordering, then inspect the cost of an index.
  3. Diagnose an estimate: find correlated columns and test extended statistics.

A journey from developer to operator

The full curriculum has five parts. Plans and indexes lead into data modeling and advanced SQL. Storage and maintenance explain why updates change the database over time. Transactions and production operations connect query behavior to reliable applications.

Open Chapters to jump to any investigation.

Part Investigations
Plans and indexes Read plans, design indexes, diagnose estimates, index tradeoffs.
Data and queries Constraints, sets and windows, JSONB, partitioning.
Storage and maintenance Row versions, vacuum, healthy statistics.
Reliable applications Isolation, locks, migrations.
Operations Observability, backup and restore, replication, incident investigation.

Start every part in the browser. Use the server laboratory setup only for optional independent-session, pg_dump, and streaming-replication extensions. Each chapter includes predictions, ordered experiments, interpretation, hints, a worked explanation, and a transfer task.

Evidence you can change

Every SQL experiment runs against PostgreSQL through PGlite. The output comes from your database. Edit a predicate, remove an index, or change the query's order and ask whether your explanation still holds.

The browser runtime uses one connection and supports a real checkpoint/restore exercise. Multi-session contention and streaming replication use the optional server extensions. Read the runtime boundaries before translating timings or operational observations to a production server.