MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecSetTupleBound

Function ExecSetTupleBound

src/backend/executor/execProcnode.c:1419–1571  ·  view source on GitHub ↗

* ExecSetTupleBound * * Set a tuple bound for a planstate node. This lets child plan nodes * optimize based on the knowledge that the maximum number of tuples that * their parent will demand is limited. The tuple bound for a node may * only be changed between scans (i.e., after node initialization or just * before an ExecReScan call). * * Any negative tuples_needed value means "no limit"

Source from the content-addressed store, hash-verified

1417 * only unchanging conditions are tested here.
1418 */
1419void
1420ExecSetTupleBound(int64 tuples_needed, PlanState *child_node)
1421{
1422 /*
1423 * Since this function recurses, in principle we should check stack depth
1424 * here. In practice, it's probably pointless since the earlier node
1425 * initialization tree traversal would surely have consumed more stack.
1426 */
1427
1428 if (IsA(child_node, SortState))
1429 {
1430 /*
1431 * If it is a Sort node, notify it that it can use bounded sort.
1432 *
1433 * Note: it is the responsibility of nodeSort.c to react properly to
1434 * changes of these parameters. If we ever redesign this, it'd be a
1435 * good idea to integrate this signaling with the parameter-change
1436 * mechanism.
1437 */
1438 SortState *sortState = (SortState *) child_node;
1439
1440 if (tuples_needed < 0)
1441 {
1442 /* make sure flag gets reset if needed upon rescan */
1443 sortState->bounded = false;
1444 }
1445 else
1446 {
1447 sortState->bounded = true;
1448 sortState->bound = tuples_needed;
1449 }
1450 }
1451 else if (IsA(child_node, IncrementalSortState))
1452 {
1453 /*
1454 * If it is an IncrementalSort node, notify it that it can use bounded
1455 * sort.
1456 *
1457 * Note: it is the responsibility of nodeIncrementalSort.c to react
1458 * properly to changes of these parameters. If we ever redesign this,
1459 * it'd be a good idea to integrate this signaling with the
1460 * parameter-change mechanism.
1461 */
1462 IncrementalSortState *sortState = (IncrementalSortState *) child_node;
1463
1464 if (tuples_needed < 0)
1465 {
1466 /* make sure flag gets reset if needed upon rescan */
1467 sortState->bounded = false;
1468 }
1469 else
1470 {
1471 sortState->bounded = true;
1472 sortState->bound = tuples_needed;
1473 }
1474 }
1475 else if (IsA(child_node, AppendState))
1476 {

Callers 2

recompute_limitsFunction · 0.85
ParallelQueryMainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected