Do I need a spatial index in my database?
- by Sanoj
I am designing an application that needs to save geometric shapes in a database. I haven't choosen the database management system yet.
In my application, all database queries will have an bounding box as input, and as output I want all shapes within that database. I know that databases with a spatial index is used for this kind of application. But in my application there will not be any queries of type "give me objects nearby x/y" or other more complex queries that are useful in a GIS application.
I am planning of having a database without a spatial index and have queries looking like:
SELECT * FROM shapes WHERE x < max_x AND x > min_x AND y < max_y AND y > min_y
And have an index on the columns x (double) and y (double). As long I can see, I don't really need a database with an spatial index, howsoever my application is close to that kind of applications.
And even if I would like to have nearby queries, then I could create a big enough bounding box around that point. Or will this lead to poor performance?
Do I really need a spatial database? And when is a spatial index needed?