The general version of the question is above - a a little more detail, I am using Django Rest Framework, but am happy for answers to be dealing with the problem in abstract.
So, I have data with ~200 countries, ~10,000 regions (the countries subdivided) and ~600 extra small districts in the UK.
My plan is currently to have the client send a request, with its current zoomlevel and position, then on the server:
- filter objects to correct zoomlevel
- filter objects to ones that overlap with viewing rect
- insert "custom data" into the features before returning
Alternative plan for 3. is to pass back the "custom data" in a separate request.
A little more detail on what the custom data is - votes - there will be a large number of voteables, and even more votes, my plan here is to precalc/cache the vote totals for each question+area there is a vote in, to make returning the data as fast as possible.
Still, I'm not too sure of a sensible way to minimise the number of DB Queries - perhaps get the geo areas that match the view, and do one query to get all pre-calculated "custom data" that matches.
Any thoughts on a good way to deal with this kind of situation are very welcome. There may we be bits I have not thought of too much (like avoiding re-sending data more than needed if the user keeps scrolling around)