7.2.  smoc index #

pgSphere uses GIN to create smoc indices. An index speeds up the execution time of operators <@, @>, &&, =, and <>.

The index works by casting all contained smocs to a fixed level, and for each pixel at that level, storing which smocs overlap with that pixel. This is especially beneficial for "overlaps" queries using the && operator. The downside of that approach is that storing large smocs like "all sky" (0/0-11) produces a large number of index entries.

The default opclass smoc_gin_ops defaults to working on level 5 with a resolution of 12288 pixels (12 * 4^5). An alternative granularity can be selected by setting the order parameter on the opclass (integer value between 0 and 12; option only available on PG 13 and later). The alternative smoc_gin_ops_fine opclass works on level 8 with 786432 pixels.

Example 7.2. Index of smoc coverage objects

CREATE TABLE ivoa (
  coverage smoc NOT NULL
);
-- Put in data now
-- Create index with the defaut smoc_gin_ops opclass (order 5)
CREATE INDEX ON ivoa USING GIN (coverage);
-- Alternative index with more detail on order 7
CREATE INDEX ivoa_order_7_idx ON ivoa USING GIN (coverage smoc_gin_ops (order = 7));
-- Alternative operator class with fixed order 8
CREATE INDEX ivoa_fine_idx ON ivoa USING GIN (coverage smoc_gin_ops_fine);