Re: Do BRIN indexes support MIN/MAX? - Mailing list pgsql-general

From Vladimir Sitnikov
Subject Re: Do BRIN indexes support MIN/MAX?
Date
Msg-id CAB=Je-GsYgM0Qd9AmsJ3ZU=qrPcOc_3XGUfhcwprMEzJfSnQwA@mail.gmail.com
Whole thread Raw
In response to Do BRIN indexes support MIN/MAX?  (Andrey Klochkov <diggerk@gmail.com>)
Responses Re: Do BRIN indexes support MIN/MAX?
List 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

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Using CTID system column as a "temporary" primary key
Next
From: Alban Hertroys
Date:
Subject: Re: Using CTID system column as a "temporary" primary key