segasai / q3c

PostgreSQL extension for spatial indexing on a sphere
GNU General Public License v2.0
76 stars 27 forks source link

Added a q3c_sindist_bool function to allow for calculating a better Selectivity #35

Open gshennessy opened 11 months ago

gshennessy commented 11 months ago

Have a selectivity function for q3c_sindist_bool.

segasai commented 11 months ago

I looked at the patch, but I actually forgot that I already have selectivity on for the q3c_join() so nothing is needed there. It is done through the weird operator https://github.com/segasai/q3c/blob/040de144fdddaca19ce95ebf79652d4c6fab97c9/scripts/q3c--2.0.0.sql#L209 with this selectivity function https://github.com/segasai/q3c/blob/040de144fdddaca19ce95ebf79652d4c6fab97c9/q3c.c#L94 In fact

explain select * from gaia_dr3.gaia_source as g, gaia_dr3.gaia_source as g1 where q3c_join(g.ra,g.dec,g1.ra,g1.dec,5./3600);

estimates the number of rows to be 60 millions which is pretty sensible (given it asssumes independent positions).

So I don't think q3c_join can be improved with your patch. What I can do is to do the same thing for q3c_radial_query() which currently doesnt' have the selectivity implemented

gshennessy commented 11 months ago

I need to do more A/B testing, if only for my own understanding.