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
Generating Results
Introduction to queries

Full Course

$
349
$399
USD, one-time fee
Mastering Postgres is such a crisp way to learn this subject. With today’s AI tools writing many of the queries via autocomplete it’s vital to have this knowledge to ensure you know what’s actually happening under the hood. My app’s performance improved overnight after learning more about indexing. Aaron’s excitement for the subject makes it really fun to learn whether I’m next to my code editor or on a treadmill run.
Peter Ramsing
Peter Ramsing

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

Get ready to dive into writing powerful SQL queries using joins, Common Table Expressions (CTEs), and window functions—all of which are both fun and incredibly useful. Even if you don’t use them immediately, understanding these tools equips you to recognize opportunities to apply them in future projects. Building this foundation will make you a more confident and effective database user.

Video Transcript

You made it through indexing. This is basically a college course on its own. Congratulations, you made it here.

Now, we're gonna start writing some queries, which is also super fun. If you haven't gathered yet, I think all of this is super fun. In this module, we're gonna do joins, we're gonna do CTEs, recursive CTEs, window functions, series, obfuscation, we're gonna do all kinds of stuff, and here is my encouragement to you as you're watching these. As you're watching these, and you think, "Do I need a window function? I don't have any use for a window function," hear me out.

As you learn about this stuff, your brain is being primed. You're adding signposts in your brain, and then later, when you're working, you don't even have to remember how a window function works. You just have to look at the problem that you're currently working on and think, "Hang on, that feels like something that a window function might solve." Because you have watched the video, and you have learned about the thing, your brain is primed to recognize that pattern in your work.

Recursive CTEs, awesome, maybe not an immediate use case, but totally awesome, window functions, CTEs, cross joins, all of this stuff I think will be useful to you at some point, and ideally, you'll be watching it and think, "Holy cow, that is exactly the problem I have been struggling with." Fingers crossed that that happens. If that does happen, let me know. I would love to hear about it.

Let's write some queries.