mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-25 07:37:18 +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
99 lines
1.9 KiB
Plaintext
99 lines
1.9 KiB
Plaintext
-- enum check
|
|
create type rainbow as enum ('r','o','y','g','b','i','v');
|
|
CREATE TABLE enumtmp (a rainbow);
|
|
\copy enumtmp from 'data/enum.data'
|
|
SET enable_seqscan=on;
|
|
select a, count(*) from enumtmp group by a order by 1;
|
|
a | count
|
|
---+-------
|
|
r | 76
|
|
o | 78
|
|
y | 73
|
|
g | 75
|
|
b | 77
|
|
i | 78
|
|
v | 75
|
|
| 63
|
|
(8 rows)
|
|
|
|
SELECT count(*) FROM enumtmp WHERE a < 'g'::rainbow;
|
|
count
|
|
-------
|
|
227
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM enumtmp WHERE a <= 'g'::rainbow;
|
|
count
|
|
-------
|
|
302
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM enumtmp WHERE a = 'g'::rainbow;
|
|
count
|
|
-------
|
|
75
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
|
|
count
|
|
-------
|
|
305
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM enumtmp WHERE a > 'g'::rainbow;
|
|
count
|
|
-------
|
|
230
|
|
(1 row)
|
|
|
|
SET client_min_messages = DEBUG1;
|
|
CREATE INDEX enumidx ON enumtmp USING gist ( a );
|
|
DEBUG: building index "enumidx" on table "enumtmp" serially
|
|
DEBUG: using sorted GiST build
|
|
CREATE INDEX enumidx_b ON enumtmp USING gist ( a ) WITH (buffering=on);
|
|
DEBUG: building index "enumidx_b" on table "enumtmp" serially
|
|
DROP INDEX enumidx_b;
|
|
RESET client_min_messages;
|
|
SET enable_seqscan=off;
|
|
SELECT count(*) FROM enumtmp WHERE a < 'g'::rainbow;
|
|
count
|
|
-------
|
|
227
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM enumtmp WHERE a <= 'g'::rainbow;
|
|
count
|
|
-------
|
|
302
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM enumtmp WHERE a = 'g'::rainbow;
|
|
count
|
|
-------
|
|
75
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
|
|
count
|
|
-------
|
|
305
|
|
(1 row)
|
|
|
|
SELECT count(*) FROM enumtmp WHERE a > 'g'::rainbow;
|
|
count
|
|
-------
|
|
230
|
|
(1 row)
|
|
|
|
EXPLAIN (COSTS OFF)
|
|
SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
|
|
QUERY PLAN
|
|
-----------------------------------------------
|
|
Aggregate
|
|
-> Bitmap Heap Scan on enumtmp
|
|
Recheck Cond: (a >= 'g'::rainbow)
|
|
-> Bitmap Index Scan on enumidx
|
|
Index Cond: (a >= 'g'::rainbow)
|
|
(5 rows)
|
|
|