Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d822468

Browse files
author
Alexandra Pervushina
committed
Remove SeqScan nodes that were terminated early from learning entirely
Lower reliability for HashJoin nodes containing such scans
1 parent c84dc34 commit d822468

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

postprocessing.c

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,53 @@ should_learn(PlanState *ps, AQOPlanNode *node, aqo_obj_stat *ctx,
336336
}
337337
else if (ctx->learn)
338338
{
339-
elog(NOTICE, "fss %d, IsNull %s, nloops %lf", node->fss, TupIsNull(ps->ps_ResultTupleSlot) ? "true" : "false", ps->instrument->nloops);
340-
if (IsA(ps, HashJoinState))
339+
//elog(NOTICE, "fss %d, IsNull %s, nloops %lf", node->fss, TupIsNull(ps->ps_ResultTupleSlot) ? "true" : "false", ps->instrument->nloops);
340+
switch (nodeTag(ps))
341341
{
342-
HashJoinState *hjstate = castNode(HashJoinState, ps);
343-
elog(NOTICE, "TerminatedEarly %s", hjstate->hj_TerminatedEarly ? "true" : "false");
344-
if (hjstate->hj_TerminatedEarly)
342+
case T_SeqScanState:
343+
case T_SampleScanState:
344+
case T_IndexScanState:
345+
case T_IndexOnlyScanState:
346+
case T_BitmapHeapScanState:
347+
case T_TidScanState:
348+
case T_TidRangeScanState:
349+
case T_ForeignScanState:
350+
case T_CustomScanState:
345351
{
346-
*rfactor = RELIABILITY_MIN;
347-
return true;
352+
ScanState *sstate = (ScanState *) ps;
353+
354+
if (!TupIsNull(sstate->ss_ScanTupleSlot) && ps->instrument->nloops > 0.)
355+
{
356+
/* If the scan node was terminated early, skip it*/
357+
elog(NOTICE, "ScanState terminated early");
358+
return false;
359+
}
360+
//elog(NOTICE, "ScanState, isnull ss_ScanTupleSlot %s", TupIsNull(sstate->ss_ScanTupleSlot) ? "true" : "false");
361+
break;
362+
}
363+
case T_HashJoinState:
364+
{
365+
HashJoinState *hjstate;
366+
ScanState *sstate;
367+
PlanState *outerNode;
368+
369+
hjstate = castNode(HashJoinState, ps);
370+
outerNode = outerPlanState(hjstate);
371+
sstate = (ScanState *) outerNode;
372+
373+
if (!TupIsNull(sstate->ss_ScanTupleSlot) && outerNode->instrument->nloops > 0.)
374+
{
375+
/* If the scan node was terminated early, lower reliability for HashJoin node*/
376+
elog(NOTICE, "HashJoin ScanState terminated early");
377+
*rfactor = 0.9 * (RELIABILITY_MAX - RELIABILITY_MIN);
378+
return true;
379+
}
380+
break;
348381
}
382+
default:
383+
break;
349384
}
385+
350386
*rfactor = RELIABILITY_MAX;
351387
return true;
352388
}

0 commit comments

Comments
 (0)