blob: 7fbc7355929a1b944ab9738e651b955ee99c29d0 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
-- money check
CREATE TABLE moneytmp (a money);
\copy moneytmp from 'data/cash.data'
SET enable_seqscan=on;
SELECT count(*) FROM moneytmp WHERE a < '22649.64';
count
-------
289
(1 row)
SELECT count(*) FROM moneytmp WHERE a <= '22649.64';
count
-------
290
(1 row)
SELECT count(*) FROM moneytmp WHERE a = '22649.64';
count
-------
1
(1 row)
SELECT count(*) FROM moneytmp WHERE a >= '22649.64';
count
-------
254
(1 row)
SELECT count(*) FROM moneytmp WHERE a > '22649.64';
count
-------
253
(1 row)
SELECT a, a <-> '21472.79' FROM moneytmp ORDER BY a <-> '21472.79' LIMIT 3;
a | ?column?
------------+----------
$21,472.79 | $0.00
$21,469.25 | $3.54
$21,915.01 | $442.22
(3 rows)
CREATE INDEX moneyidx ON moneytmp USING gist ( a );
SET enable_seqscan=off;
SELECT count(*) FROM moneytmp WHERE a < '22649.64'::money;
count
-------
289
(1 row)
SELECT count(*) FROM moneytmp WHERE a <= '22649.64'::money;
count
-------
290
(1 row)
SELECT count(*) FROM moneytmp WHERE a = '22649.64'::money;
count
-------
1
(1 row)
SELECT count(*) FROM moneytmp WHERE a >= '22649.64'::money;
count
-------
254
(1 row)
SELECT count(*) FROM moneytmp WHERE a > '22649.64'::money;
count
-------
253
(1 row)
EXPLAIN (COSTS OFF)
SELECT a, a <-> '21472.79' FROM moneytmp ORDER BY a <-> '21472.79' LIMIT 3;
QUERY PLAN
--------------------------------------------------
Limit
-> Index Only Scan using moneyidx on moneytmp
Order By: (a <-> '$21,472.79'::money)
(3 rows)
SELECT a, a <-> '21472.79' FROM moneytmp ORDER BY a <-> '21472.79' LIMIT 3;
a | ?column?
------------+----------
$21,472.79 | $0.00
$21,469.25 | $3.54
$21,915.01 | $442.22
(3 rows)
|