Search Postgresql Archives

Re: Daterange question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Adrian Klaver <adrian.klaver@xxxxxxxxxxx> 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





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux