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
|
|
|
-- float4 check
|
|
|
|
CREATE TABLE float4tmp (a float4);
|
|
|
|
\copy float4tmp from 'data/float4.data'
|
|
|
|
SET enable_seqscan=on;
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a < -179.0;
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
244
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a <= -179.0;
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
245
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a = -179.0;
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
1
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a >= -179.0;
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
303
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a > -179.0;
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
302
|
|
|
|
(1 row)
|
|
|
|
|
2011-03-03 03:43:24 +08:00
|
|
|
SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3;
|
|
|
|
a | ?column?
|
|
|
|
----------+----------
|
|
|
|
-179 | 0
|
|
|
|
-189.024 | 10.0239
|
|
|
|
-158.177 | 20.8226
|
|
|
|
(3 rows)
|
|
|
|
|
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
|
|
|
CREATE INDEX float4idx ON float4tmp USING gist ( a );
|
|
|
|
SET enable_seqscan=off;
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a < -179.0::float4;
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
244
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a <= -179.0::float4;
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
245
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a = -179.0::float4;
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
1
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a >= -179.0::float4;
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
303
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM float4tmp WHERE a > -179.0::float4;
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
302
|
|
|
|
(1 row)
|
|
|
|
|
2011-03-03 03:43:24 +08:00
|
|
|
EXPLAIN (COSTS OFF)
|
|
|
|
SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3;
|
|
|
|
QUERY PLAN
|
|
|
|
-----------------------------------------------
|
|
|
|
Limit
|
|
|
|
-> Index Scan using float4idx on float4tmp
|
|
|
|
Order By: (a <-> (-179)::real)
|
|
|
|
(3 rows)
|
|
|
|
|
|
|
|
SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3;
|
|
|
|
a | ?column?
|
|
|
|
----------+----------
|
|
|
|
-179 | 0
|
|
|
|
-189.024 | 10.0239
|
|
|
|
-158.177 | 20.8226
|
|
|
|
(3 rows)
|
|
|
|
|