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

Commit6280d4e

Browse files
committed
improve regression tests for RuntimeAppend
1 parent845d7c8 commit6280d4e

File tree

4 files changed

+60
-40
lines changed

4 files changed

+60
-40
lines changed

‎expected/pathman_runtime_nodes.out

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,15 @@ select pathman.create_hash_partitions('test.runtime_test_3', 'id', 4);
260260

261261
create index on test.runtime_test_3 (id);
262262
create index on test.runtime_test_3_0 (id);
263+
create table test.runtime_test_4(val text, id int not null);
264+
insert into test.runtime_test_4(id, val) select * from generate_series(1, 10000) k, md5(k::text);
265+
select pathman.create_range_partitions('test.runtime_test_4', 'id', 1, 2000);
266+
NOTICE: sequence "runtime_test_4_seq" does not exist, skipping
267+
create_range_partitions
268+
-------------------------
269+
5
270+
(1 row)
271+
263272
VACUUM ANALYZE;
264273
set pg_pathman.enable_runtimeappend = on;
265274
set pg_pathman.enable_runtimemergeappend = on;
@@ -293,19 +302,6 @@ select test.pathman_test_5(); /* projection tests for RuntimeXXX nodes */
293302
ok
294303
(1 row)
295304

296-
/* RuntimeAppend (select ... where id = ANY (subquery), missing partitions) */
297-
select count(*) = 0 from pathman.pathman_partition_list
298-
where parent = 'test.runtime_test_1'::regclass and range_max::int < 0;
299-
?column?
300-
----------
301-
t
302-
(1 row)
303-
304-
select from test.runtime_test_1
305-
where id = any (select generate_series(-10, -1)); /* should be empty */
306-
--
307-
(0 rows)
308-
309305
/* RuntimeAppend (join, enabled parent) */
310306
select pathman.set_enable_parent('test.runtime_test_1', true);
311307
set_enable_parent
@@ -393,7 +389,24 @@ join (select * from test.run_values limit 4) as t2 on t1.id = t2.val;
393389
2
394390
(8 rows)
395391

392+
/* RuntimeAppend (select ... where id = ANY (subquery), missing partitions) */
393+
select count(*) = 0 from pathman.pathman_partition_list
394+
where parent = 'test.runtime_test_4'::regclass and coalesce(range_min::int, 1) < 0;
395+
?column?
396+
----------
397+
t
398+
(1 row)
399+
400+
set enable_hashjoin = off;
401+
set enable_mergejoin = off;
402+
select from test.runtime_test_4
403+
where id = any (select generate_series(-10, -1)); /* should be empty */
404+
--
405+
(0 rows)
406+
407+
set enable_hashjoin = on;
408+
set enable_mergejoin = on;
396409
DROP SCHEMA test CASCADE;
397-
NOTICE: drop cascades to30 other objects
410+
NOTICE: drop cascades to37 other objects
398411
DROP EXTENSION pg_pathman CASCADE;
399412
DROP SCHEMA pathman CASCADE;

‎sql/pathman_runtime_nodes.sql

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ select pathman.create_hash_partitions('test.runtime_test_3', 'id', 4);
261261
createindexontest.runtime_test_3 (id);
262262
createindexontest.runtime_test_3_0 (id);
263263

264+
createtabletest.runtime_test_4(valtext, idintnot null);
265+
insert intotest.runtime_test_4(id, val)select*from generate_series(1,10000) k, md5(k::text);
266+
selectpathman.create_range_partitions('test.runtime_test_4','id',1,2000);
267+
264268

265269
VACUUM ANALYZE;
266270

@@ -274,12 +278,6 @@ select test.pathman_test_3(); /* RuntimeAppend (a join b on a.id = b.val) */
274278
selecttest.pathman_test_4();/* RuntimeMergeAppend (lateral)*/
275279
selecttest.pathman_test_5();/* projection tests for RuntimeXXX nodes*/
276280

277-
/* RuntimeAppend (select ... where id = ANY (subquery), missing partitions)*/
278-
selectcount(*)=0frompathman.pathman_partition_list
279-
where parent='test.runtime_test_1'::regclassand range_max::int<0;
280-
281-
selectfromtest.runtime_test_1
282-
where id= any (select generate_series(-10,-1));/* should be empty*/
283281

284282
/* RuntimeAppend (join, enabled parent)*/
285283
selectpathman.set_enable_parent('test.runtime_test_1', true);
@@ -305,6 +303,19 @@ join (select * from test.run_values limit 4) as t2 on t1.id = t2.val;
305303
select generate_series(1,2)fromtest.runtime_test_1as t1
306304
join (select*fromtest.run_valueslimit4)as t2ont1.id=t2.val;
307305

306+
/* RuntimeAppend (select ... where id = ANY (subquery), missing partitions)*/
307+
selectcount(*)=0frompathman.pathman_partition_list
308+
where parent='test.runtime_test_4'::regclassand coalesce(range_min::int,1)<0;
309+
310+
set enable_hashjoin= off;
311+
set enable_mergejoin= off;
312+
313+
selectfromtest.runtime_test_4
314+
where id= any (select generate_series(-10,-1));/* should be empty*/
315+
316+
set enable_hashjoin=on;
317+
set enable_mergejoin=on;
318+
308319

309320
DROPSCHEMA test CASCADE;
310321
DROP EXTENSION pg_pathman CASCADE;

‎src/pg_pathman.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ static bool pull_var_param(const WalkerContext *ctx,
7070

7171
staticConst*extract_const(WalkerContext*wcxt,Param*param);
7272

73-
staticdoubleestimate_paramsel_using_prel(constPartRelationInfo*prel,
74-
intstrategy);
75-
7673

7774
/* Copied from PostgreSQL (allpaths.c) */
7875
staticvoidset_plain_rel_size(PlannerInfo*root,
@@ -104,6 +101,21 @@ static void generate_mergeappend_paths(PlannerInfo *root,
104101
((Const *) (node)) \
105102
)
106103

104+
/* Selectivity estimator for common 'paramsel' */
105+
staticinlinedouble
106+
estimate_paramsel_using_prel(constPartRelationInfo*prel,intstrategy)
107+
{
108+
/* If it's "=", divide by partitions number */
109+
if (strategy==BTEqualStrategyNumber)
110+
return1.0 / (double)PrelChildrenCount(prel);
111+
112+
/* Default selectivity estimate for inequalities */
113+
elseif (prel->parttype==PT_RANGE&&strategy>0)
114+
returnDEFAULT_INEQ_SEL;
115+
116+
/* Else there's not much to do */
117+
elsereturn1.0;
118+
}
107119

108120

109121
/*
@@ -1214,22 +1226,6 @@ extract_const(WalkerContext *wcxt, Param *param)
12141226
value,isnull,get_typbyval(param->paramtype));
12151227
}
12161228

1217-
/* Selectivity estimator for common 'paramsel' */
1218-
staticdouble
1219-
estimate_paramsel_using_prel(constPartRelationInfo*prel,intstrategy)
1220-
{
1221-
/* If it's "=", divide by partitions number */
1222-
if (strategy==BTEqualStrategyNumber)
1223-
return1.0 / (double)PrelChildrenCount(prel);
1224-
1225-
/* Default selectivity estimate for inequalities */
1226-
elseif (prel->parttype==PT_RANGE&&strategy>0)
1227-
returnDEFAULT_INEQ_SEL;
1228-
1229-
/* Else there's not much to do */
1230-
elsereturn1.0;
1231-
}
1232-
12331229

12341230

12351231
/*

‎src/pl_funcs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ show_partition_list_internal(PG_FUNCTION_ARGS)
458458
usercxt= (show_partition_list_cxt*)funccxt->user_fctx;
459459

460460
/* Iterate through pathman cache */
461-
for(;;)
461+
for(;;)
462462
{
463463
constPartRelationInfo*prel;
464464
HeapTuplehtup;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp