cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
29.87k stars 3.77k forks source link

opt,geospatial: add rule to handle st_dwithin with zero distance #127265

Open DrewKimball opened 1 month ago

DrewKimball commented 1 month ago

When 0 is passed as the distance argument for the st_dwithin geospatial function, CRDB is unable to generate an index scan using an indexed column among the other arguments to the function. It should be possible to constrain a scan in this case, either by adding an optimizer rule to replace st_dwithin with another function or expression, or by handling this case in the inverted constraint generation logic.

Jira issue: CRDB-40347

tejasridontham commented 1 month ago

@DrewKimball also looks like st_dwithin(geography_a: geography, geography_b: geography, distance: float, use_spheroid: bool) → bool this query with useSpheroid also doesnt obey the indexing thing. Can you please fix for this too.