Constraints
CREATE TABLE ... with an inline EXCLUDE constraint
Lock mode SHARE ROW EXCLUSIVE
Risk LOW
Blocks writes, other DDL
pgfence rule
create-table-exclude-constraint CREATE TABLE reservations (room_id int, during tstzrange, EXCLUDE USING gist (room_id WITH =, during WITH &&)); What this does
Building the exclusion constraint on a brand-new, empty table during CREATE TABLE is not a risk: there is no existing data to scan and no concurrent traffic on a table that does not exist yet.