pgsql: BRIN: Block Range Indexes

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: BRIN: Block Range Indexes
Date: 2014-11-07 19:43:23
Message-ID: E1XmpRL-0001Zh-Sd@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2014-11-07 20:08:56 pgsql: Fix serial schedule
Previous Message Heikki Linnakangas 2014-11-07 19:19:44 pgsql: Fix generation of SP-GiST vacuum WAL records.