Skip to content

The Gather cost is charged per row and is blind to tuple width, which holds nine of eleven measured cells and an extension cannot change it #753

Description

@jdatcmd

docs/limitations.md, "Parallel scans", records this as known and unfixed:

On a narrow but selective scan the planner still prefers the serial plan even where the
parallel one is faster. Measured: a three-column selective scan of a four-million-row table
ran up to 2.5x faster in parallel, and the planner chose serial anyway.

The cause is the cost of the Gather node. The planner prices each row passed from a worker
to the leader at parallel_tuple_cost, the same rate it uses for a heap scan. A columnar
scan ships fewer, already-decoded rows, so that rate overstates its Gather cost. On the
shape above the Gather cost reached almost the whole cost of the serial scan. The serial
plan won on cost while losing on the clock.

So this is a costing asymmetry with a measured number attached, not a missing feature: the
parallel path exists and is built, and on a wide projection it is already chosen.

Relationship to #369

#369 (closed) is the same class one node higher: the grouped parallel aggregate arm lost to
the serial node because the Finalize was priced off estimate_num_groups on an expression
key. Worth reading before starting, because the shape of the fix and the traps in measuring
it will be similar. This issue is about the scan, not the grouped aggregate.

The care this needs

The doc is explicit that the default rate is conservative for any row-returning parallel
scan, not only a columnar one, and that a heap scan on the same shape also flipped. So the
fix must not be "discount our Gather until we win": it has to be defensible as pricing what
a columnar scan actually ships, and it needs a control on a shape where the serial plan is
genuinely right, or it will just move the error to the other side.

Per the house rule, calibrate the threshold in the context the check runs in, and assert the
chosen plan on both arms rather than the runtime alone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions