If you keep them "inside" tornado you run two risks:
1. If you extract, say, 1000 elements straight away from the database but only show the first 100. Then, suppose your users only bother to look at the first 100. That means you have fetched the 900 extra for no good use. Sure, sooner or later your users might look at all of them but that might be a very long time to hold on to the data in some sort of global variable.
2. What if you have 2 tornado processors running. One on port :8001 and one on :8002 and you put Nginx or HAProxy in front of this. Then your users might hit the first server for the first 100 rows and the next server for the next request of the next 100.
If you have a really slow database, consider fetching 1000 and sticking them into a memcache or redis and then build your template so that it fetches from memcache instead.
On Friday, April 5, 2013 7:19:55 AM UTC-7, Quinlan Morake wrote:
What would the best way to increment through a result set, <X> at a time, be? I have a large result set of which I'd like to display 20 per page, and would like to put a navigation bar at the bottom, <a href links or something of the like, to go to the rest. What would the best way to go about it be? I would ideally not like to load the results from the datasource each time, but keep them in "inside" tornado.
Regards,
Quinlan