From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Andreas Joseph Krogh <andreas(at)visena(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Daterange question |
Date: | 2024-01-20 05:13:20 |
Message-ID: | 253fb378-5d21-4605-a444-9338990253a2@aklaver.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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 order-lines which does not have end-date set in the
> past, but want to show lines with start-dates in future.
>
> 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.
>
> Thanks.
>
> --
> *Andreas Joseph Krogh*
> CTO / Partner - Visena AS
> Mobile: +47 909 56 963
> andreas(at)visena(dot)com <mailto:andreas(at)visena(dot)com>
> www.visena.com <https://www.visena.com>
> <https://www.visena.com>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Joseph Krogh | 2024-01-20 05:28:15 | Re: Daterange question |
Previous Message | Andreas Joseph Krogh | 2024-01-20 04:08:43 | Daterange question |