BRIN minmax-multi indexes
authorTomas Vondra <tomas.vondra@postgresql.org>
Fri, 26 Mar 2021 12:54:29 +0000 (13:54 +0100)
committerTomas Vondra <tomas.vondra@postgresql.org>
Fri, 26 Mar 2021 12:54:30 +0000 (13:54 +0100)
commitab596105b55f1d7fbd5a66b66f65227d210b047d
treeba03f65e68913c0a684e9483a0c43e0df0229ee3
parent77b88cd1bb9041a735f24072150cacfa06c699a3
BRIN minmax-multi indexes

Adds BRIN opclasses similar to the existing minmax, except that instead
of summarizing the page range into a single [min,max] range, the summary
consists of multiple ranges and/or points, allowing gaps. This allows
more efficient handling of data with poor correlation to physical
location within the table and/or outlier values, for which the regular
minmax opclassed tend to work poorly.

It's possible to specify the number of values kept for each page range,
either as a single point or an interval boundary.

  CREATE TABLE t (a int);
  CREATE INDEX ON t
   USING brin (a int4_minmax_multi_ops(values_per_range=16));

When building the summary, the values are combined into intervals with
the goal to minimize the "covering" (sum of interval lengths), using a
support procedure computing distance between two values.

Bump catversion, due to various catalog changes.

Author: Tomas Vondra <tomas.vondra@postgresql.org>
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
Reviewed-by: Sokolov Yura <y.sokolov@postgrespro.ru>
Reviewed-by: John Naylor <john.naylor@enterprisedb.com>
Discussion: https://postgr.es/m/c1138ead-7668-f0e1-0638-c3be3237e812@2ndquadrant.com
Discussion: https://postgr.es/m/5d78b774-7e9c-c94e-12cf-fef51cc89b1a%402ndquadrant.com
19 files changed:
doc/src/sgml/brin.sgml
src/backend/access/brin/Makefile
src/backend/access/brin/brin_minmax_multi.c [new file with mode: 0644]
src/backend/access/brin/brin_tuple.c
src/include/access/brin_tuple.h
src/include/access/transam.h
src/include/catalog/catversion.h
src/include/catalog/pg_amop.dat
src/include/catalog/pg_amproc.dat
src/include/catalog/pg_opclass.dat
src/include/catalog/pg_opfamily.dat
src/include/catalog/pg_proc.dat
src/include/catalog/pg_type.dat
src/test/regress/expected/brin_multi.out [new file with mode: 0644]
src/test/regress/expected/psql.out
src/test/regress/expected/type_sanity.out
src/test/regress/parallel_schedule
src/test/regress/serial_schedule
src/test/regress/sql/brin_multi.sql [new file with mode: 0644]