Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selectivity estimators for <@(spoint, scircle) and spoint_dwithin(spoint, spoint, float8) #80

Merged
merged 1 commit into from
Oct 20, 2023

Commits on Oct 19, 2023

  1. Implement restriction selectivity estimators for <@(spoint, scircle)

    This implements restriction selectivity estimation for the <@ @> !<@ !@>
    family of operators on spoint and scircle. The selectivity is estimated
    to be (area of sphere circle) / (4 pi).
    
    Queries like `select * from sky where sky.star <@ scircle(const, radius)`
    will be able to properly estimate if using an index is appropriate
    depending on the size of radius.
    
    Secondly, a function spoint_dwithin(p1 spoint, p2 spoint, radius float8)
    is added that effectively returns `p1 <-> p2 <= radius`. But other than
    this two-operator expression, it has GIST index support so the optimizer
    can rewrite it to either `p1 <@ scircle(p2, radius)` or `p2 <@
    scircle(p1, radius)`, i.e. it is symmetric in the first two arguments.
    
    This allows efficient matching queries without the user having to encode
    the join ordering in the query.
    
    On PostgreSQL 10/11, the spoint_dwithin function is created, but without
    the GIST support since that only appeared in PG12.
    
    The file expected/selectivity_1.out is used on PG10/11; it has <@
    flipped around to @> in some plans.
    df7cb committed Oct 19, 2023
    Configuration menu
    Copy the full SHA
    65217de View commit details
    Browse the repository at this point in the history