From: | Andreas Joseph Krogh <andreas(at)visena(dot)com> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Daterange question |
Date: | 2024-01-20 04:08:43 |
Message-ID: | VisenaEmail.2.c34e09422a661ed9.18d2509f980@origo-test01.app.internal.visena.net |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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?
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>
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2024-01-20 05:13:20 | Re: Daterange question |
Previous Message | Ron Johnson | 2024-01-19 21:36:00 | Re: B-tree index balance? |