1 <!-- doc/src/sgml/gist.sgml -->
4 <title>GiST Indexes</title>
7 <primary>index</primary>
8 <secondary>GiST</secondary>
11 <sect1 id="gist-intro">
12 <title>Introduction</title>
15 <acronym>GiST</acronym> stands for Generalized Search Tree. It is a
16 balanced, tree-structured access method, that acts as a base template in
17 which to implement arbitrary indexing schemes. B-trees, R-trees and many
18 other indexing schemes can be implemented in <acronym>GiST</acronym>.
22 One advantage of <acronym>GiST</acronym> is that it allows the development
23 of custom data types with the appropriate access methods, by
24 an expert in the domain of the data type, rather than a database expert.
28 Some of the information here is derived from the University of California
29 at Berkeley's GiST Indexing Project
30 <ulink url="http://gist.cs.berkeley.edu/">web site</ulink> and
31 Marcel Kornacker's thesis,
32 <ulink url="http://www.sai.msu.su/~megera/postgres/gist/papers/concurrency/access-methods-for-next-generation.pdf.gz">
33 Access Methods for Next-Generation Database Systems</ulink>.
34 The <acronym>GiST</acronym>
35 implementation in <productname>PostgreSQL</productname> is primarily
36 maintained by Teodor Sigaev and Oleg Bartunov, and there is more
38 <ulink url="http://www.sai.msu.su/~megera/postgres/gist/">web site</ulink>.
43 <sect1 id="gist-builtin-opclasses">
44 <title>Built-in Operator Classes</title>
47 The core <productname>PostgreSQL</> distribution
48 includes the <acronym>GiST</acronym> operator classes shown in
49 <xref linkend="gist-builtin-opclasses-table">.
50 (Some of the optional modules described in <xref linkend="contrib">
51 provide additional <acronym>GiST</acronym> operator classes.)
54 <table id="gist-builtin-opclasses-table">
55 <title>Built-in <acronym>GiST</acronym> Operator Classes</title>
60 <entry>Indexed Data Type</entry>
61 <entry>Indexable Operators</entry>
62 <entry>Ordering Operators</entry>
67 <entry><literal>box_ops</></entry>
68 <entry><type>box</></entry>
70 <literal>&&</>
73 <literal>&<|</>
80 <literal>|&></>
89 <entry><literal>circle_ops</></entry>
90 <entry><type>circle</></entry>
92 <literal>&&</>
95 <literal>&<|</>
102 <literal>|&></>
103 <literal>|>></>
108 <literal><-></>
112 <entry><literal>inet_ops</></entry>
113 <entry><type>inet</>, <type>cidr</></entry>
115 <literal>&&</>
117 <literal>>>=</>
122 <literal><<=</>
131 <entry><literal>point_ops</></entry>
132 <entry><type>point</></entry>
144 <literal><-></>
148 <entry><literal>poly_ops</></entry>
149 <entry><type>polygon</></entry>
151 <literal>&&</>
152 <literal>&></>
153 <literal>&<</>
154 <literal>&<|</>
157 <literal><<|</>
161 <literal>|&></>
162 <literal>|>></>
167 <literal><-></>
171 <entry><literal>range_ops</></entry>
172 <entry>any range type</entry>
174 <literal>&&</>
175 <literal>&></>
176 <literal>&<</>
189 <entry><literal>tsquery_ops</></entry>
190 <entry><type>tsquery</></entry>
199 <entry><literal>tsvector_ops</></entry>
200 <entry><type>tsvector</></entry>
212 For historical reasons, the <literal>inet_ops</> operator class is
213 not the default class for types <type>inet</> and <type>cidr</>.
214 To use it, mention the class name in <command>CREATE INDEX</>,
217 CREATE INDEX ON my_table USING GIST (my_inet_column inet_ops);
223 <sect1 id="gist-extensibility">
224 <title>Extensibility</title>
227 Traditionally, implementing a new index access method meant a lot of
228 difficult work. It was necessary to understand the inner workings of the
229 database, such as the lock manager and Write-Ahead Log. The
230 <acronym>GiST</acronym> interface has a high level of abstraction,
231 requiring the access method implementer only to implement the semantics of
232 the data type being accessed. The <acronym>GiST</acronym> layer itself
233 takes care of concurrency, logging and searching the tree structure.
237 This extensibility should not be confused with the extensibility of the
238 other standard search trees in terms of the data they can handle. For
239 example, <productname>PostgreSQL</productname> supports extensible B-trees
240 and hash indexes. That means that you can use
241 <productname>PostgreSQL</productname> to build a B-tree or hash over any
242 data type you want. But B-trees only support range predicates
243 (<literal><</literal>, <literal>=</literal>, <literal>></literal>),
244 and hash indexes only support equality queries.
248 So if you index, say, an image collection with a
249 <productname>PostgreSQL</productname> B-tree, you can only issue queries
250 such as <quote>is imagex equal to imagey</quote>, <quote>is imagex less
251 than imagey</quote> and <quote>is imagex greater than imagey</quote>.
252 Depending on how you define <quote>equals</quote>, <quote>less than</quote>
253 and <quote>greater than</quote> in this context, this could be useful.
254 However, by using a <acronym>GiST</acronym> based index, you could create
255 ways to ask domain-specific questions, perhaps <quote>find all images of
256 horses</quote> or <quote>find all over-exposed images</quote>.
260 All it takes to get a <acronym>GiST</acronym> access method up and running
261 is to implement several user-defined methods, which define the behavior of
262 keys in the tree. Of course these methods have to be pretty fancy to
263 support fancy queries, but for all the standard queries (B-trees,
264 R-trees, etc.) they're relatively straightforward. In short,
265 <acronym>GiST</acronym> combines extensibility along with generality, code
266 reuse, and a clean interface.
270 There are seven methods that an index operator class for
271 <acronym>GiST</acronym> must provide, and two that are optional.
272 Correctness of the index is ensured
273 by proper implementation of the <function>same</>, <function>consistent</>
274 and <function>union</> methods, while efficiency (size and speed) of the
275 index will depend on the <function>penalty</> and <function>picksplit</>
277 The remaining two basic methods are <function>compress</> and
278 <function>decompress</>, which allow an index to have internal tree data of
279 a different type than the data it indexes. The leaves are to be of the
280 indexed data type, while the other tree nodes can be of any C struct (but
281 you still have to follow <productname>PostgreSQL</> data type rules here,
282 see about <literal>varlena</> for variable sized data). If the tree's
283 internal data type exists at the SQL level, the <literal>STORAGE</> option
284 of the <command>CREATE OPERATOR CLASS</> command can be used.
285 The optional eighth method is <function>distance</>, which is needed
286 if the operator class wishes to support ordered scans (nearest-neighbor
287 searches). The optional ninth method <function>fetch</> is needed if the
288 operator class wishes to support index-only scans.
293 <term><function>consistent</></term>
296 Given an index entry <literal>p</> and a query value <literal>q</>,
297 this function determines whether the index entry is
298 <quote>consistent</> with the query; that is, could the predicate
299 <quote><replaceable>indexed_column</>
300 <replaceable>indexable_operator</> <literal>q</></quote> be true for
301 any row represented by the index entry? For a leaf index entry this is
302 equivalent to testing the indexable condition, while for an internal
303 tree node this determines whether it is necessary to scan the subtree
304 of the index represented by the tree node. When the result is
305 <literal>true</>, a <literal>recheck</> flag must also be returned.
306 This indicates whether the predicate is certainly true or only possibly
307 true. If <literal>recheck</> = <literal>false</> then the index has
308 tested the predicate condition exactly, whereas if <literal>recheck</>
309 = <literal>true</> the row is only a candidate match. In that case the
310 system will automatically evaluate the
311 <replaceable>indexable_operator</> against the actual row value to see
312 if it is really a match. This convention allows
313 <acronym>GiST</acronym> to support both lossless and lossy index
318 The <acronym>SQL</> declaration of the function must look like this:
321 CREATE OR REPLACE FUNCTION my_consistent(internal, data_type, smallint, oid, internal)
327 And the matching code in the C module could then follow this skeleton:
330 PG_FUNCTION_INFO_V1(my_consistent);
333 my_consistent(PG_FUNCTION_ARGS)
335 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
336 data_type *query = PG_GETARG_DATA_TYPE_P(1);
337 StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
338 /* Oid subtype = PG_GETARG_OID(3); */
339 bool *recheck = (bool *) PG_GETARG_POINTER(4);
340 data_type *key = DatumGetDataType(entry->key);
344 * determine return value as a function of strategy, key and query.
346 * Use GIST_LEAF(entry) to know where you're called in the index tree,
347 * which comes handy when supporting the = operator for example (you could
348 * check for non empty union() in non-leaf nodes and equality in leaf
352 *recheck = true; /* or false if check is exact */
354 PG_RETURN_BOOL(retval);
358 Here, <varname>key</> is an element in the index and <varname>query</>
359 the value being looked up in the index. The <literal>StrategyNumber</>
360 parameter indicates which operator of your operator class is being
361 applied — it matches one of the operator numbers in the
362 <command>CREATE OPERATOR CLASS</> command.
366 Depending on which operators you have included in the class, the data
367 type of <varname>query</> could vary with the operator, since it will
368 be whatever type is on the righthand side of the operator, which might
369 be different from the indexed data type appearing on the lefthand side.
370 (The above code skeleton assumes that only one type is possible; if
371 not, fetching the <varname>query</> argument value would have to depend
372 on the operator.) It is recommended that the SQL declaration of
373 the <function>consistent</> function use the opclass's indexed data
374 type for the <varname>query</> argument, even though the actual type
375 might be something else depending on the operator.
382 <term><function>union</></term>
385 This method consolidates information in the tree. Given a set of
386 entries, this function generates a new index entry that represents
387 all the given entries.
391 The <acronym>SQL</> declaration of the function must look like this:
394 CREATE OR REPLACE FUNCTION my_union(internal, internal)
400 And the matching code in the C module could then follow this skeleton:
403 PG_FUNCTION_INFO_V1(my_union);
406 my_union(PG_FUNCTION_ARGS)
408 GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
409 GISTENTRY *ent = entryvec->vector;
416 numranges = entryvec->n;
417 tmp = DatumGetDataType(ent[0].key);
422 out = data_type_deep_copy(tmp);
424 PG_RETURN_DATA_TYPE_P(out);
427 for (i = 1; i < numranges; i++)
430 tmp = DatumGetDataType(ent[i].key);
431 out = my_union_implementation(out, tmp);
434 PG_RETURN_DATA_TYPE_P(out);
440 As you can see, in this skeleton we're dealing with a data type
441 where <literal>union(X, Y, Z) = union(union(X, Y), Z)</>. It's easy
442 enough to support data types where this is not the case, by
443 implementing the proper union algorithm in this
444 <acronym>GiST</> support method.
448 The result of the <function>union</> function must be a value of the
449 index's storage type, whatever that is (it might or might not be
450 different from the indexed column's type). The <function>union</>
451 function should return a pointer to newly <function>palloc()</>ed
452 memory. You can't just return the input value as-is, even if there is
457 As shown above, the <function>union</> function's
458 first <type>internal</> argument is actually
459 a <structname>GistEntryVector</> pointer. The second argument is a
460 pointer to an integer variable, which can be ignored. (It used to be
461 required that the <function>union</> function store the size of its
462 result value into that variable, but this is no longer necessary.)
468 <term><function>compress</></term>
471 Converts the data item into a format suitable for physical storage in
476 The <acronym>SQL</> declaration of the function must look like this:
479 CREATE OR REPLACE FUNCTION my_compress(internal)
485 And the matching code in the C module could then follow this skeleton:
488 PG_FUNCTION_INFO_V1(my_compress);
491 my_compress(PG_FUNCTION_ARGS)
493 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
496 if (entry->leafkey)
498 /* replace entry->key with a compressed version */
499 compressed_data_type *compressed_data = palloc(sizeof(compressed_data_type));
501 /* fill *compressed_data from entry->key ... */
503 retval = palloc(sizeof(GISTENTRY));
504 gistentryinit(*retval, PointerGetDatum(compressed_data),
505 entry->rel, entry->page, entry->offset, FALSE);
509 /* typically we needn't do anything with non-leaf entries */
513 PG_RETURN_POINTER(retval);
519 You have to adapt <replaceable>compressed_data_type</> to the specific
520 type you're converting to in order to compress your leaf nodes, of
527 <term><function>decompress</></term>
530 The reverse of the <function>compress</function> method. Converts the
531 index representation of the data item into a format that can be
532 manipulated by the other GiST methods in the operator class.
536 The <acronym>SQL</> declaration of the function must look like this:
539 CREATE OR REPLACE FUNCTION my_decompress(internal)
545 And the matching code in the C module could then follow this skeleton:
548 PG_FUNCTION_INFO_V1(my_decompress);
551 my_decompress(PG_FUNCTION_ARGS)
553 PG_RETURN_POINTER(PG_GETARG_POINTER(0));
557 The above skeleton is suitable for the case where no decompression
564 <term><function>penalty</></term>
567 Returns a value indicating the <quote>cost</quote> of inserting the new
568 entry into a particular branch of the tree. Items will be inserted
569 down the path of least <function>penalty</function> in the tree.
570 Values returned by <function>penalty</function> should be non-negative.
571 If a negative value is returned, it will be treated as zero.
575 The <acronym>SQL</> declaration of the function must look like this:
578 CREATE OR REPLACE FUNCTION my_penalty(internal, internal, internal)
581 LANGUAGE C STRICT; -- in some cases penalty functions need not be strict
584 And the matching code in the C module could then follow this skeleton:
587 PG_FUNCTION_INFO_V1(my_penalty);
590 my_penalty(PG_FUNCTION_ARGS)
592 GISTENTRY *origentry = (GISTENTRY *) PG_GETARG_POINTER(0);
593 GISTENTRY *newentry = (GISTENTRY *) PG_GETARG_POINTER(1);
594 float *penalty = (float *) PG_GETARG_POINTER(2);
595 data_type *orig = DatumGetDataType(origentry->key);
596 data_type *new = DatumGetDataType(newentry->key);
598 *penalty = my_penalty_implementation(orig, new);
599 PG_RETURN_POINTER(penalty);
603 For historical reasons, the <function>penalty</> function doesn't
604 just return a <type>float</> result; instead it has to store the value
605 at the location indicated by the third argument. The return
606 value per se is ignored, though it's conventional to pass back the
607 address of that argument.
611 The <function>penalty</> function is crucial to good performance of
612 the index. It'll get used at insertion time to determine which branch
613 to follow when choosing where to add the new entry in the tree. At
614 query time, the more balanced the index, the quicker the lookup.
620 <term><function>picksplit</></term>
623 When an index page split is necessary, this function decides which
624 entries on the page are to stay on the old page, and which are to move
629 The <acronym>SQL</> declaration of the function must look like this:
632 CREATE OR REPLACE FUNCTION my_picksplit(internal, internal)
638 And the matching code in the C module could then follow this skeleton:
641 PG_FUNCTION_INFO_V1(my_picksplit);
644 my_picksplit(PG_FUNCTION_ARGS)
646 GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
647 GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
648 OffsetNumber maxoff = entryvec->n - 1;
649 GISTENTRY *ent = entryvec->vector;
654 data_type *tmp_union;
657 GISTENTRY **raw_entryvec;
659 maxoff = entryvec->n - 1;
660 nbytes = (maxoff + 1) * sizeof(OffsetNumber);
662 v->spl_left = (OffsetNumber *) palloc(nbytes);
663 left = v->spl_left;
666 v->spl_right = (OffsetNumber *) palloc(nbytes);
667 right = v->spl_right;
668 v->spl_nright = 0;
673 /* Initialize the raw entry vector. */
674 raw_entryvec = (GISTENTRY **) malloc(entryvec->n * sizeof(void *));
675 for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
676 raw_entryvec[i] = &(entryvec->vector[i]);
678 for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
680 int real_index = raw_entryvec[i] - entryvec->vector;
682 tmp_union = DatumGetDataType(entryvec->vector[real_index].key);
683 Assert(tmp_union != NULL);
686 * Choose where to put the index entries and update unionL and unionR
687 * accordingly. Append the entries to either v_spl_left or
688 * v_spl_right, and care about the counters.
691 if (my_choice_is_left(unionL, curl, unionR, curr))
696 unionL = my_union_implementation(unionL, tmp_union);
710 v->spl_ldatum = DataTypeGetDatum(unionL);
711 v->spl_rdatum = DataTypeGetDatum(unionR);
712 PG_RETURN_POINTER(v);
716 Notice that the <function>picksplit</> function's result is delivered
717 by modifying the passed-in <structname>v</> structure. The return
718 value per se is ignored, though it's conventional to pass back the
719 address of <structname>v</>.
723 Like <function>penalty</>, the <function>picksplit</> function
724 is crucial to good performance of the index. Designing suitable
725 <function>penalty</> and <function>picksplit</> implementations
726 is where the challenge of implementing well-performing
727 <acronym>GiST</> indexes lies.
733 <term><function>same</></term>
736 Returns true if two index entries are identical, false otherwise.
737 (An <quote>index entry</> is a value of the index's storage type,
738 not necessarily the original indexed column's type.)
742 The <acronym>SQL</> declaration of the function must look like this:
745 CREATE OR REPLACE FUNCTION my_same(storage_type, storage_type, internal)
751 And the matching code in the C module could then follow this skeleton:
754 PG_FUNCTION_INFO_V1(my_same);
757 my_same(PG_FUNCTION_ARGS)
759 prefix_range *v1 = PG_GETARG_PREFIX_RANGE_P(0);
760 prefix_range *v2 = PG_GETARG_PREFIX_RANGE_P(1);
761 bool *result = (bool *) PG_GETARG_POINTER(2);
763 *result = my_eq(v1, v2);
764 PG_RETURN_POINTER(result);
768 For historical reasons, the <function>same</> function doesn't
769 just return a Boolean result; instead it has to store the flag
770 at the location indicated by the third argument. The return
771 value per se is ignored, though it's conventional to pass back the
772 address of that argument.
778 <term><function>distance</></term>
781 Given an index entry <literal>p</> and a query value <literal>q</>,
782 this function determines the index entry's
783 <quote>distance</> from the query value. This function must be
784 supplied if the operator class contains any ordering operators.
785 A query using the ordering operator will be implemented by returning
786 index entries with the smallest <quote>distance</> values first,
787 so the results must be consistent with the operator's semantics.
788 For a leaf index entry the result just represents the distance to
789 the index entry; for an internal tree node, the result must be the
790 smallest distance that any child entry could have.
794 The <acronym>SQL</> declaration of the function must look like this:
797 CREATE OR REPLACE FUNCTION my_distance(internal, data_type, smallint, oid, internal)
803 And the matching code in the C module could then follow this skeleton:
806 PG_FUNCTION_INFO_V1(my_distance);
809 my_distance(PG_FUNCTION_ARGS)
811 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
812 data_type *query = PG_GETARG_DATA_TYPE_P(1);
813 StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
814 /* Oid subtype = PG_GETARG_OID(3); */
815 /* bool *recheck = (bool *) PG_GETARG_POINTER(4); */
816 data_type *key = DatumGetDataType(entry->key);
820 * determine return value as a function of strategy, key and query.
823 PG_RETURN_FLOAT8(retval);
827 The arguments to the <function>distance</> function are identical to
828 the arguments of the <function>consistent</> function.
832 Some approximation is allowed when determining the distance, so long
833 as the result is never greater than the entry's actual distance. Thus,
834 for example, distance to a bounding box is usually sufficient in
835 geometric applications. For an internal tree node, the distance
836 returned must not be greater than the distance to any of the child
837 nodes. If the returned distance is not exact, the function must set
838 <literal>*recheck</> to true. (This is not necessary for internal tree
839 nodes; for them, the calculation is always assumed to be inexact.) In
840 this case the executor will calculate the accurate distance after
841 fetching the tuple from the heap, and reorder the tuples if necessary.
845 If the distance function returns <literal>*recheck = true</> for any
846 leaf node, the original ordering operator's return type must
847 be <type>float8</> or <type>float4</>, and the distance function's
848 result values must be comparable to those of the original ordering
849 operator, since the executor will sort using both distance function
850 results and recalculated ordering-operator results. Otherwise, the
851 distance function's result values can be any finite <type>float8</>
852 values, so long as the relative order of the result values matches the
853 order returned by the ordering operator. (Infinity and minus infinity
854 are used internally to handle cases such as nulls, so it is not
855 recommended that <function>distance</> functions return these values.)
862 <term><function>fetch</></term>
865 Converts the compressed index representation of a data item into the
866 original data type, for index-only scans. The returned data must be an
867 exact, non-lossy copy of the originally indexed value.
871 The <acronym>SQL</> declaration of the function must look like this:
874 CREATE OR REPLACE FUNCTION my_fetch(internal)
880 The argument is a pointer to a <structname>GISTENTRY</> struct. On
881 entry, its <structfield>key</> field contains a non-NULL leaf datum in
882 compressed form. The return value is another <structname>GISTENTRY</>
883 struct, whose <structfield>key</> field contains the same datum in its
884 original, uncompressed form. If the opclass's compress function does
885 nothing for leaf entries, the <function>fetch</> method can return the
890 The matching code in the C module could then follow this skeleton:
893 PG_FUNCTION_INFO_V1(my_fetch);
896 my_fetch(PG_FUNCTION_ARGS)
898 GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
899 input_data_type *in = DatumGetP(entry->key);
900 fetched_data_type *fetched_data;
903 retval = palloc(sizeof(GISTENTRY));
904 fetched_data = palloc(sizeof(fetched_data_type));
907 * Convert 'fetched_data' into the a Datum of the original datatype.
910 /* fill *retval from fetch_data. */
911 gistentryinit(*retval, PointerGetDatum(converted_datum),
912 entry->rel, entry->page, entry->offset, FALSE);
914 PG_RETURN_POINTER(retval);
920 If the compress method is lossy for leaf entries, the operator class
921 cannot support index-only scans, and must not define
922 a <function>fetch</> function.
930 All the GiST support methods are normally called in short-lived memory
931 contexts; that is, <varname>CurrentMemoryContext</> will get reset after
932 each tuple is processed. It is therefore not very important to worry about
933 pfree'ing everything you palloc. However, in some cases it's useful for a
934 support method to cache data across repeated calls. To do that, allocate
935 the longer-lived data in <literal>fcinfo->flinfo->fn_mcxt</>, and
936 keep a pointer to it in <literal>fcinfo->flinfo->fn_extra</>. Such
937 data will survive for the life of the index operation (e.g., a single GiST
938 index scan, index build, or index tuple insertion). Be careful to pfree
939 the previous value when replacing a <literal>fn_extra</> value, or the leak
940 will accumulate for the duration of the operation.
945 <sect1 id="gist-implementation">
946 <title>Implementation</title>
948 <sect2 id="gist-buffering-build">
949 <title>GiST buffering build</title>
951 Building large GiST indexes by simply inserting all the tuples tends to be
952 slow, because if the index tuples are scattered across the index and the
953 index is large enough to not fit in cache, the insertions need to perform
954 a lot of random I/O. Beginning in version 9.2, PostgreSQL supports a more
955 efficient method to build GiST indexes based on buffering, which can
956 dramatically reduce the number of random I/Os needed for non-ordered data
957 sets. For well-ordered data sets the benefit is smaller or non-existent,
958 because only a small number of pages receive new tuples at a time, and
959 those pages fit in cache even if the index as whole does not.
963 However, buffering index build needs to call the <function>penalty</>
964 function more often, which consumes some extra CPU resources. Also, the
965 buffers used in the buffering build need temporary disk space, up to
966 the size of the resulting index. Buffering can also influence the quality
967 of the resulting index, in both positive and negative directions. That
968 influence depends on various factors, like the distribution of the input
969 data and the operator class implementation.
973 By default, a GiST index build switches to the buffering method when the
974 index size reaches <xref linkend="guc-effective-cache-size">. It can
975 be manually turned on or off by the <literal>buffering</literal> parameter
976 to the CREATE INDEX command. The default behavior is good for most cases,
977 but turning buffering off might speed up the build somewhat if the input
984 <sect1 id="gist-examples">
985 <title>Examples</title>
988 The <productname>PostgreSQL</productname> source distribution includes
989 several examples of index methods implemented using
990 <acronym>GiST</acronym>. The core system currently provides text search
991 support (indexing for <type>tsvector</> and <type>tsquery</>) as well as
992 R-Tree equivalent functionality for some of the built-in geometric data types
993 (see <filename>src/backend/access/gist/gistproc.c</>). The following
994 <filename>contrib</> modules also contain <acronym>GiST</acronym>
999 <term><filename>btree_gist</></term>
1001 <para>B-tree equivalent functionality for several data types</para>
1006 <term><filename>cube</></term>
1008 <para>Indexing for multidimensional cubes</para>
1013 <term><filename>hstore</></term>
1015 <para>Module for storing (key, value) pairs</para>
1020 <term><filename>intarray</></term>
1022 <para>RD-Tree for one-dimensional array of int4 values</para>
1027 <term><filename>ltree</></term>
1029 <para>Indexing for tree-like structures</para>
1034 <term><filename>pg_trgm</></term>
1036 <para>Text similarity using trigram matching</para>
1041 <term><filename>seg</></term>
1043 <para>Indexing for <quote>float ranges</quote></para>