Re: performance problems with bulk inserts/updates on tsrange with gist-based exclude constrains

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: performance problems with bulk inserts/updates on tsrange with gist-based exclude constrains
Дата
Msg-id CAMkU=1zgVjQZMUikVZg9=0M7E9k-s=aWN8EHtqkAbPdo4cukcw@mail.gmail.com
обсуждение исходный текст
Ответ на performance problems with bulk inserts/updates on tsrange with gist-based exclude constrains  (Chris Withers <chris@simplistix.co.uk>)
Ответы Re: performance problems with bulk inserts/updates on tsrange with gist-based exclude constrains  (pinker <pinker@onet.eu>)
Список pgsql-general
On Fri, Sep 16, 2016 at 2:01 AM, Chris Withers <chris@simplistix.co.uk> wrote:
Hi All,

I have quite a few tables that follow a pattern like this:

         Table "public.my_model"
  Column |       Type        | Modifiers
--------+-------------------+-----------
  period | tsrange           | not null
  key    | character varying | not null
  value  | integer           |
Indexes:
     "my_model_pkey" PRIMARY KEY, btree (period, key)
     "my_model_period_key_excl" EXCLUDE USING gist (period WITH &&, key WITH =)
Check constraints:
     "my_model_period_check" CHECK (period <> 'empty'::tsrange)

Try swapping the order of the columns in the exclude constraint.  You want the more selective criterion to appear first in the index/constraint.  Presumably "key with =" is the most selective, especially if many of your periods are unbounded.

Cheers,

Jeff

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

Предыдущее
От: Paul Jungwirth
Дата:
Сообщение: Re: journaling / time travel
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: Index scan is not working