pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Jeremy Finzel <finzelj@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: Aggregate not using BRIN index on timestamp
Date: Mon, 5 Aug 2019 11:42:38 -0400
Message-ID: <20190805154238.GA7309@alvherre.pgsql> (raw)
In-Reply-To: <CAMa1XUh4zy8uSLjQMH3UH_=bW84meeEduAci+_o2w_-paLgKRA@mail.gmail.com>

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





view thread (7+ messages)  latest in thread

Message-ID: <20190805154238.GA7309@alvherre.pgsql>
Permalink:  ../20190805154238.GA7309@alvherre.pgsql/
Also on:    postgresql.org/message-id/20190805154238.GA7309@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: alvherre@2ndquadrant.com, finzelj@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: Aggregate not using BRIN index on timestamp
  In-Reply-To: <20190805154238.GA7309@alvherre.pgsql>
  References: <CAMa1XUh4zy8uSLjQMH3UH_=bW84meeEduAci+_o2w_-paLgKRA@mail.gmail.com> <20190805154238.GA7309@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox