New version. Add support for int2, int8, float4, float8, timestamp with/without time zone, time with/without time zone, date, interval, oid, money and macaddr, char, varchar/text, bytea, numeric, bit, varbit, inet/cidr types for GiST
2004-05-28 18:43:32 +08:00
|
|
|
-- inet check
|
|
|
|
|
|
|
|
CREATE TABLE inettmp (a inet);
|
|
|
|
|
|
|
|
\copy inettmp from 'data/inet.data'
|
|
|
|
|
|
|
|
SET enable_seqscan=on;
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a < '89.225.196.191';
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a <= '89.225.196.191';
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a = '89.225.196.191';
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a >= '89.225.196.191';
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a > '89.225.196.191';
|
|
|
|
|
|
|
|
CREATE INDEX inetidx ON inettmp USING gist ( a );
|
|
|
|
|
|
|
|
SET enable_seqscan=off;
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a < '89.225.196.191'::inet;
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a <= '89.225.196.191'::inet;
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a = '89.225.196.191'::inet;
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a >= '89.225.196.191'::inet;
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a > '89.225.196.191'::inet;
|
2018-03-02 04:35:03 +08:00
|
|
|
|
2018-10-17 00:01:18 +08:00
|
|
|
VACUUM ANALYZE inettmp;
|
2018-03-02 04:35:03 +08:00
|
|
|
|
|
|
|
-- gist_inet_ops lacks a fetch function, so this should not be index-only scan
|
|
|
|
EXPLAIN (COSTS OFF)
|
|
|
|
SELECT count(*) FROM inettmp WHERE a = '89.225.196.191'::inet;
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a = '89.225.196.191'::inet;
|
|
|
|
|
|
|
|
DROP INDEX inetidx;
|
|
|
|
|
|
|
|
CREATE INDEX ON inettmp USING gist (a gist_inet_ops, a inet_ops);
|
|
|
|
|
2022-01-04 05:12:11 +08:00
|
|
|
-- this can be an index-only scan, as long as the planner uses the right column
|
2018-03-02 04:35:03 +08:00
|
|
|
EXPLAIN (COSTS OFF)
|
|
|
|
SELECT count(*) FROM inettmp WHERE a = '89.225.196.191'::inet;
|
|
|
|
|
|
|
|
SELECT count(*) FROM inettmp WHERE a = '89.225.196.191'::inet;
|