mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-27 07:17:20 +02:00
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
90 lines
1.8 KiB
Plaintext
90 lines
1.8 KiB
Plaintext
-- char check
|
|
CREATE TABLE chartmp (a char(32));
|
|
\copy chartmp from 'data/char.data'
|
|
SET enable_seqscan=on;
|
|
SELECT count(*) FROM chartmp WHERE a < '31b0'::char(32);
|
|
count
|
|
-------
|
|
587
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM chartmp WHERE a <= '31b0'::char(32);
|
|
count
|
|
-------
|
|
588
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM chartmp WHERE a = '31b0'::char(32);
|
|
count
|
|
-------
|
|
1
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM chartmp WHERE a >= '31b0'::char(32);
|
|
count
|
|
-------
|
|
401
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM chartmp WHERE a > '31b0'::char(32);
|
|
count
|
|
-------
|
|
400
|
|
(1 row)
|
|
|
|
SET client_min_messages = DEBUG1;
|
|
CREATE INDEX charidx ON chartmp USING GIST ( a );
|
|
DEBUG: building index "charidx" on table "chartmp" serially
|
|
DEBUG: using sorted GiST build
|
|
CREATE INDEX charidx_b ON chartmp USING GIST ( a ) WITH (buffering=on);
|
|
DEBUG: building index "charidx_b" on table "chartmp" serially
|
|
DROP INDEX charidx_b;
|
|
RESET client_min_messages;
|
|
SET enable_seqscan=off;
|
|
SELECT count(*) FROM chartmp WHERE a < '31b0'::char(32);
|
|
count
|
|
-------
|
|
587
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM chartmp WHERE a <= '31b0'::char(32);
|
|
count
|
|
-------
|
|
588
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM chartmp WHERE a = '31b0'::char(32);
|
|
count
|
|
-------
|
|
1
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM chartmp WHERE a >= '31b0'::char(32);
|
|
count
|
|
-------
|
|
401
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM chartmp WHERE a > '31b0'::char(32);
|
|
count
|
|
-------
|
|
400
|
|
(1 row)
|
|
|
|
-- Test index-only scans
|
|
SET enable_bitmapscan=off;
|
|
EXPLAIN (COSTS OFF)
|
|
SELECT * FROM chartmp WHERE a BETWEEN '31a' AND '31c';
|
|
QUERY PLAN
|
|
---------------------------------------------------------------
|
|
Index Only Scan using charidx on chartmp
|
|
Index Cond: ((a >= '31a'::bpchar) AND (a <= '31c'::bpchar))
|
|
(2 rows)
|
|
|
|
SELECT * FROM chartmp WHERE a BETWEEN '31a' AND '31c';
|
|
a
|
|
------
|
|
31b0
|
|
(1 row)
|
|
|