App Engine (well the Datastore) can't run queries like that. Remember App Engine is designed with scaling in mind, the application should function the same if 1 person is using the app or a million (performance wise), tradional database systems and sql in particular, make it very easy to define very complex queries simply. They hide the implementation details - but in particular many queries are just terrible performance wise - with small datasets this isnt noticeable.
Now think you have 6 million results in your table (the size of the geonames.org dump iirc) - running that query would requite the mathermatical calculation to be run for *every single row* - its going to bring most database systems to its knees. (even, or in particular, the datastore) An important consideration is you are probably only going to be using a very small result set, say the closest 15 results. Calculating the distance on every row, sorting the *whole lot*, then choosing which want (results 1-15) is quickly going to breakdown. So an important optimization is to cutdown the resultset with a index, and only sort the very small subset. Have a look in the group for geohash - that is a way of making a 2dimensional index in one field (which is a limitation of the datastore). Admittedly the theory is easy, but the implementation is not trival - mainly as you have to be able to define your area of interest in a square grid - which means your Point of interest might near a grid boundary so you might have to search multiple grids and combine the results. - also you have to be able to define the size of the grid, which doesnt fit with "15 nearest results" - too big and get too many results to sort, too small and you miss results. *what many hosting and application enviroment make you only think about once you start needing to scale - AppEngine effectivly makes you think about from the outset.* 2009/1/15 arnie <[email protected]>: > > Hi > I have to create a query similar to the below given one > SELECT id, place_name, > ROUND( SQRT( POW((69.1 * (#Val(arguments.latitude)# - latitude)), 2) + > POW((53 * (#Val(arguments.longitude)# - longitude)), 2)), 1) AS > distance > FROM places > but it seems to me that we cannot select individual elements of table > in select statement > I am being a newbie at python so can anybody tell about creating > dynaic collections so that I can store the calculated distance along > with ID of row and then arrange the collection in ascending order > > > -- Barry - www.nearby.org.uk - www.geograph.org.uk - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
