Re: Aggregate not using BRIN index on timestamp

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Jeremy Finzel <finzelj(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Aggregate not using BRIN index on timestamp
Date: 2019-08-05 15:42:38
Message-ID: 20190805154238.GA7309@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2019-Aug-05, Jeremy Finzel wrote:

> Thanks Tom. So, this is a very general question, but would it be possible
> to develop that feature into BRIN, given what it stores? Even if it does
> not have ordering information, doesn't it know which blocks would contain
> the lowest values, so it could choose to do a "bitmap scan ordered sort" or
> something, depending on the number of rows sought? Or is the problem that
> it has no way of determining what value actually would be the "minimum"
> without the query specifying a particular date, such as less than
> "2013-04-01"?

For btrees, we have planagg.c which transforms min() and max() into
subqueries (SELECT .. WHERE ... ORDER BY .. LIMIT 1).

In a BRIN index, you could execute the search by scanning the index to
determine which ranges contain the least/greatest values, and then using
a bitmap scan to scan those. I'm not sure that this is a transformation
that can be applied cleanly, since that thing I describe doesn't look to
be a "subquery". But maybe it can -- I think you'd need a special
executor node.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2019-08-05 15:53:47 Re: Aggregate not using BRIN index on timestamp
Previous Message Julie Nishimura 2019-08-05 15:27:57 Re: adding more space to the existing server