Re: Daterange question

2024-01-19 Thread Andreas Joseph Krogh
På lørdag 20. januar 2024 kl. 06:35:07, skrev Tom Lane mailto:t...@sss.pgh.pa.us>>: […] 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 opera

Re: Daterange question

2024-01-19 Thread Tom Lane
Adrian Klaver 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 EX

Re: Daterange question

2024-01-19 Thread Andreas Joseph Krogh
create table order_line ( id serial primary key, start_date DATE NOT NULL, end_date DATE, drange daterange NOT NULL GENERATED ALWAYS AS (daterange(start_date, end_date, '[)')) STORED ); CREATE INDEX order_line_not_end_idx ON order_line using gist(drange); INSERT INTO order_line(start_date, end

Re: Daterange question

2024-01-19 Thread Adrian Klaver
On 1/19/24 20:08, Andreas Joseph Krogh wrote: I have order-lines with start-end like this: |start_date DATE NOT NULL, end_date DATE, drange daterange NOT NULL GENERATED ALWAYS AS (daterange(start_date, end_date, '[)')) STORED| and have an index on |using gist(drange)| I want to list all orde

Daterange question

2024-01-19 Thread Andreas Joseph Krogh
I have order-lines with start-end like this: start_date DATE NOT NULL, end_date DATE, drange daterange NOT NULL GENERATED ALWAYS AS (daterange(start_date, end_date, '[)')) STORED and have an index on using gist(drange) I want to list all order-lines which does not have end-date set in the pas