Re: Do BRIN indexes support MIN/MAX?

From: Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>
To: Andrey Klochkov <diggerk(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Do BRIN indexes support MIN/MAX?
Date: 2023-03-29 20:06:59
Message-ID: CAB=Je-GsYgM0Qd9AmsJ3ZU=qrPcOc_3XGUfhcwprMEzJfSnQwA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Is it correct that BRIN indexes don't support MIN/MAX operations ?

In theory, it should be possible to implement min/max scan support for
BRIN, however it is not implemented yet.

Just in case, min/max query would require to read all BRIN pages, and then
it would require to read the corresponding pages in table.

For instance, imagine the table has N pages. Then BRIN would have N/128
pages with the default pages_per_range=128, so your max(..) query would
take N/128 + 128 pages to read. In theory it would be sequential, however,
under concurrent load it might not be that sequential for the disk.

For instance, 80GiB table would be like 10’000’000 pages, so the default
BRIN would take about 78’000 pages (625MiB), so the min/max scan would read
626 MiB
If pages per range is increased to ~3162, then index size would be ~3162
pages (25MiB), and each index entry would cover 25MiB range. Then the query
would have to read ~50MiB to fetch min/max. It is not clear if that is
really practical though.

What are you data volumes and expectations by the way?

Vladimir

--
Vladimir

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2023-03-29 20:15:48 Re: Using CTID system column as a "temporary" primary key
Previous Message Adrian Klaver 2023-03-29 19:23:32 Re: Using CTID system column as a "temporary" primary key