blob: 249e8085c3b3b6487be8db2adab8bed89f894c85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
-- 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;
VACUUM ANALYZE inettmp;
-- 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);
-- this can be an index-only scan, as long as the planner uses the right column
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;
|