Often times the gap in trying/learning something in Postgres is having a good tangible example. The playground makes that easier by loading a datasets then guiding you step by step through an exercise leveraging that dataset in a practical way. Whether it's just the basics of interacting in the Postgres CLI with psql , improving your querying skills with SQL, or digging into performance analysis we want something for everyone to be able to level up your skills. Our guided tutorials focus on practical uses and examples as opposed to purely academic definitions.
psql basics
Never seen Postgres from the command line before? Start here! We’ve loaded a sample database in for you and you’re a superuser.
Joins in Postgres
Learn about inner and outer joins in this tutorial
Indexing (B-Tree Indexes)
Learn how to create a b-tree index in Postgres. No yardwork required!
Transactions
Learn why and how to use transactions.
Basics of PostGIS
Test some sample spatial queries and functions with PostGIS!
Partitioning
Learn how to create partitions with native Postgres and pg_partman with an IoT sample dataset.
Basics of JSON
Learn JSON interactions including manipulating, querying, saving, and optimizing a simple object structure.
High level performance analysis
A quick introduction to some of the most important Postgres performance metrics. Including cache hit ratio, index hit, and bloat.
Query performance analytics
A tutorial for how to find your least performant queries and a lot more query performance information
Casting Data Types
Learn about casting data types with in-depth examples for time intervals and date and time formats.
CTEs and Window Functions
Learn how to query data with US Birth data.
Percentage Calculations
Learn how to do percentage calculations in Postgres in one pass.
Strings to Arrays
Learn about the unnest(array) function and how to break about data from a csv in a csv.
Custom data types: DOMAINS
Learn about user-defined datatypes, domain types, and how to create constraints that validate values.
Custom data types : user defined types
Hands on examples for composite types, enumerated types, and range types.
Using FILTER vs CTEs and CASE WHEN
When aggregating based on status, try using FILTER instead of CASE statements.
PostgreSQL - Just for Kids
Intro to SQL tutorial for kids. This is a hands on tutorial using an existing Postgres database running in a web browser.
Advent of Code - Day 1
We’re publishing a few days to do Advent of Code challenges in SQL. Day 1 makes use of sequences and sum over ranges.
Advent of Code - Day 2
SQL Solutions for Day 2 of Advent of Code. This one has some functions to find out who’s the winner of each battle and summing the wins.
Advent of Code - Day 3
SQL Solutions for Day 3 of Advent of Code. This one includes functions for length(), left(), right(), regexp_replace(), COLLATE commands, window function lag(), and more.
Advent of Code - Day 4
SQL Solutions for Day 4 of Advent of Code. This one includes the function split_part(), the int4range data type, and range operators.
Advent of Code - Day 5
SQL Solutions for Day 5 of Advent of Code. This one includes the function split_part(), the int4range data type, and range operators.
Advent of Code - Day 6
SQL Solutions for Day 6 of Advent of Code. This one includes regexp_split_to_table, strpos, lag() functions and COUNT(DISTINCT). Also, a great example of using a DO function with RAISE NOTICE.
Advent of Code - Day 7
SQL Solutions for Day 7 of Advent of Code. This one includes recursive queries, text arrays, and tons of Postgres functions.
Advent of Code - Day 8
SQL Solutions for Day 8 of Advent of Code. This one includes plpgsql, row_number window functions, sequences, and regexp_split_to_table.
Advent of Code - Day 9
SQL Solutions for Day 8 of Advent of Code. This one includes plpgsql, row_number window functions, sequences, and regexp_split_to_table.
Advent of Code - Day 10
SQL Solutions for Day 9 of Advent of Code. This one uses sequences and the OVER() function..
Advent of Code - Day 16
SQL Solutions for Day 16 of Advent of Code. This one calls a plpgsql function recursively
Advent of Code - Day 12
Day 12 of AOC we have new hands on SQL for the Hill Climbing Algorithm. This one uses parsing, an IDENTITY column, functions, and text arrays.
Advent of Code - Day 11
Day 11 of AOC we have new hands on SQL for playing Monkey in the Middle. This one uses sequences, string functions, and window functions.
Advent of Code - Day 13
Day 13 of AOC we have new hands on SQL for the Distress Signal. This one uses lag(), sequencing, regexp_replace(), and overlay().
Advent of Code - Day 15
Day 15 of AOC we have new hands on SQL for the Beacon Exclusion Zone. This one uses CTEs, sequences, regexp_substr() / regexp_match(), int4range, range_agg(), and an upsert.
Advent of Code - Day 14
Day 14 of AOC we have new hands on SQL for the Regolith Reservoir. This one uses lag(), sequences, string_to_table(), split_part(), and generate_series().
Tags and Postgres Arrays, a Purrrfect Combination
Review some of the ways to store tags in a database from basic relational models to text arrays. This tutorial has data models, performance tests, sample queries, and guidance on choosing the best path.
Working with Time in Postgres
A primer on working with time in Postgres. Covers data types, query formats, intervals, overlaps, indexing, and roll ups.
SQL Tricks for More Effective CRUD
A quick tutorial of some simple and not-so-simple CRUD - create, read, update, and delete.