Re: [HACKERS] WIP: BRIN multi-range indexes

2017-10-30 Thread Tomas Vondra
Hi,

attached is a patch series that includes both the BRIN multi-range
minmax indexes discussed in this thread, and the BRIN bloom indexes
initially posted in [1].

It seems easier to just deal with a single patch series, although we may
end up adding just one of those proposed opclasses.

There are 4 parts:

0001 - Modifies bringetbitmap() to pass all scan keys to the consistent
function at once. This is actually needed by the multi-minmax indexes,
but not really required for the others.

I'm wondering if this is a safechange, considering it affects the BRIN
interface. I.e. custom BRIN opclasses (perhaps in extensions) will be
broken by this change. Maybe we should extend the BRIN API to support
two versions of the consistent function - one that processes scan keys
one by one, and the other one that processes all of them at once.

0002 - Adds BRIN bloom indexes, along with opclasses for all built-in
data types (or at least those that also have regular BRIN opclasses).

0003 - Adds BRIN multi-minmax indexes, but only with float8 opclasses
(which also includes timestamp etc.). That should be good enough for
now, but adding support for other data types will require adding some
sort of "distance" operator which is needed for merging ranges (to pick
the two "closest" ones). For float8 it's simply a subtraction.

0004 - Moves dealing with IS [NOT] NULL search keys from opclasses to
bringetbitmap(). The code was exactly the same in all opclasses, so
moving it to bringetbitmap() seems right. It also allows some nice
optimizations where we can skip the consistent() function entirely,
although maybe that's useless. Also, maybe the there are opclasses that
actually need to deal with the NULL values in consistent() function?


regards


[1]
https://www.postgresql.org/message-id/5d78b774-7e9c-c94e-12cf-fef51cc89b1a%402ndquadrant.com

-- 
Tomas Vondra  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


0001-Pass-all-keys-to-BRIN-consistent-function-at-once.patch.gz
Description: application/gzip


0002-BRIN-bloom-indexes.patch.gz
Description: application/gzip


0003-BRIN-multi-range-minmax-indexes.patch.gz
Description: application/gzip


0004-Move-IS-NOT-NULL-checks-to-bringetbitmap.patch.gz
Description: application/gzip

-- 
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] WIP: BRIN multi-range indexes

2017-10-25 Thread Tomas Vondra
Apparently I've managed to botch the git format-patch thing :-( Attached
are both patches (the first one adding BRIN bloom indexes, the other one
adding the BRIN multi-range). Hopefully I got it right this time ;-)

regards

-- 
Tomas Vondra  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From c27f02d2839e08ebcee852448ed3838c8932d2ea Mon Sep 17 00:00:00 2001
From: Tomas Vondra 
Date: Mon, 23 Oct 2017 22:48:58 +0200
Subject: [PATCH 1/2] brin bloom v1

---
 doc/src/sgml/brin.sgml   | 236 ++
 src/backend/access/brin/Makefile |   2 +-
 src/backend/access/brin/brin_bloom.c | 727 +++
 src/include/catalog/pg_amop.h|  59 +++
 src/include/catalog/pg_amproc.h  | 153 +++
 src/include/catalog/pg_opclass.h |  25 ++
 src/include/catalog/pg_opfamily.h|  20 +
 src/include/catalog/pg_proc.h|  10 +
 src/test/regress/expected/opr_sanity.out |   3 +-
 9 files changed, 1233 insertions(+), 2 deletions(-)
 create mode 100644 src/backend/access/brin/brin_bloom.c

diff --git a/doc/src/sgml/brin.sgml b/doc/src/sgml/brin.sgml
index b7483df..49d53e1 100644
--- a/doc/src/sgml/brin.sgml
+++ b/doc/src/sgml/brin.sgml
@@ -118,6 +118,13 @@


 
+ abstime_bloom_ops
+ abstime
+ 
+  =
+ 
+
+
  abstime_minmax_ops
  abstime
  
@@ -129,6 +136,13 @@
  
 
 
+ int8_bloom_ops
+ bigint
+ 
+  =
+ 
+
+
  int8_minmax_ops
  bigint
  
@@ -180,6 +194,13 @@
  
 
 
+ bytea_bloom_ops
+ bytea
+ 
+  =
+ 
+
+
  bytea_minmax_ops
  bytea
  
@@ -191,6 +212,13 @@
  
 
 
+ bpchar_bloom_ops
+ character
+ 
+  =
+ 
+
+
  bpchar_minmax_ops
  character
  
@@ -202,6 +230,13 @@
  
 
 
+ char_bloom_ops
+ "char"
+ 
+  =
+ 
+
+
  char_minmax_ops
  "char"
  
@@ -213,6 +248,13 @@
  
 
 
+ date_bloom_ops
+ date
+ 
+  =
+ 
+
+
  date_minmax_ops
  date
  
@@ -224,6 +266,13 @@
  
 
 
+ float8_bloom_ops
+ double precision
+ 
+  =
+ 
+
+
  float8_minmax_ops
  double precision
  
@@ -235,6 +284,13 @@
  
 
 
+ inet_bloom_ops
+ inet
+ 
+  =
+ 
+
+
  inet_minmax_ops
  inet
  
@@ -258,6 +314,13 @@
  
 
 
+ int4_bloom_ops
+ integer
+ 
+  =
+ 
+
+
  int4_minmax_ops
  integer
  
@@ -269,6 +332,13 @@
  
 
 
+ interval_bloom_ops
+ interval
+ 
+  =
+ 
+
+
  interval_minmax_ops
  interval
  
@@ -280,6 +350,13 @@
  
 
 
+ macaddr_bloom_ops
+ macaddr
+ 
+  =
+ 
+
+
  macaddr_minmax_ops
  macaddr
  
@@ -291,6 +368,13 @@
  
 
 
+ macaddr8_bloom_ops
+ macaddr8
+ 
+  =
+ 
+
+
  macaddr8_minmax_ops
  macaddr8
  
@@ -302,6 +386,13 @@
  
 
 
+ name_bloom_ops
+ name
+ 
+  =
+ 
+
+
  name_minmax_ops
  name
  
@@ -313,6 +404,13 @@
  
 
 
+ numeric_bloom_ops
+ numeric
+ 
+  =
+ 
+
+
  numeric_minmax_ops
  numeric
  
@@ -324,6 +422,13 @@
  
 
 
+ pg_lsn_bloom_ops
+ pg_lsn
+ 
+  =
+ 
+
+
  pg_lsn_minmax_ops
  pg_lsn
  
@@ -335,6 +440,13 @@
  
 
 
+ oid_bloom_ops
+ oid
+ 
+  =
+ 
+
+
  oid_minmax_ops
  oid
  
@@ -366,6 +478,13 @@
  
 
 
+ float4_bloom_ops
+ real
+ 
+  =
+ 
+
+
  float4_minmax_ops
  real
  
@@ -377,6 +496,13 @@
  
 
 
+ reltime_bloom_ops
+ reltime
+ 
+  =
+ 
+
+
  reltime_minmax_ops
  reltime
  
@@ -388,6 +514,13 @@
  
 
 
+ int2_bloom_ops
+ smallint
+ 
+  =
+ 
+
+
  int2_minmax_ops
  smallint
  
@@ -399,6 +532,13 @@
  
 
 
+ text_bloom_ops
+ text
+ 
+  =
+ 
+
+
  text_minmax_ops
  text
  
@@ -410,6 +550,13 @@
  
 
 
+ tid_bloom_ops
+ tid
+ 
+  =
+ 
+
+
  tid_minmax_ops
  tid
  
@@ -421,6 +568,13 @@
  
 
 
+ timestamp_bloom_ops
+ timestamp without time zone
+ 
+  =
+ 
+
+
  timestamp_minmax_ops
  timestamp without time zone
  
@@ -432,6 +586,13 @@
  
 
 
+ timestamptz_bloom_ops
+ timestamp with time zone
+ 
+  =
+ 
+
+
  timestamptz_minmax_ops
  timestamp with time zone
  
@@ -443,6 +604,13 @@
  
 
 
+ time_bloom_ops
+ time