Mastering Postgres
Introduction
Introduction to the course
Overview of course structure
Postgres vs. everyone
The psql CLI
Data Types
Introduction to schema
Integers
Numeric
Floating point
Storing money
NaNs and infinity
Casting types
Characters types
Check constraints
Domain types
Charsets and collations
Binary data
UUIDs
Boolean
Enums
Timestamps
Timezones
Dates and times
Advanced Data Types
Intervals
Serial type
Sequences
Identity
Network and mac addresses
JSON
Arrays
Generated columns
Text search types
Bit string
Ranges
Composite types
Nulls
Unique constraints
Exclusion constraints
Foreign key constraints
Indexing
Introduction to indexes
Heaps and CTIDs
B-Tree overview
Primary keys vs. secondary indexes
Primary key types
Where to add indexes
Index selectivity
Composite indexes
Composite range
Combining multiple indexes
Covering indexes
Partial indexes
Index ordering
Ordering nulls in indexes
Advanced Indexing
Functional indexes
Duplicate indexes
Hash indexes
Naming indexes
Understanding Query Plans
Introduction to explain
Explain structure
Scan nodes
Costs and rows
Explain analyze
Generating Results
Introduction to queries
Cross joins
Inner joins
Outer joins
Subqueries
Lateral joins
ROWS FROM
Filling gaps in sequences
Subquery elimination
Combining queries
Set generating functions
Indexing joins
Advanced SQL
Introduction to advanced SQL
Grouping
Grouping sets, rollups, cubes
Window functions
CTEs
CTEs with window functions
Recursive CTE
Hierarchical recursive CTE
Handling nulls
Row value syntax
Views
Materialized views
Removing duplicate rows
Upsert
Returning keyword
COALESCE + generated column
Full Text Search
Introduction to full text search
Searching with LIKE
Vectors, queries, and ranks
Websearch
Ranking
Indexing full text search
Highlighting
Advanced JSON
Intro to JSON
JSON vs JSONB
Validating JSON
Creating JSON objects + arrays
JSON extraction
JSON containment
JSON existence
JSON recordset
Updating JSON
Indexing JSON parts
GIN index
Vectors (pgvector)
Intro to pgvector
Vector embedding columns
Find related articles
Upsert vector embedding
Semantic search
Other operators
Vector indexes
Outro
Thank you
Bonus interviews
Heroku's glory days & Postgres vs the world (with Craig Kerstiens)
Creating a Postgres platform with Monica & Tudor from Xata.io
Bootstrapping an email service provider (with Jesse Hanley)
Locked video

Please purchase the course to watch this video.

Video thumbnail
Understanding Query Plans
Introduction to explain

Full Course

$
349
$399
USD, one-time fee
Going through the Mastering Postgres course by Aaron Francis and holy cow is it well designed. These types of well-polished knowledge products bring me an immense amount of joy.
Adam Taylor

PostgreSQL database platform

Shorten dev cycles with branching and zero-downtime schema migrations.

Test Data

I've made my test data available for you to use and follow along.

Download
or
Use on Xata

Summary

You'll learn how to read and interpret explain plans to optimize your database queries. We’ll cover various formats, settings, and node types, helping you understand the sometimes tricky indentations. By mastering these skills, you'll gain an edge in performance tuning, as you'll be able to analyze how databases calculate the cost of different query approaches and when to use `EXPLAIN` or `EXPLAIN ANALYZE` for effective troubleshooting.

Video Transcript

We've looked at the output of several different explain plans so far, but we haven't dived in super deep because it's been out of scope. Good news for you. It's in scope now.

In this hopefully short-ish module, we're gonna look at several different things about explain plans. There are different formats, there are different settings, there are outputs. Many of the node types. We're gonna look at how to read one because they're kind of indented a little bit weird. And learning this stuff and figuring out how to use this data to help you optimize your queries is going to set you so far apart and it's going to put you so much ahead of the rest of your peers.

This is an extremely important thing for you to understand specifically because when you issue a query to a database, you're telling it what to do, you're not telling it how to do it. Inside of the database it has to look at, it has to look at indexes and statistics and the data and it has to figure out, alright, what's my best, what's my best option here? The way that it does that is it calculates what it thinks are the costs. Like if I do it this way, that's gonna cost me this much, but if I do it that way, it's gonna cost me this much.

You may think you understand what it's going to do, but it is always a good idea to run and explain on it and then maybe even later, and explain, analyze if you're having quite a bit of trouble. And we're gonna look at all of that in this module.