Skip to content

Operations over row estimates #215

@MarceloZabini

Description

@MarceloZabini

Hello! I have a question about row estimates.

In Hints for Row number corrections, I see the examples all show a way to fix postgres' resulting estimate.
But I am looking for a way to hint that the resulting row number estimate of the join a b is the number of estimated rows for a.
I have never used pg_hint_plan (sorry, maybe I should install it and try it out myself), but thought it might be good to have this documented if it is supported.
Would Rows(a b a) work?

Thanks in advance.


Use-case if it helps:

We have a join based on a computed value that does not have statistics, e.g. extract_latest_less_than(table_a.array_of_b_ids, $1) = b.id. Since $1 is a query parameter that changes a lot, this can't be a computed column with statistics. But we know that function will return an Id that exists in b, something Postgres can't know. Postgres will treat it as an arbitrary integer and will produce very low and wrong row estimates.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions