mirror of
https://github.com/postgres/postgres.git
synced 2025-06-18 00:02:37 -04:00
Stabilize incremental_sort tests
The test never did ANALYZE on the test table, so the plans depended on various defaults (e.g. number of groups being 200). This worked most of the time, but with CLOBBER_CACHE_ALWAYS the autoanalyze often managed to build accurate stats, changing the plan. Fixed by increasing the size of test tables a bit, making the Sort a bit more expensive than Incremental Sort. The tests were constructed to test transitions in the Incremental Sort algorithm, and this change does not break that. Reviewed-by: James Coleman Discussion: https://postgr.es/m/CAPpHfds1waRZ=NOmueYq0sx1ZSCnt+5QJvizT8ndT2=etZEeAQ@mail.gmail.com
This commit is contained in:
parent
a9d70c1087
commit
cea09246e5
@ -141,7 +141,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
$$;
|
$$;
|
||||||
-- A single large group tested around each mode transition point.
|
-- A single large group tested around each mode transition point.
|
||||||
insert into t(a, b) select 1, i from generate_series(1, 100) n(i);
|
insert into t(a, b) select i/100 + 1, i + 1 from generate_series(0, 999) n(i);
|
||||||
|
analyze t;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
---------------------------------
|
---------------------------------
|
||||||
@ -456,7 +457,8 @@ select * from (select * from t order by a) s order by a, b limit 66;
|
|||||||
|
|
||||||
delete from t;
|
delete from t;
|
||||||
-- An initial large group followed by a small group.
|
-- An initial large group followed by a small group.
|
||||||
insert into t(a, b) select (case when i < 50 then 1 else 2 end), i from generate_series(1, 100) n(i);
|
insert into t(a, b) select i/50 + 1, i + 1 from generate_series(0, 999) n(i);
|
||||||
|
analyze t;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 55;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 55;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
---------------------------------
|
---------------------------------
|
||||||
@ -521,7 +523,7 @@ select * from (select * from t order by a) s order by a, b limit 55;
|
|||||||
1 | 47
|
1 | 47
|
||||||
1 | 48
|
1 | 48
|
||||||
1 | 49
|
1 | 49
|
||||||
2 | 50
|
1 | 50
|
||||||
2 | 51
|
2 | 51
|
||||||
2 | 52
|
2 | 52
|
||||||
2 | 53
|
2 | 53
|
||||||
@ -538,10 +540,10 @@ select explain_analyze_without_memory('select * from (select * from t order by a
|
|||||||
Sort Key: t.a, t.b
|
Sort Key: t.a, t.b
|
||||||
Presorted Key: t.a
|
Presorted Key: t.a
|
||||||
Full-sort Groups: 2 Sort Methods: top-N heapsort, quicksort Memory: avg=NNkB peak=NNkB
|
Full-sort Groups: 2 Sort Methods: top-N heapsort, quicksort Memory: avg=NNkB peak=NNkB
|
||||||
-> Sort (actual rows=100 loops=1)
|
-> Sort (actual rows=101 loops=1)
|
||||||
Sort Key: t.a
|
Sort Key: t.a
|
||||||
Sort Method: quicksort Memory: NNkB
|
Sort Method: quicksort Memory: NNkB
|
||||||
-> Seq Scan on t (actual rows=100 loops=1)
|
-> Seq Scan on t (actual rows=1000 loops=1)
|
||||||
(9 rows)
|
(9 rows)
|
||||||
|
|
||||||
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'));
|
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 *
|
|||||||
|
|
||||||
delete from t;
|
delete from t;
|
||||||
-- An initial small group followed by a large group.
|
-- An initial small group followed by a large group.
|
||||||
insert into t(a, b) select (case when i < 5 then i else 9 end), i from generate_series(1, 100) n(i);
|
insert into t(a, b) select (case when i < 5 then i else 9 end), i from generate_series(1, 1000) n(i);
|
||||||
|
analyze t;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 70;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 70;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
---------------------------------
|
---------------------------------
|
||||||
@ -706,16 +709,16 @@ rollback;
|
|||||||
-- Test EXPLAIN ANALYZE with both fullsort and presorted groups.
|
-- Test EXPLAIN ANALYZE with both fullsort and presorted groups.
|
||||||
select explain_analyze_without_memory('select * from (select * from t order by a) s order by a, b limit 70');
|
select explain_analyze_without_memory('select * from (select * from t order by a) s order by a, b limit 70');
|
||||||
explain_analyze_without_memory
|
explain_analyze_without_memory
|
||||||
-----------------------------------------------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
Limit (actual rows=70 loops=1)
|
Limit (actual rows=70 loops=1)
|
||||||
-> Incremental Sort (actual rows=70 loops=1)
|
-> Incremental Sort (actual rows=70 loops=1)
|
||||||
Sort Key: t.a, t.b
|
Sort Key: t.a, t.b
|
||||||
Presorted Key: t.a
|
Presorted Key: t.a
|
||||||
Full-sort Groups: 1 Sort Method: quicksort Memory: avg=NNkB peak=NNkB Presorted Groups: 5 Sort Method: quicksort Memory: avg=NNkB peak=NNkB
|
Full-sort Groups: 1 Sort Method: quicksort Memory: avg=NNkB peak=NNkB Presorted Groups: 5 Sort Methods: top-N heapsort, quicksort Memory: avg=NNkB peak=NNkB
|
||||||
-> Sort (actual rows=100 loops=1)
|
-> Sort (actual rows=1000 loops=1)
|
||||||
Sort Key: t.a
|
Sort Key: t.a
|
||||||
Sort Method: quicksort Memory: NNkB
|
Sort Method: quicksort Memory: NNkB
|
||||||
-> Seq Scan on t (actual rows=100 loops=1)
|
-> Seq Scan on t (actual rows=1000 loops=1)
|
||||||
(9 rows)
|
(9 rows)
|
||||||
|
|
||||||
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'));
|
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
|
|||||||
"Presorted Groups": { +
|
"Presorted Groups": { +
|
||||||
"Group Count": 5, +
|
"Group Count": 5, +
|
||||||
"Sort Methods Used": [ +
|
"Sort Methods Used": [ +
|
||||||
|
"top-N heapsort", +
|
||||||
"quicksort" +
|
"quicksort" +
|
||||||
], +
|
], +
|
||||||
"Sort Space Memory": { +
|
"Sort Space Memory": { +
|
||||||
@ -767,7 +771,8 @@ select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select *
|
|||||||
|
|
||||||
delete from t;
|
delete from t;
|
||||||
-- Small groups of 10 tuples each tested around each mode transition point.
|
-- Small groups of 10 tuples each tested around each mode transition point.
|
||||||
insert into t(a, b) select i / 10, i from generate_series(1, 70) n(i);
|
insert into t(a, b) select i / 10, i from generate_series(1, 1000) n(i);
|
||||||
|
analyze t;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
---------------------------------
|
---------------------------------
|
||||||
@ -1082,7 +1087,8 @@ select * from (select * from t order by a) s order by a, b limit 66;
|
|||||||
|
|
||||||
delete from t;
|
delete from t;
|
||||||
-- Small groups of only 1 tuple each tested around each mode transition point.
|
-- Small groups of only 1 tuple each tested around each mode transition point.
|
||||||
insert into t(a, b) select i, i from generate_series(1, 70) n(i);
|
insert into t(a, b) select i, i from generate_series(1, 1000) n(i);
|
||||||
|
analyze t;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
@ -119,7 +119,8 @@ end;
|
|||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- A single large group tested around each mode transition point.
|
-- A single large group tested around each mode transition point.
|
||||||
insert into t(a, b) select 1, i from generate_series(1, 100) n(i);
|
insert into t(a, b) select i/100 + 1, i + 1 from generate_series(0, 999) n(i);
|
||||||
|
analyze t;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
||||||
select * from (select * from t order by a) s order by a, b limit 31;
|
select * from (select * from t order by a) s order by a, b limit 31;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 32;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 32;
|
||||||
@ -133,7 +134,8 @@ select * from (select * from t order by a) s order by a, b limit 66;
|
|||||||
delete from t;
|
delete from t;
|
||||||
|
|
||||||
-- An initial large group followed by a small group.
|
-- An initial large group followed by a small group.
|
||||||
insert into t(a, b) select (case when i < 50 then 1 else 2 end), i from generate_series(1, 100) n(i);
|
insert into t(a, b) select i/50 + 1, i + 1 from generate_series(0, 999) n(i);
|
||||||
|
analyze t;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 55;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 55;
|
||||||
select * from (select * from t order by a) s order by a, b limit 55;
|
select * from (select * from t order by a) s order by a, b limit 55;
|
||||||
-- Test EXPLAIN ANALYZE with only a fullsort group.
|
-- Test EXPLAIN ANALYZE with only a fullsort group.
|
||||||
@ -143,7 +145,8 @@ select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select *
|
|||||||
delete from t;
|
delete from t;
|
||||||
|
|
||||||
-- An initial small group followed by a large group.
|
-- An initial small group followed by a large group.
|
||||||
insert into t(a, b) select (case when i < 5 then i else 9 end), i from generate_series(1, 100) n(i);
|
insert into t(a, b) select (case when i < 5 then i else 9 end), i from generate_series(1, 1000) n(i);
|
||||||
|
analyze t;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 70;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 70;
|
||||||
select * from (select * from t order by a) s order by a, b limit 70;
|
select * from (select * from t order by a) s order by a, b limit 70;
|
||||||
-- Test rescan.
|
-- Test rescan.
|
||||||
@ -164,7 +167,8 @@ select explain_analyze_inc_sort_nodes_verify_invariants('select * from (select *
|
|||||||
delete from t;
|
delete from t;
|
||||||
|
|
||||||
-- Small groups of 10 tuples each tested around each mode transition point.
|
-- Small groups of 10 tuples each tested around each mode transition point.
|
||||||
insert into t(a, b) select i / 10, i from generate_series(1, 70) n(i);
|
insert into t(a, b) select i / 10, i from generate_series(1, 1000) n(i);
|
||||||
|
analyze t;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
||||||
select * from (select * from t order by a) s order by a, b limit 31;
|
select * from (select * from t order by a) s order by a, b limit 31;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 32;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 32;
|
||||||
@ -178,7 +182,8 @@ select * from (select * from t order by a) s order by a, b limit 66;
|
|||||||
delete from t;
|
delete from t;
|
||||||
|
|
||||||
-- Small groups of only 1 tuple each tested around each mode transition point.
|
-- Small groups of only 1 tuple each tested around each mode transition point.
|
||||||
insert into t(a, b) select i, i from generate_series(1, 70) n(i);
|
insert into t(a, b) select i, i from generate_series(1, 1000) n(i);
|
||||||
|
analyze t;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 31;
|
||||||
select * from (select * from t order by a) s order by a, b limit 31;
|
select * from (select * from t order by a) s order by a, b limit 31;
|
||||||
explain (costs off) select * from (select * from t order by a) s order by a, b limit 32;
|
explain (costs off) select * from (select * from t order by a) s order by a, b limit 32;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user