Postgres Playground

Enhance your Postgres skills

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.

Learn SQL

Learn about the basics of SQL

Joins in Postgres

Learn about inner and outer joins in this tutorial

psql Echo Commands

Learn about -E, -echo-hidden, -e, -echo-queries in the Postgres command line interface, psql

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 with an IoT sample dataset.

Creating Tables

Learn the basics of Postgres table creation, with primary keys, foreign keys, and data types.

Row Level Security

Learn how to use Postgres’ Row Level Security functionality. It’s a great tool for managing key-based partitioning in a multi-tenant world.

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.

Postgres Users and Roles

Learn about creating Postgres user roles, role groups, and login and password details for users.

Window Functions for Data Analysis

Walk through sample Window functions with and without CTEs for running totals, rolling averages, first and last values, lag and lead, ranking, and ntiles.

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.

Postgres Contraints

This tutorial shows you how to create foreign keys, work with cascading deletes, not-null constraints, check constraints, and exclusion constraints. Also, examples for time-based check constraints and box based exclusion constraints.

Postgres Functions for Rolling Up Data by Date

Sample code and tutorial for using Postgres intervals, date_trunc, rollup, cube and formatting output with to_char.

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.

Materialized Views

Create a basic materialized view using a sample ecommerce data set.

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.

Working with Time in Postgres

A primer on working with time in Postgres. Covers data types, query formats, intervals, overlaps, indexing, and roll ups.

Custom data types: DOMAINS

Learn about user-defined datatypes, domain types, and how to create constraints that validate values.

Working with Money in Postgres

A primer for working with money in Postgres including what data type to choose, storing currency, and some sample functions.

Custom data types : user defined types

Hands on examples for composite types, enumerated types, and range types.

Summaries with Aggregate Filters and Windows

Aggregate filtering with window functions to strip out just the information you want

Using FILTER vs CTEs and CASE WHEN

When aggregating based on status, try using FILTER instead of CASE statements.

SQL Tricks for More Effective CRUD

A quick tutorial of some simple and not-so-simple CRUD - create, read, update, and delete.

LATERAL JOIN

“This is a perfect scenario for a lateral join!” Have you ever heard that? If you were wondering “what’s a lateral join?” This will help. It’s pretty simple, but the combination of it with other SQL capabilities is quite powerful.

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.