]> granicus.if.org Git - postgresql/commit
BRIN: Block Range Indexes
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 7 Nov 2014 19:38:14 +0000 (16:38 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 7 Nov 2014 19:38:14 +0000 (16:38 -0300)
commit7516f5259411c02ae89e49084452dc342aadb2ae
treee1c84a6dacca20c8070823b26cbaa30c24670b1f
parent1961b1c131e4211f3dc86ff2be971e430ab2a23d
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.
57 files changed:
contrib/pageinspect/Makefile
contrib/pageinspect/brinfuncs.c [new file with mode: 0644]
contrib/pageinspect/pageinspect--1.2--1.3.sql [new file with mode: 0644]
contrib/pageinspect/pageinspect--1.3.sql [moved from contrib/pageinspect/pageinspect--1.2.sql with 71% similarity]
contrib/pageinspect/pageinspect.control
contrib/pg_xlogdump/rmgrdesc.c
doc/src/sgml/brin.sgml [new file with mode: 0644]
doc/src/sgml/filelist.sgml
doc/src/sgml/indices.sgml
doc/src/sgml/pageinspect.sgml
doc/src/sgml/postgres.sgml
src/backend/access/Makefile
src/backend/access/brin/Makefile [new file with mode: 0644]
src/backend/access/brin/README [new file with mode: 0644]
src/backend/access/brin/brin.c [new file with mode: 0644]
src/backend/access/brin/brin_minmax.c [new file with mode: 0644]
src/backend/access/brin/brin_pageops.c [new file with mode: 0644]
src/backend/access/brin/brin_revmap.c [new file with mode: 0644]
src/backend/access/brin/brin_tuple.c [new file with mode: 0644]
src/backend/access/brin/brin_xlog.c [new file with mode: 0644]
src/backend/access/common/reloptions.c
src/backend/access/heap/heapam.c
src/backend/access/rmgrdesc/Makefile
src/backend/access/rmgrdesc/brindesc.c [new file with mode: 0644]
src/backend/access/transam/rmgr.c
src/backend/catalog/index.c
src/backend/replication/logical/decode.c
src/backend/storage/page/bufpage.c
src/backend/utils/adt/selfuncs.c
src/include/access/brin.h [new file with mode: 0644]
src/include/access/brin_internal.h [new file with mode: 0644]
src/include/access/brin_page.h [new file with mode: 0644]
src/include/access/brin_pageops.h [new file with mode: 0644]
src/include/access/brin_revmap.h [new file with mode: 0644]
src/include/access/brin_tuple.h [new file with mode: 0644]
src/include/access/brin_xlog.h [new file with mode: 0644]
src/include/access/heapam.h
src/include/access/reloptions.h
src/include/access/relscan.h
src/include/access/rmgrlist.h
src/include/catalog/catversion.h
src/include/catalog/index.h
src/include/catalog/pg_am.h
src/include/catalog/pg_amop.h
src/include/catalog/pg_amproc.h
src/include/catalog/pg_opclass.h
src/include/catalog/pg_opfamily.h
src/include/catalog/pg_proc.h
src/include/storage/bufpage.h
src/include/utils/selfuncs.h
src/test/regress/expected/brin.out [new file with mode: 0644]
src/test/regress/expected/opr_sanity.out
src/test/regress/output/misc.source
src/test/regress/parallel_schedule
src/test/regress/serial_schedule
src/test/regress/sql/brin.sql [new file with mode: 0644]
src/test/regress/sql/opr_sanity.sql