From c6e3ac11b60ac4a8942ab964252d51c1c0bd8845 Mon Sep 17 00:00:00 2001
From: Tom Lane
Date: Wed, 7 Dec 2011 00:18:38 -0500
Subject: Create a "sort support" interface API for faster sorting.
This patch creates an API whereby a btree index opclass can optionally
provide non-SQL-callable support functions for sorting. In the initial
patch, we only use this to provide a directly-callable comparator function,
which can be invoked with a bit less overhead than the traditional
SQL-callable comparator. While that should be of value in itself, the real
reason for doing this is to provide a datatype-extensible framework for
more aggressive optimizations, as in Peter Geoghegan's recent work.
Robert Haas and Tom Lane
---
doc/src/sgml/xindex.sgml | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
(limited to 'doc/src/sgml/xindex.sgml')
diff --git a/doc/src/sgml/xindex.sgml b/doc/src/sgml/xindex.sgml
index 28324361a95..f3a9783e5c9 100644
--- a/doc/src/sgml/xindex.sgml
+++ b/doc/src/sgml/xindex.sgml
@@ -311,7 +311,8 @@
- B-trees require a single support function, shown in .
@@ -333,12 +334,19 @@
1
+
+
+ Return the addresses of C-callable sort support function(s),
+ as documented in utils/sortsupport.h> (optional)
+
+ 2
+
- Hash indexes likewise require one support function, shown in .
@@ -363,6 +371,7 @@
GiST indexes require seven support functions, with an optional eighth, as
shown in .
+ (For more information see .)
@@ -418,9 +427,7 @@
distance>
-
- (optional method) determine distance from key to query value
-
+ determine distance from key to query value (optional)
8
@@ -430,6 +437,7 @@
GIN indexes require four support functions, with an optional fifth, as
shown in .
+ (For more information see .)
@@ -470,10 +478,10 @@
comparePartial>
- (optional method) compare partial key from
+ compare partial key from
query and key from index, and return an integer less than zero, zero,
or greater than zero, indicating whether GIN should ignore this index
- entry, treat the entry as a match, or stop the index scan
+ entry, treat the entry as a match, or stop the index scan (optional)
5
@@ -486,7 +494,8 @@
type the particular index method expects; for example in the case
of the comparison function for B-trees, a signed integer. The number
and types of the arguments to each support function are likewise
- dependent on the index method. For B-tree and hash the support functions
+ dependent on the index method. For B-tree and hash the comparison and
+ hashing support functions
take the same input data types as do the operators included in the operator
class, but this is not the case for most GIN and GiST support functions.
@@ -748,7 +757,8 @@ DEFAULT FOR TYPE int8 USING btree FAMILY integer_ops AS
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
- FUNCTION 1 btint8cmp(int8, int8) ;
+ FUNCTION 1 btint8cmp(int8, int8) ,
+ FUNCTION 2 btint8sortsupport(internal) ;
CREATE OPERATOR CLASS int4_ops
DEFAULT FOR TYPE int4 USING btree FAMILY integer_ops AS
@@ -758,7 +768,8 @@ DEFAULT FOR TYPE int4 USING btree FAMILY integer_ops AS
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
- FUNCTION 1 btint4cmp(int4, int4) ;
+ FUNCTION 1 btint4cmp(int4, int4) ,
+ FUNCTION 2 btint4sortsupport(internal) ;
CREATE OPERATOR CLASS int2_ops
DEFAULT FOR TYPE int2 USING btree FAMILY integer_ops AS
@@ -768,7 +779,8 @@ DEFAULT FOR TYPE int2 USING btree FAMILY integer_ops AS
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
- FUNCTION 1 btint2cmp(int2, int2) ;
+ FUNCTION 1 btint2cmp(int2, int2) ,
+ FUNCTION 2 btint2sortsupport(internal) ;
ALTER OPERATOR FAMILY integer_ops USING btree ADD
-- cross-type comparisons int8 vs int2
--
cgit v1.2.3