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)
Next video (8)
Introduction
Overview of course structure

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

You'll learn how to navigate the MasteringPostgres.com platform, including tips for viewing in dark or light mode, and insights into using Postgres version 17 RC1. Recommendations for running Postgres locally with free tools like Postgres.app or DBngin are included, along with helpful resources for database setup and test data access.

Links

Postgres.app
How to install PostgreSQL
How to configure PostgreSQL

Video Transcript

Before we dive in too far, I want to give you a little tour of what you're gonna be seeing, both on the website where you're watching this video and on the screen. You know, many times I'll be full screen like this and trying to explain something to you and pointing at stuff, that sort of thing. Sometimes you'll see graphics to help explain some theoretical concepts a little better.

Most of the time, I'm gonna be little and out of the way, and we're gonna be looking at this. This is an application called TablePlus. I have no affiliation with them, it is just a SQL GUI that I happen to really like. And the reason I like it is I find it very ergonomic for teaching and for day-to-day usage. If we were to do something like select * from users limit 10, then I can say like, "Okay, well now, if we take this, we come down here and we format this and we come up here and we say where, and we get a little bit of auto complete here."

I just find that this speeds up the process of teaching, so I'm not constantly fiddling around with, you know, something over here where it's like, "Okay, well, let me take this one. What was that last one we used? Let me pull that in."

This is psql, I'll show you how to use this. It's a great tool. I find that when we're doing a bunch of different things, having a GUI here is quite nice. Now, on the website itself you're watching this video on masteringpostgres.com, you can change the website to dark mode or light mode. If you change the website to dark mode, the actual interface, the video itself will change to dark mode, which is kind of insane, it's a little bit over the top. Hey, I know a lot of people like dark mode, and I know a lot of people like light mode, so why not? You can do that on, you know, the nav bar up the top of the website, and all of the video will change. Now, I will not change, I'm not gonna go dark mode. This is what you're gonna see, but the interface will change.

The version of Postgres that I'm using in this course is 17 RC1. I will call out when old versions don't have the right stuff that I'm teaching. I think there's some instances where prior to 10, certain things weren't available, or prior to 12, this function works differently. I will try to call that out, because I know not everyone is on 17, but I did want to be on the most recent version at the time of recording.

The place that I get my local Postgres is from the fine proprietors of Postgres.app. I'll leave the links down below for that. For Postgres.app, it's just a GUI that that gets Postgres up and running. I think it is very nice, it's very normie, it makes it very easy to spin up different versions if you need to do that.

There's another GUI option called DBngin. That's quite good, it includes Postgres, MySQL, Redis, and maybe a few others. It's by the same people that create TablePlus. I think it's the same person, I think it's an individual person that creates both of those apps. DBngin is free, Postgres.app is free. I'm not associated with either, they're both just really good.

If you don't want to use one of those normie GUIs, which is totally fine, we have written a full article on getting Postgres up and running on your local machine, it just doesn't make very engaging video. I'm not gonna show you how to get all of that up and running on a Linux, a Windows, and a Mac machine. Instead, we just wrote out an article. I'll leave a link to that below.

You can also get the test data or the data that I'm using here. You can get that down below, or you can spin up a database on Xata and follow along over there if you want. I think that is about it.

If you have any questions, please feel free to reach out and ask for help. Hopefully, that is an overview of the site, the video, the stuff that you'll see on screen. We can start doing some learning.