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?
EDIT:
The search queries will actually be a little bit more advanced than the one I wrote above, since I deal with geometric shapes I will input an Bounding box that will return multiple shapes (with bounding box) that are inside or interfere with the box in the query. But I still think I can do this without a spatial index, after been reading all good answers.
It looks like what you are doing will work fine for your application.
You may want to consider creating an index on a Geohash instead. This method is recommended for indexing geo-spatial points on the Google App Engine, for example, where the indexing features are limited. (Source)
There are many scenarios where a spatial index is useful. First of all, spatial indexes can deal with not just points, but with polylines, polygons, and other shapes. In addition, as you already mentioned, there are many complex query operations that can be applied on spatial data, where a proper spatial index would be essential.