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 12:43:32 +02:00
|
|
|
-- timestamp check
|
|
|
|
CREATE TABLE timestamptmp (a timestamp);
|
|
|
|
\copy timestamptmp from 'data/timestamp.data'
|
|
|
|
SET enable_seqscan=on;
|
|
|
|
SELECT count(*) FROM timestamptmp WHERE a < '2004-10-26 08:55:08';
|
|
|
|
count
|
|
|
|
-------
|
2005-07-01 15:44:56 +02:00
|
|
|
278
|
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 12:43:32 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM timestamptmp WHERE a <= '2004-10-26 08:55:08';
|
|
|
|
count
|
|
|
|
-------
|
2005-07-01 15:44:56 +02:00
|
|
|
279
|
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 12:43:32 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM timestamptmp WHERE a = '2004-10-26 08:55:08';
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
1
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM timestamptmp WHERE a >= '2004-10-26 08:55:08';
|
|
|
|
count
|
|
|
|
-------
|
2005-07-01 15:44:56 +02:00
|
|
|
290
|
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 12:43:32 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM timestamptmp WHERE a > '2004-10-26 08:55:08';
|
|
|
|
count
|
|
|
|
-------
|
2005-07-01 15:44:56 +02:00
|
|
|
289
|
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 12:43:32 +02:00
|
|
|
(1 row)
|
|
|
|
|
2011-03-02 20:43:24 +01:00
|
|
|
SELECT a, a <-> '2004-10-26 08:55:08' FROM timestamptmp ORDER BY a <-> '2004-10-26 08:55:08' LIMIT 3;
|
|
|
|
a | ?column?
|
|
|
|
--------------------------+------------------------------------
|
|
|
|
Tue Oct 26 08:55:08 2004 | @ 0
|
|
|
|
Sun Oct 31 06:35:03 2004 | @ 4 days 21 hours 39 mins 55 secs
|
|
|
|
Mon Nov 29 20:12:43 2004 | @ 34 days 11 hours 17 mins 35 secs
|
|
|
|
(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 12:43:32 +02:00
|
|
|
CREATE INDEX timestampidx ON timestamptmp USING gist ( a );
|
|
|
|
SET enable_seqscan=off;
|
|
|
|
SELECT count(*) FROM timestamptmp WHERE a < '2004-10-26 08:55:08'::timestamp;
|
|
|
|
count
|
|
|
|
-------
|
2005-07-01 15:44:56 +02:00
|
|
|
278
|
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 12:43:32 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM timestamptmp WHERE a <= '2004-10-26 08:55:08'::timestamp;
|
|
|
|
count
|
|
|
|
-------
|
2005-07-01 15:44:56 +02:00
|
|
|
279
|
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 12:43:32 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM timestamptmp WHERE a = '2004-10-26 08:55:08'::timestamp;
|
|
|
|
count
|
|
|
|
-------
|
|
|
|
1
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM timestamptmp WHERE a >= '2004-10-26 08:55:08'::timestamp;
|
|
|
|
count
|
|
|
|
-------
|
2005-07-01 15:44:56 +02:00
|
|
|
290
|
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 12:43:32 +02:00
|
|
|
(1 row)
|
|
|
|
|
|
|
|
SELECT count(*) FROM timestamptmp WHERE a > '2004-10-26 08:55:08'::timestamp;
|
|
|
|
count
|
|
|
|
-------
|
2005-07-01 15:44:56 +02:00
|
|
|
289
|
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 12:43:32 +02:00
|
|
|
(1 row)
|
|
|
|
|
2011-03-02 20:43:24 +01:00
|
|
|
EXPLAIN (COSTS OFF)
|
|
|
|
SELECT a, a <-> '2004-10-26 08:55:08' FROM timestamptmp ORDER BY a <-> '2004-10-26 08:55:08' LIMIT 3;
|
|
|
|
QUERY PLAN
|
|
|
|
-----------------------------------------------------------------------------------
|
|
|
|
Limit
|
2015-03-27 22:35:16 +01:00
|
|
|
-> Index Only Scan using timestampidx on timestamptmp
|
2011-03-02 20:43:24 +01:00
|
|
|
Order By: (a <-> 'Tue Oct 26 08:55:08 2004'::timestamp without time zone)
|
|
|
|
(3 rows)
|
|
|
|
|
|
|
|
SELECT a, a <-> '2004-10-26 08:55:08' FROM timestamptmp ORDER BY a <-> '2004-10-26 08:55:08' LIMIT 3;
|
|
|
|
a | ?column?
|
|
|
|
--------------------------+------------------------------------
|
|
|
|
Tue Oct 26 08:55:08 2004 | @ 0
|
|
|
|
Sun Oct 31 06:35:03 2004 | @ 4 days 21 hours 39 mins 55 secs
|
|
|
|
Mon Nov 29 20:12:43 2004 | @ 34 days 11 hours 17 mins 35 secs
|
|
|
|
(3 rows)
|
|
|
|
|