Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcea0924

Browse files
committed
Stabilize incremental_sort tests
The test never did ANALYZE on the test table, so the plans depended onvarious defaults (e.g. number of groups being 200). This worked most ofthe time, but with CLOBBER_CACHE_ALWAYS the autoanalyze often managedto build accurate stats, changing the plan.Fixed by increasing the size of test tables a bit, making the Sort a bitmore expensive than Incremental Sort. The tests were constructed to testtransitions in the Incremental Sort algorithm, and this change does notbreak that.Reviewed-by: James ColemanDiscussion:https://postgr.es/m/CAPpHfds1waRZ=NOmueYq0sx1ZSCnt+5QJvizT8ndT2=etZEeAQ@mail.gmail.com
1 parenta9d70c1 commitcea0924

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

‎src/test/regress/expected/incremental_sort.out

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ begin
141141
end;
142142
$$;
143143
-- A single large group tested around each mode transition point.
144-
insert into t(a, b) select 1, i from generate_series(1, 100) n(i);
144+
insert into t(a, b) select i/100 + 1, i + 1 from generate_series(0, 999) n(i);
145+
analyze t;
145146
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
146147
QUERY PLAN
147148
---------------------------------
@@ -456,7 +457,8 @@ select * from (select * from t order by a) s order by a, b limit 66;
456457

457458
delete from t;
458459
-- An initial large group followed by a small group.
459-
insert into t(a, b) select (case when i < 50 then 1 else 2 end), i from generate_series(1, 100) n(i);
460+
insert into t(a, b) select i/50 + 1, i + 1 from generate_series(0, 999) n(i);
461+
analyze t;
460462
explain (costs off) select * from (select * from t order by a) s order by a, b limit 55;
461463
QUERY PLAN
462464
---------------------------------
@@ -521,7 +523,7 @@ select * from (select * from t order by a) s order by a, b limit 55;
521523
1 | 47
522524
1 | 48
523525
1 | 49
524-
2 | 50
526+
1 | 50
525527
2 | 51
526528
2 | 52
527529
2 | 53
@@ -538,10 +540,10 @@ select explain_analyze_without_memory('select * from (select * from t order by a
538540
Sort Key: t.a, t.b
539541
Presorted Key: t.a
540542
Full-sort Groups: 2 Sort Methods: top-N heapsort, quicksort Memory: avg=NNkB peak=NNkB
541-
-> Sort (actual rows=100 loops=1)
543+
-> Sort (actual rows=101 loops=1)
542544
Sort Key: t.a
543545
Sort Method: quicksort Memory: NNkB
544-
-> Seq Scan on t (actual rows=100 loops=1)
546+
-> Seq Scan on t (actual rows=1000 loops=1)
545547
(9 rows)
546548

547549
select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 55'));
@@ -584,7 +586,8 @@ select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select *
584586

585587
delete from t;
586588
-- An initial small group followed by a large group.
587-
insert into t(a, b) select (case when i < 5 then i else 9 end), i from generate_series(1, 100) n(i);
589+
insert into t(a, b) select (case when i < 5 then i else 9 end), i from generate_series(1, 1000) n(i);
590+
analyze t;
588591
explain (costs off) select * from (select * from t order by a) s order by a, b limit 70;
589592
QUERY PLAN
590593
---------------------------------
@@ -705,17 +708,17 @@ select * from t left join (select * from (select * from t order by a) v order by
705708
rollback;
706709
-- Test EXPLAIN ANALYZE with both fullsort and presorted groups.
707710
select explain_analyze_without_memory('select * from (select * from t order by a) s order by a, b limit 70');
708-
explain_analyze_without_memory
709-
-----------------------------------------------------------------------------------------------------------------------------------------------------
711+
explain_analyze_without_memory
712+
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
710713
Limit (actual rows=70 loops=1)
711714
-> Incremental Sort (actual rows=70 loops=1)
712715
Sort Key: t.a, t.b
713716
Presorted Key: t.a
714-
Full-sort Groups: 1 Sort Method: quicksort Memory: avg=NNkB peak=NNkB Presorted Groups: 5 SortMethod: quicksort Memory: avg=NNkB peak=NNkB
715-
-> Sort (actual rows=100 loops=1)
717+
Full-sort Groups: 1 Sort Method: quicksort Memory: avg=NNkB peak=NNkB Presorted Groups: 5 SortMethods: top-N heapsort, quicksort Memory: avg=NNkB peak=NNkB
718+
-> Sort (actual rows=1000 loops=1)
716719
Sort Key: t.a
717720
Sort Method: quicksort Memory: NNkB
718-
-> Seq Scan on t (actual rows=100 loops=1)
721+
-> Seq Scan on t (actual rows=1000 loops=1)
719722
(9 rows)
720723

721724
select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 70'));
@@ -747,6 +750,7 @@ select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from
747750
"Presorted Groups": { +
748751
"Group Count": 5, +
749752
"Sort Methods Used": [ +
753+
"top-N heapsort", +
750754
"quicksort" +
751755
], +
752756
"Sort Space Memory": { +
@@ -767,7 +771,8 @@ select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select *
767771

768772
delete from t;
769773
-- Small groups of 10 tuples each tested around each mode transition point.
770-
insert into t(a, b) select i / 10, i from generate_series(1, 70) n(i);
774+
insert into t(a, b) select i / 10, i from generate_series(1, 1000) n(i);
775+
analyze t;
771776
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
772777
QUERY PLAN
773778
---------------------------------
@@ -1082,7 +1087,8 @@ select * from (select * from t order by a) s order by a, b limit 66;
10821087

10831088
delete from t;
10841089
-- Small groups of only 1 tuple each tested around each mode transition point.
1085-
insert into t(a, b) select i, i from generate_series(1, 70) n(i);
1090+
insert into t(a, b) select i, i from generate_series(1, 1000) n(i);
1091+
analyze t;
10861092
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
10871093
QUERY PLAN
10881094
---------------------------------

‎src/test/regress/sql/incremental_sort.sql

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ end;
119119
$$;
120120

121121
-- A single large group tested around each mode transition point.
122-
insert into t(a, b)select1, ifrom generate_series(1,100) n(i);
122+
insert into t(a, b)select i/100+1, i+1from generate_series(0,999) n(i);
123+
analyze t;
123124
explain (costs off)select*from (select*from torder by a) sorder by a, blimit31;
124125
select*from (select*from torder by a) sorder by a, blimit31;
125126
explain (costs off)select*from (select*from torder by a) sorder by a, blimit32;
@@ -133,7 +134,8 @@ select * from (select * from t order by a) s order by a, b limit 66;
133134
deletefrom t;
134135

135136
-- An initial large group followed by a small group.
136-
insert into t(a, b)select (case when i<50 then1 else2 end), ifrom generate_series(1,100) n(i);
137+
insert into t(a, b)select i/50+1, i+1from generate_series(0,999) n(i);
138+
analyze t;
137139
explain (costs off)select*from (select*from torder by a) sorder by a, blimit55;
138140
select*from (select*from torder by a) sorder by a, blimit55;
139141
-- Test EXPLAIN ANALYZE with only a fullsort group.
@@ -143,7 +145,8 @@ select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select *
143145
deletefrom t;
144146

145147
-- An initial small group followed by a large group.
146-
insert into t(a, b)select (case when i<5 then i else9 end), ifrom generate_series(1,100) n(i);
148+
insert into t(a, b)select (case when i<5 then i else9 end), ifrom generate_series(1,1000) n(i);
149+
analyze t;
147150
explain (costs off)select*from (select*from torder by a) sorder by a, blimit70;
148151
select*from (select*from torder by a) sorder by a, blimit70;
149152
-- Test rescan.
@@ -164,7 +167,8 @@ select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select *
164167
deletefrom t;
165168

166169
-- Small groups of 10 tuples each tested around each mode transition point.
167-
insert into t(a, b)select i/10, ifrom generate_series(1,70) n(i);
170+
insert into t(a, b)select i/10, ifrom generate_series(1,1000) n(i);
171+
analyze t;
168172
explain (costs off)select*from (select*from torder by a) sorder by a, blimit31;
169173
select*from (select*from torder by a) sorder by a, blimit31;
170174
explain (costs off)select*from (select*from torder by a) sorder by a, blimit32;
@@ -178,7 +182,8 @@ select * from (select * from t order by a) s order by a, b limit 66;
178182
deletefrom t;
179183

180184
-- Small groups of only 1 tuple each tested around each mode transition point.
181-
insert into t(a, b)select i, ifrom generate_series(1,70) n(i);
185+
insert into t(a, b)select i, ifrom generate_series(1,1000) n(i);
186+
analyze t;
182187
explain (costs off)select*from (select*from torder by a) sorder by a, blimit31;
183188
select*from (select*from torder by a) sorder by a, blimit31;
184189
explain (costs off)select*from (select*from torder by a) sorder by a, blimit32;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp