# btree_gist — Postgres extension

> GiST indexes over plain columns, for exclusion constraints.

Source: https://scribase.com/extensions/btree_gist

Category: Text search and indexing. Version: 1.7. Optional, enabled per project.

## About

btree_gist lets GiST indexes include scalar columns. Its main use is exclusion constraints that combine equality with range overlap, such as "the same room cannot be booked twice for overlapping times", enforced by the database itself.

## Enable it

```sql
create extension if not exists btree_gist with schema extensions;
```

## Example

```sql
create table bookings (
  room_id int not null,
  during tstzrange not null,
  exclude using gist (room_id with =, during with &&)
);

-- the second insert fails with SQLSTATE 23P01 (exclusion_violation)
insert into bookings values (1, '[2026-10-08 10:00, 2026-10-08 11:00)');
insert into bookings values (1, '[2026-10-08 10:30, 2026-10-08 12:00)');
```

Upstream: https://www.postgresql.org/docs/17/btree-gist.html