Re: BRIN indexes for MAX, MIN, ORDER BY? - Mailing list pgsql-hackers

From Simon Riggs
Subject Re: BRIN indexes for MAX, MIN, ORDER BY?
Date
Msg-id CANP8+jJ0Z2c3LNY4Lne+OkpxN1yasy-cHDbAXSJ==7iY9MvrDA@mail.gmail.com
Whole thread Raw
In response to Re: BRIN indexes for MAX, MIN, ORDER BY?  (Jeremy Harris <jgh@wizmail.org>)
List pgsql-hackers
On 29 September 2015 at 13:20, Jeremy Harris <jgh@wizmail.org> wrote:
On 27/09/15 21:58, Gavin Wahl wrote:
> Somewhat harder but still possible would be using BRIN indexes to
> accelerate ORDER BY. This would require a sorting algorithm that can take
> advantage of mostly-sorted inputs. You would sort the page ranges by their
> minimum or maximum value, then feed the sorting algorithm in that order.

An internal merge sort does well with partially-sorted input.

Yes, the $SUBJECT would be a valid use for BRIN.

And also in general for sorts, leading to an optimization of merge joins using BRIN indexes.

All this was foreseen in the original design; if it really was trivial it would be in 9.5 already...

--
Simon Riggs                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: On-demand running query plans using auto_explain and signals
Next
From: Tom Lane
Date:
Subject: Idea for improving buildfarm robustness