GIST index

Updated at:

GanosBase supports native GiST (Generalized Search Tree) 2D spatial indexes for the GeomGrid and H3Grid geographic grid data types.

Usage notes

The following examples show how to create a GiST index on a GeomGrid column and an H3Grid column.

GeomGrid

-- Create a table with a GeomGrid column.
CREATE TABLE geomgrid_gist_test (
    id serial,
    code geomgrid
);

-- Insert sample records.
INSERT INTO geomgrid_gist_test(code) VALUES('0102000F58182C0E'::GeomGrid);
INSERT INTO geomgrid_gist_test(code) VALUES('0102000F58182C0D'::GeomGrid);
INSERT INTO geomgrid_gist_test(code) VALUES('0102000F59163522'::GeomGrid);
INSERT INTO geomgrid_gist_test(code) VALUES('0102000F59163622'::GeomGrid);
INSERT INTO geomgrid_gist_test(code) VALUES('0102000F59163B22'::GeomGrid);

-- Create a GiST 2D spatial index on the code column.
CREATE INDEX geomgrid_gist_test_idx ON geomgrid_gist_test USING gist (code);

H3Grid

-- Create a table with an H3Grid column.
CREATE TABLE h3grid_gist_test (
    id serial,
    code h3grid
);

-- Insert sample records.
INSERT INTO h3grid_gist_test(code) VALUES('010100FFFF846CD932AB08'::H3Grid);
INSERT INTO h3grid_gist_test(code) VALUES('010100FF7F366127CEA308'::H3Grid);
INSERT INTO h3grid_gist_test(code) VALUES('010100FF7F466C3B8EAA08'::H3Grid);
INSERT INTO h3grid_gist_test(code) VALUES('010100FFFF0C134D87A308'::H3Grid);
INSERT INTO h3grid_gist_test(code) VALUES('010100FF7FD95460EFA108'::H3Grid);

-- Create a GiST 2D spatial index on the code column.
CREATE INDEX h3grid_gist_test_idx ON h3grid_gist_test USING gist (code);