Postgres-XC 1.2devel Documentation | ||||
---|---|---|---|---|
Prev | Fast Backward | Appendix F. Additional Supplied Modules | Fast Forward | Next |
Note: The following description applies both to Postgres-XC and PostgreSQL if not described explicitly. You can read PostgreSQL as Postgres-XC except for version number, which is specific to each product.
btree_gist provides GiST index operator classes that implement B-tree equivalent behavior for the data types int2, int4, int8, float4, float8, numeric, timestamp with time zone, timestamp without time zone, time with time zone, time without time zone, date, interval, oid, money, char, varchar, text, bytea, bit, varbit, macaddr, inet, and cidr.
In general, these operator classes will not outperform the equivalent standard B-tree index methods, and they lack one major feature of the standard B-tree code: the ability to enforce uniqueness. However, they provide some other features that are not available with a B-tree index, as described below. Also, these operator classes are useful when a multicolumn GiST index is needed, wherein some of the columns are of data types that are only indexable with GiST but other columns are just simple data types. Lastly, these operator classes are useful for GiST testing and as a base for developing other GiST operator classes.
In addition to the typical B-tree search operators, btree_gist also provides index support for <> ("not equals").
Also, for data types for which there is a natural distance metric, btree_gist defines a distance operator <->, and provides GiST index support for nearest-neighbor searches using this operator. Distance operators are provided for int2, int4, int8, float4, float8, timestamp with time zone, timestamp without time zone, time without time zone, date, interval, oid, and money.
Note: The following description applies both to Postgres-XC and PostgreSQL if not described explicitly. You can read PostgreSQL as Postgres-XC except for version number, which is specific to each product.
Simple example using btree_gist instead of btree:
CREATE TABLE test (a int4); -- create index CREATE INDEX testidx ON test USING gist (a); -- query SELECT * FROM test WHERE a < 10; -- nearest-neighbor search: find the ten entries closest to "42" SELECT *, a <-> 42 AS dist FROM test ORDER BY a <-> 42 LIMIT 10;
Teodor Sigaev (<teodor@stack.net>
) ,
Oleg Bartunov (<oleg@sai.msu.su>
), and
Janko Richter (<jankorichter@yahoo.de>
). See
http://www.sai.msu.su/~megera/postgres/gist/
for additional information.