Re: Daterange question

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Daterange question
Дата
Msg-id 2922215.1705728907@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Daterange question  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: Daterange question
Список pgsql-general
Adrian Klaver <adrian.klaver@aklaver.com> writes:
> On 1/19/24 20:08, Andreas Joseph Krogh wrote:
>> This seems to do what I want:
>> |NOT (drange << daterange(CURRENT_DATE, NULL, '[)'))|
>> But this doesn't use the index.
>> Any idea how to write a query so it uses the index on |drange|?

> Without the full query and the EXPLAIN output I don't see that there is 
> much that can be offered in way of an answer.

Well, we can definitively state that the NOT makes this unindexable.
You need a WHERE clause that looks like
    indexed-column indexable-operator pseudo-constant
which this isn't, nor does << have a negator operator that could
allow the NOT to be simplified out.

Wouldn't
    drange && daterange(CURRENT_DATE, NULL, '[)')
serve the purpose?  That should be indexable.

            regards, tom lane



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

Предыдущее
От: Andreas Joseph Krogh
Дата:
Сообщение: Re: Daterange question
Следующее
От: Andreas Joseph Krogh
Дата:
Сообщение: Re: Daterange question