Re: Overlapping timestamptz ranges with priority

Поиск
Список
Период
Сортировка
От Ray O'Donnell
Тема Re: Overlapping timestamptz ranges with priority
Дата
Msg-id 4244dbae-6387-0d3c-0862-c4c72e71af3c@rodonnell.ie
обсуждение исходный текст
Ответ на Re: Overlapping timestamptz ranges with priority  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: Overlapping timestamptz ranges with priority  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
On 29/06/2021 20:43, Adrian Klaver wrote:
> 
> An ounce of prevention is worth a pound of cure:
> 
> 1) Install btree_gist
> create extension btree_gist ;
> 
> 2) create table bookings (
>      booking_id bigint not null,
>      aircraft_id integer,
>      booking_time_start timestamptz,
>      booking_time_end timestamptz,
> 
>      constraint bookings_pk primary key (booking_id),
>      constraint timestamp_exclude EXCLUDE USING gist
>          (aircraft_id WITH =,
>           tstzrange(booking_time_start, booking_time_end, '[]') WITH &&)

[...]

> This way the overlap is prevented and you don't have to deal with it later.

Fair point.... The idea of using overlapping ranges was to allow for 
queued bookings, which is something we permit. In the old system (which 
this one is to replace) queued bookings are kept in a separate table. My 
idea was to have them in a single table, which would seem more elegant - 
but by golly it's harder! Maybe I should rethink my approach.

Thanks,

Ray.


-- 
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie



В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Overlapping timestamptz ranges with priority
Следующее
От: George Tarasov
Дата:
Сообщение: PGDLLIMPORT: patch or not to patch