PostgreSQL Next Steps

What you can now do

Query with joins, aggregates, subqueries, CTEs and window functions; design tables with the right types and constraints; index them and read EXPLAIN; use transactions correctly; and work with JSONB and full-text search.

Query-writing habits worth keeping

  • Name columns explicitly instead of SELECT * in application code.
  • ORDER BY whenever you LIMIT.
  • EXISTS rather than NOT IN when NULLs are possible.
  • Filter in WHERE before grouping; use HAVING only for aggregates.
  • Alias every table in a multi-table query.
  • Run EXPLAIN ANALYZE on anything slow before guessing.

Schema design habits

  • A primary key on every table.
  • TIMESTAMPTZ, not TIMESTAMP.
  • NUMERIC for money, never float.
  • TEXT over VARCHAR(n) unless a limit is a real business rule.
  • Index every foreign key.
  • Let constraints enforce invariants — the database is the last line of defence, and it never forgets.

Migrations

Never change a production schema by hand. Use a migration tool — Flyway, Liquibase, Alembic, Prisma Migrate, or plain numbered .sql files applied by a script — so every environment ends up identical and changes are reviewable in version control.

Where to go next

Performance. Learn to read EXPLAIN (ANALYZE, BUFFERS) properly, enable pg_stat_statements to find your slowest queries, and understand connection pooling (PgBouncer) — running out of connections is one of the most common production failures.

Replication and high availability. Streaming replication, read replicas, and point-in-time recovery with WAL archiving.

Partitioning. Declarative partitioning for very large tables, typically by date range.

Extensions. PostGIS for geospatial data, pg_cron for scheduled jobs, pgvector for embeddings and semantic search, TimescaleDB for time series.

The documentation. The official PostgreSQL manual is unusually good — genuinely worth reading rather than only searching.

Practise

Take a real dataset — a bookstore, a school, your own project — and try to answer questions with a single query: top sellers per month, customers who never ordered twice, running revenue totals. Real questions teach joins and window functions far faster than isolated exercises.