When working with GAE datastore you want to execute minimum number of 
queries necessary to avoid delays and
limit the use of DB API calls. Fetching comments one by one is not the best 
option then (even if done with ajax).

Probably the most efficient way would be to store the list of comment ids 
as an attribute of each article entity. Then
you could get all comment ids with a single query. Having the ids you could 
build a list of GAE keys, and fetch all
needed comment entities at once. We discussed that recently here:
https://groups.google.com/d/topic/web2py/7dvo_jqIR38/discussion

I'm also guessing that this might be quite common GAE use case and you 
might find a better solution already optimised
for this on GAE forum. The other option is to show comments only on the 
article individual page (not on the list of articles).

If you use the wrapper for caching, then you could memorize the entire 
response, so this is very efficient as the views
are not rendered but read straight from cache. If you need some extra 
parametrisation inside the controller you could
either move some of the code to a separate function which output is cached 
or simply cache only the queries:
http://web2py.com/books/default/chapter/29/6#Caching-selects

Reply via email to