The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/14/spgist-builtin-opclasses.html
Description:
I wanted to add an SP-GIST index for an inet field ip_address
In https://www.postgresql.org/docs/14/spgist-builtin-opclasses.html
network_ops is stated as the built-in opclass for (inet, inet)
On this basis, on this version of pgsql:
psql (15.1 (Debian 15.1-1.pgdg110+1), server 14.6 (Debian
14.6-1.pgdg110+1))
I entered the following command:
# create index concurrently ip_address_spgist_ban_by_ip on ban_by_ip using
spgist (ip_address network_ops);
ERROR: operator class "network_ops" does not exist for access method
"spgist"
However, this worked:
# create index concurrently ip_address_spgist_ban_by_ip on ban_by_ip using
spgist (ip_address inet_ops);
CREATE INDEX
This created the index:
"ip_address_spgist_ban_by_ip" spgist (ip_address)
which worked as expected:
# EXPLAIN ANALYZE select * from ban_by_ip where ip_address >>= '1.2.3.4' and
now() < banuntil_datetime;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------
Index Scan using ip_address_spgist_ban_by_ip on ban_by_ip (cost=0.14..2.57
rows=1 width=32) (actual time=0.013..0.013 rows=0 loops=1)
Index Cond: (ip_address >>= '1.2.3.4'::inet)
Filter: (now() < banuntil_datetime)
Planning Time: 0.149 ms
Execution Time: 0.027 ms
(5 rows)
I notice inet_ops, not network_ops, is mentioned in the docs for 13. Perhaps
it was renamed to network_ops in 15 but not 14?