From a1c649d889bdf6e74e9382e1e28574d7071568de Mon Sep 17 00:00:00 2001 From: Tomas Vondra Date: Tue, 23 Mar 2021 00:12:19 +0100 Subject: Pass all scan keys to BRIN consistent function at once This commit changes how we pass scan keys to BRIN consistent function. Instead of passing them one by one, we now pass all scan keys for a given attribute at once. That makes the consistent function a bit more complex, as it has to loop through the keys, but it does allow more elaborate opclasses that can use multiple keys to eliminate ranges much more effectively. The existing BRIN opclasses (minmax, inclusion) don't really benefit from this change. The primary purpose is to allow future opclases to benefit from seeing all keys at once. This does change the BRIN API, because the signature of the consistent function changes (a new parameter with number of scan keys). So this breaks existing opclasses, and will require supporting two variants of the code for different PostgreSQL versions. We've considered supporting two variants of the consistent, but we've decided not to do that. Firstly, there's another patch that moves handling of NULL values from the opclass, which means the opclasses need to be updated anyway. Secondly, we're not aware of any out-of-core BRIN opclasses, so it does not seem worth the extra complexity. Bump catversion, because of pg_proc changes. Author: Tomas Vondra Reviewed-by: Alvaro Herrera Reviewed-by: Mark Dilger Reviewed-by: Alexander Korotkov Reviewed-by: John Naylor Reviewed-by: Nikita Glukhov Discussion: https://postgr.es/m/c1138ead-7668-f0e1-0638-c3be3237e812@2ndquadrant.com --- doc/src/sgml/brin.sgml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/brin.sgml b/doc/src/sgml/brin.sgml index 06880c0f7bf..078f51bb55a 100644 --- a/doc/src/sgml/brin.sgml +++ b/doc/src/sgml/brin.sgml @@ -464,12 +464,14 @@ typedef struct BrinOpcInfo bool consistent(BrinDesc *bdesc, BrinValues *column, - ScanKey key) + ScanKey *keys, int nkeys) - Returns whether the ScanKey is consistent with the given indexed - values for a range. + Returns whether all the ScanKey entries are consistent with the given + indexed values for a range. The attribute number to use is passed as part of the scan key. + Multiple scan keys for the same attribute may be passed at once, the + number of entries is determined by the nkeys parameter. -- cgit v1.2.3