From bf76a8c75ddff6253961523a9e2c03c3f71480ec Mon Sep 17 00:00:00 2001 From: Alexander Nestorov Date: Thu, 4 Jun 2026 00:09:08 +0200 Subject: [PATCH] Add docs for cross-type operators for GiST indexes --- 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