From efe64c8d1ffbc0729de850c79a47c9d1ce62d54e Mon Sep 17 00:00:00 2001 From: Alexander Nestorov Date: Thu, 4 Jun 2026 00:09:08 +0200 Subject: [PATCH] doc: Document cross-type operator support in btree_gist Note that as of btree_gist 1.10 the int2, int4 and int8 operator classes accept cross-type query operators (the B-tree comparison operators and the <-> distance operator) against the other two integer types without an explicit cast, and that out-of-range query constants are compared by normal integer semantics. Also document that the integer <-> distance is computed in float8, so for int8 distances beyond 2^53 the result loses precision and may reorder nearly-equidistant matches; it never changes which rows match. --- doc/src/sgml/btree-gist.sgml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/doc/src/sgml/btree-gist.sgml b/doc/src/sgml/btree-gist.sgml index cc09ec83733..1b1dce707cf 100644 --- a/doc/src/sgml/btree-gist.sgml +++ b/doc/src/sgml/btree-gist.sgml @@ -49,12 +49,36 @@ float8, timestamp with time zone, timestamp without time zone, time without time zone, date, interval, oid, and money. + + As of version 1.10, the operator classes for int2, + int4 and int8 additionally support cross-type + query operators. An index on any one of these integer types can be used + with a B-tree-style comparison (<, + <=, =, >=, + >, <>) or with the + distance operator (<->) against a value of any + of the other two integer types, without an explicit cast. Query + constants outside the indexed column's range are compared according to + normal integer comparison semantics, without narrowing the query value + to the column type first. + + + + The integer distance operator (<->) used for + nearest-neighbor (ORDER BY) searches computes the + distance in float8. For int8 values whose + distance from the query exceeds 2^53, the result loses precision and + may reorder results that are nearly equidistant; it never changes which + rows match. This applies equally to same-type and cross-type + int8 distance searches. + + By default btree_gist builds GiST index with sortsupport in sorted mode. This usually results in much faster index built speed. It is still possible to revert to buffered built strategy by using the buffering parameter when creating the index. -- 2.51.0