PostgreSQL 18 and 19 are adding native temporal database capabilities. PostgreSQL 18 introduced temporal primary and unique keys using the WITHOUT OVERLAPS clause and temporal foreign keys using the PERIOD clause, enforced via GiST indexes through the btree_gist extension. PostgreSQL 19 Beta 1 adds UPDATE/DELETE ... FOR PORTION OF, enabling surgical modification of application-time history while automatically preserving unaffected time periods. The post explains valid time vs. transaction time semantics, demonstrates the booking/room scheduling use case with concrete DDL and queries, and maps PostgreSQL's current temporal feature coverage against SQL:2011 standards — noting that system-versioned tables and FOR SYSTEM_TIME AS OF syntax are still missing.

10m read timeFrom postgr.es
Post cover image
Table of contents
What makes a database temporalWhy temporal mattersTemporal PRIMARY KEY and UNIQUE constraintsTemporal FOREIGN KEY constraintsWant to learn more?
353 Impressions