postgresql/contrib/btree_gist/expected/timestamptz.out
Heikki Linnakangas 9f984ba6d2 Add sortsupport for gist_btree opclasses, for faster index builds.
Commit 16fa9b2b30 introduced a faster way to build GiST indexes, by
sorting all the data. This commit adds the sortsupport functions needed
to make use of that feature for btree_gist.

Author: Andrey Borodin
Discussion: https://www.postgresql.org/message-id/2F3F7265-0D22-44DB-AD71-8554C743D943@yandex-team.ru
2021-04-07 13:22:05 +03:00

219 lines
5.2 KiB
Plaintext

-- timestamptz check
CREATE TABLE timestamptztmp (a timestamptz);
\copy timestamptztmp from 'data/timestamptz.data'
SET enable_seqscan=on;
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+3';
count
-------
391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+3';
count
-------
392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+3';
count
-------
1
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+3';
count
-------
158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+3';
count
-------
157
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+2';
count
-------
391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+2';
count
-------
391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+2';
count
-------
0
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+2';
count
-------
158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+2';
count
-------
158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+4';
count
-------
392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+4';
count
-------
392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+4';
count
-------
0
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+4';
count
-------
157
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+4';
count
-------
157
(1 row)
SELECT a, a <-> '2018-12-18 10:59:54 GMT+2' FROM timestamptztmp ORDER BY a <-> '2018-12-18 10:59:54 GMT+2' LIMIT 3;
a | ?column?
------------------------------+-----------------------------------
Tue Dec 18 05:59:54 2018 PST | @ 1 hour
Thu Jan 10 03:01:34 2019 PST | @ 22 days 22 hours 1 min 40 secs
Thu Jan 24 12:28:12 2019 PST | @ 37 days 7 hours 28 mins 18 secs
(3 rows)
SET client_min_messages = DEBUG1;
CREATE INDEX timestamptzidx ON timestamptztmp USING gist ( a );
DEBUG: building index "timestamptzidx" on table "timestamptztmp" serially
DEBUG: using sorted GiST build
CREATE INDEX timestamptzidx_b ON timestamptztmp USING gist ( a ) WITH (buffering=on);
DEBUG: building index "timestamptzidx_b" on table "timestamptztmp" serially
DROP INDEX timestamptzidx_b;
RESET client_min_messages;
SET enable_seqscan=off;
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+3'::timestamptz;
count
-------
391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+3'::timestamptz;
count
-------
392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+3'::timestamptz;
count
-------
1
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+3'::timestamptz;
count
-------
158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+3'::timestamptz;
count
-------
157
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+2'::timestamptz;
count
-------
391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+2'::timestamptz;
count
-------
391
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+2'::timestamptz;
count
-------
0
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+2'::timestamptz;
count
-------
158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+2'::timestamptz;
count
-------
158
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a < '2018-12-18 10:59:54 GMT+4'::timestamptz;
count
-------
392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a <= '2018-12-18 10:59:54 GMT+4'::timestamptz;
count
-------
392
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a = '2018-12-18 10:59:54 GMT+4'::timestamptz;
count
-------
0
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a >= '2018-12-18 10:59:54 GMT+4'::timestamptz;
count
-------
157
(1 row)
SELECT count(*) FROM timestamptztmp WHERE a > '2018-12-18 10:59:54 GMT+4'::timestamptz;
count
-------
157
(1 row)
EXPLAIN (COSTS OFF)
SELECT a, a <-> '2018-12-18 10:59:54 GMT+2' FROM timestamptztmp ORDER BY a <-> '2018-12-18 10:59:54 GMT+2' LIMIT 3;
QUERY PLAN
------------------------------------------------------------------------------------
Limit
-> Index Only Scan using timestamptzidx on timestamptztmp
Order By: (a <-> 'Tue Dec 18 04:59:54 2018 PST'::timestamp with time zone)
(3 rows)
SELECT a, a <-> '2018-12-18 10:59:54 GMT+2' FROM timestamptztmp ORDER BY a <-> '2018-12-18 10:59:54 GMT+2' LIMIT 3;
a | ?column?
------------------------------+-----------------------------------
Tue Dec 18 05:59:54 2018 PST | @ 1 hour
Thu Jan 10 03:01:34 2019 PST | @ 22 days 22 hours 1 min 40 secs
Thu Jan 24 12:28:12 2019 PST | @ 37 days 7 hours 28 mins 18 secs
(3 rows)