1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-18 13:44:19 +03:00
Heikki Linnakangas e4309f73f6 Add support for sorted gist index builds to btree_gist
This enables sortsupport in the btree_gist extension for faster builds
of gist indexes.

Sorted gist index build strategy is the new default now. Regression
tests are unchanged (except for one small change in the 'enum' test to
add coverage for enum values added later) and are using the sorted
build strategy instead.

One version of this was committed a long time ago already, in commit
9f984ba6d2, but it was quickly reverted because of buildfarm
failures. The failures were presumably caused by some small bugs, but
we never got around to debug and commit it again. This patch was
written from scratch, implementing the same idea, with some fragments
and ideas from the original patch.

Author: Bernd Helmle <mailings@oopsware.de>
Author: Andrey Borodin <x4mmm@yandex-team.ru>
Discussion: https://www.postgresql.org/message-id/64d324ce2a6d535d3f0f3baeeea7b25beff82ce4.camel@oopsware.de
2025-04-03 13:46:35 +03:00

95 lines
1.8 KiB
Plaintext

-- enum check
create type rainbow as enum ('r','o','g','b','i','v');
-- enum values added later take some different codepaths internally,
-- so make sure we have coverage for those too
alter type rainbow add value 'y' before 'g';
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)
CREATE INDEX enumidx ON enumtmp USING gist ( a );
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)