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

Compare performance vs MySQL spatial funcs? #265

Open
kalnode opened this issue May 26, 2021 · 0 comments
Open

Compare performance vs MySQL spatial funcs? #265

kalnode opened this issue May 26, 2021 · 0 comments

Comments

@kalnode
Copy link

kalnode commented May 26, 2021

In my app I use MySQL spatial functions directly in db queries, to filter results based on distance from location (e.g. restaurants near a user). When researching this in the past, there were performance benefits to doing this directly in MySQL as opposed to in my server code (e.g. PHP, Go, etc). e.g. Link

Fast-forward a bit, my app is fully Node.js (for lots of other reasons). I still use raw queries with the MySQL spatial func, however it's difficult juggling raw queries against the high-level stuff my CMS/ORM wants to do. In this case, your library may be much more practical. Aside from the query filtering, I think this lib would be useful since there's lots of mapping of data involved in the app and all the UX/UI that comes with that.

Anyhow, I'm wondering if there are any performance worries ie this library vs MySQL spatial funcs?

MySQL distance calc example:

                .join('locations', 'restaurants.Location', 'locations.id')               
                .where(connection.raw(                
                    `round(st_distance_sphere(
                        st_geomfromtext(CONCAT('  POINT(',locations.Longitude, ' ', locations.Latitude,')'  )),
                        st_geomfromtext(CONCAT('  POINT(` + ctx.query.Longitude + ` ` + ctx.query.Latitude + `) '))
                    )) <= 5000`
                ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant