mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-29 02:17:18 +02:00
This extends GiST's support for nearest-neighbor searches to many of the standard data types. Teodor Sigaev
38 lines
1022 B
SQL
38 lines
1022 B
SQL
-- date check
|
|
|
|
CREATE TABLE datetmp (a date);
|
|
|
|
\copy datetmp from 'data/date.data'
|
|
|
|
SET enable_seqscan=on;
|
|
|
|
SELECT count(*) FROM datetmp WHERE a < '2001-02-13';
|
|
|
|
SELECT count(*) FROM datetmp WHERE a <= '2001-02-13';
|
|
|
|
SELECT count(*) FROM datetmp WHERE a = '2001-02-13';
|
|
|
|
SELECT count(*) FROM datetmp WHERE a >= '2001-02-13';
|
|
|
|
SELECT count(*) FROM datetmp WHERE a > '2001-02-13';
|
|
|
|
SELECT a, a <-> '2001-02-13' FROM datetmp ORDER BY a <-> '2001-02-13' LIMIT 3;
|
|
|
|
CREATE INDEX dateidx ON datetmp USING gist ( a );
|
|
|
|
SET enable_seqscan=off;
|
|
|
|
SELECT count(*) FROM datetmp WHERE a < '2001-02-13'::date;
|
|
|
|
SELECT count(*) FROM datetmp WHERE a <= '2001-02-13'::date;
|
|
|
|
SELECT count(*) FROM datetmp WHERE a = '2001-02-13'::date;
|
|
|
|
SELECT count(*) FROM datetmp WHERE a >= '2001-02-13'::date;
|
|
|
|
SELECT count(*) FROM datetmp WHERE a > '2001-02-13'::date;
|
|
|
|
EXPLAIN (COSTS OFF)
|
|
SELECT a, a <-> '2001-02-13' FROM datetmp ORDER BY a <-> '2001-02-13' LIMIT 3;
|
|
SELECT a, a <-> '2001-02-13' FROM datetmp ORDER BY a <-> '2001-02-13' LIMIT 3;
|