pgsql: BRIN: Block Range Indexes

Started by Alvaro Herreraover 11 years ago4 messagescomitters
Jump to latest
#1Alvaro Herrera
alvherre@2ndquadrant.com

BRIN: Block Range Indexes

BRIN is a new index access method intended to accelerate scans of very
large tables, without the maintenance overhead of btrees or other
traditional indexes. They work by maintaining "summary" data about
block ranges. Bitmap index scans work by reading each summary tuple and
comparing them with the query quals; all pages in the range are returned
in a lossy TID bitmap if the quals are consistent with the values in the
summary tuple, otherwise not. Normal index scans are not supported
because these indexes do not store TIDs.

As new tuples are added into the index, the summary information is
updated (if the block range in which the tuple is added is already
summarized) or not; in the latter case, a subsequent pass of VACUUM or
the brin_summarize_new_values() function will create the summary
information.

For data types with natural 1-D sort orders, the summary info consists
of the maximum and the minimum values of each indexed column within each
page range. This type of operator class we call "Minmax", and we
supply a bunch of them for most data types with B-tree opclasses.
Since the BRIN code is generalized, other approaches are possible for
things such as arrays, geometric types, ranges, etc; even for things
such as enum types we could do something different than minmax with
better results. In this commit I only include minmax.

Catalog version bumped due to new builtin catalog entries.

There's more that could be done here, but this is a good step forwards.

Loosely based on ideas from Simon Riggs; code mostly by Álvaro Herrera,
with contribution by Heikki Linnakangas.

Patch reviewed by: Amit Kapila, Heikki Linnakangas, Robert Haas.
Testing help from Jeff Janes, Erik Rijkers, Emanuel Calvo.

PS:
The research leading to these results has received funding from the
European Union's Seventh Framework Programme (FP7/2007-2013) under
grant agreement n° 318633.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/7516f5259411c02ae89e49084452dc342aadb2ae

Modified Files
--------------
contrib/pageinspect/Makefile | 5 +-
contrib/pageinspect/brinfuncs.c | 414 +++++++++
contrib/pageinspect/pageinspect--1.2--1.3.sql | 43 +
contrib/pageinspect/pageinspect--1.2.sql | 107 ---
contrib/pageinspect/pageinspect--1.3.sql | 146 +++
contrib/pageinspect/pageinspect.control | 2 +-
contrib/pg_xlogdump/rmgrdesc.c | 1 +
doc/src/sgml/brin.sgml | 490 ++++++++++
doc/src/sgml/filelist.sgml | 1 +
doc/src/sgml/indices.sgml | 36 +-
doc/src/sgml/pageinspect.sgml | 104 +++
doc/src/sgml/postgres.sgml | 1 +
src/backend/access/Makefile | 2 +-
src/backend/access/brin/Makefile | 18 +
src/backend/access/brin/README | 189 ++++
src/backend/access/brin/brin.c | 1228 +++++++++++++++++++++++++
src/backend/access/brin/brin_minmax.c | 341 +++++++
src/backend/access/brin/brin_pageops.c | 723 +++++++++++++++
src/backend/access/brin/brin_revmap.c | 510 ++++++++++
src/backend/access/brin/brin_tuple.c | 554 +++++++++++
src/backend/access/brin/brin_xlog.c | 291 ++++++
src/backend/access/common/reloptions.c | 7 +
src/backend/access/heap/heapam.c | 22 +-
src/backend/access/rmgrdesc/Makefile | 3 +-
src/backend/access/rmgrdesc/brindesc.c | 112 +++
src/backend/access/transam/rmgr.c | 1 +
src/backend/catalog/index.c | 24 +
src/backend/replication/logical/decode.c | 1 +
src/backend/storage/page/bufpage.c | 179 +++-
src/backend/utils/adt/selfuncs.c | 74 +-
src/include/access/brin.h | 52 ++
src/include/access/brin_internal.h | 88 ++
src/include/access/brin_page.h | 70 ++
src/include/access/brin_pageops.h | 36 +
src/include/access/brin_revmap.h | 39 +
src/include/access/brin_tuple.h | 96 ++
src/include/access/brin_xlog.h | 109 +++
src/include/access/heapam.h | 2 +
src/include/access/reloptions.h | 3 +-
src/include/access/relscan.h | 4 +-
src/include/access/rmgrlist.h | 1 +
src/include/catalog/catversion.h | 2 +-
src/include/catalog/index.h | 8 +
src/include/catalog/pg_am.h | 2 +
src/include/catalog/pg_amop.h | 164 ++++
src/include/catalog/pg_amproc.h | 245 +++++
src/include/catalog/pg_opclass.h | 32 +
src/include/catalog/pg_opfamily.h | 28 +
src/include/catalog/pg_proc.h | 39 +
src/include/storage/bufpage.h | 2 +
src/include/utils/selfuncs.h | 1 +
src/test/regress/expected/brin.out | 179 ++++
src/test/regress/expected/opr_sanity.out | 14 +-
src/test/regress/output/misc.source | 4 +-
src/test/regress/parallel_schedule | 2 +-
src/test/regress/serial_schedule | 1 +
src/test/regress/sql/brin.sql | 184 ++++
src/test/regress/sql/opr_sanity.sql | 7 +-
58 files changed, 6913 insertions(+), 130 deletions(-)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#2Peter Eisentraut
peter_e@gmx.net
In reply to: Alvaro Herrera (#1)
Re: pgsql: BRIN: Block Range Indexes

This fails cplusplucheck:

./src/include/access/brin_xlog.h:79:17: error: expected unqualified-id
before ‘new’

"new" is a reserved word in C++, so you can't have it in a header file.

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#3Thom Brown
thom@linux.com
In reply to: Alvaro Herrera (#1)
Re: pgsql: BRIN: Block Range Indexes

On 7 November 2014 19:43, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

BRIN: Block Range Indexes

...

doc/src/sgml/brin.sgml | 490 ++++++++++

Here's a typo correction:

   The core <productname>PostgreSQL</productname> distribution includes
-  includes the <acronym>BRIN</acronym> operator classes shown in
+  the <acronym>BRIN</acronym> operator classes shown in
   <xref linkend="brin-builtin-opclasses-table">.

Thom

#4Amit Langote
Langote_Amit_f8@lab.ntt.co.jp
In reply to: Alvaro Herrera (#1)
Re: pgsql: BRIN: Block Range Indexes

On Sat, Nov 8, 2014 at 4:43 AM, Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:

src/backend/access/brin/README | 189 ++++

A minor typo:

+Summarization
+-------------

<snip>

+
+Wehn VACUUM is run on the table, all unsummarized page ranges are

s/Wehn/When/

Thanks,
Amit

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers