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

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

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,

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

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

Re: B-tree index balance?

2024-01-19 Thread Ron Johnson
On Fri, Jan 19, 2024 at 11:37 AM Tom Lane wrote: > Ron Johnson writes: > > On an RDMS which I used in the 1990s and 2000s, b-tree indices of > sequences > > would get unbalanced, since every new leaf was added to the far right > > corner of the tree. > > Sure, they would auto-balance *to a

Re: B-tree index balance?

2024-01-19 Thread Tom Lane
Ron Johnson writes: > On an RDMS which I used in the 1990s and 2000s, b-tree indices of sequences > would get unbalanced, since every new leaf was added to the far right > corner of the tree. > Sure, they would auto-balance *to a degree* during node splits, but all > those "far-right corner"

B-tree index balance?

2024-01-19 Thread Ron Johnson
On an RDMS which I used in the 1990s and 2000s, b-tree indices of sequences would get unbalanced, since every new leaf was added to the far right corner of the tree. Sure, they would auto-balance *to a degree* during node splits, but all those "far-right corner" inserts still left them pretty

Re: Explain and filter over subplans

2024-01-19 Thread Chantal Keller
Thank you very much for your quick answer and patch! I tested and this is exactly what I was looking for :-) Best Chantal Le 18/01/2024 à 18:55, Tom Lane a écrit : Chantal Keller writes: I would like "explain" to output formulas for filtering over subplans. Is it possible? No, and