Showcasing the lag
Postgres function which is a part of Postgres' windowing support.
Specifically, I wanted to illustrate a query where each row needs to be compared to the row preceding it.
Follow these instructions to explore the windowing feature in Postgres.
- Start the Postgres server
- Use whatever method you prefer: HomeBrew, Docker, etc. Depending on how you install it, the username and database
name will differ so take care to adjust the
psql
commands accordingly.
- Use whatever method you prefer: HomeBrew, Docker, etc. Depending on how you install it, the username and database
name will differ so take care to adjust the
- Apply the schema:
-
psql -f snapshots-schema.ddl
-
- Insert test data:
-
psql -f snapshots-data.sql
-
- Try out the queries
snapshots-explore.sql
and learn aboutlag
!