Naming of network_ops vs. inet_ops for SP-GIST
The Post Office <noreply@postgresql.org>
From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: greenreaper@hotmail.com
Date: 2023-01-24T17:25:06Z
Lists: pgsql-docs
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?
Commits
-
doc: Fix network_ops -> inet_ops in SpGiST operator class list
- e9774151c278 14.7 landed
- 88c27b8fe201 15.2 landed
- d7c4830abb18 16.0 landed
-
doc: Rework tables for built-in operator classes of index AMs
- 7a1cd5260aa2 14.0 cited