Indexing of Box Types

GiST and SP-GiST indexes can be created for table columns of the tbox and stbox types. An example of creation of a GiST index in a column bbox of type stbox in a table Trips is as follows:

CREATE TABLE Trips(TripID integer PRIMARY KEY, Trip tgeompoint, bbox stbox);
CREATE INDEX trips_bbox_idx ON Trips USING GIST(bbox);
				

A GiST or SP-GiST index can accelerate queries involving the following operators: &&, <@, @>, ~=, -|-, <<, >>, &<, &>, <<|, |>>, &<|, |&>, <</, />>, &</, /&>, <<#, #>>, &<#, and #&>.

In addition, B-tree indexes can be created for table columns of a box type. For these index types, basically the only useful operation is equality. There is a B-tree sort ordering defined for values of time types, with corresponding < and > operators, but the ordering is rather arbitrary and not usually useful in the real world. The B-tree support is primarily meant to allow sorting internally in queries, rather than creation of actual indexes.