Fellow Djangonauts, Here at my work[1] we've built a number of web-based educational websites in Django now. I'm analyzing the number of SQL calls and am realizing that the number is higher than I'd like.
My main question is around whether or not I can do a bulk query to get most of the data I need, and then do filtering or quick searching of the resulting list of objects. I'm thinking that it can't be done without another database call but you guys are smart and creative, so I'm sure there are other ways that I haven't thought of. :) Our data resides in a custom built content management system built in Django. We have a data model for content and media and questions (forms) and user responses to those questions. Here's a typical scenario that leads to extra SQL calls: The user has traversed a subset of the program and has answered questions or hit triggers which set responses to track the user. They hit a page which tailors content based on their previous responses or triggers. If there are a number of variables that come into play to tailor content to this user we get those with the usual ORM and filter by what we need. When I look at the SQL calls made during page creation, I see a lot of: SELECT value FROM responses WHERE varname='blah' and user_id=1; What would be more efficient would be if I could get all responses for a particular user, then pluck the particular variables out of that data set as/when I need them. 1 SQL call. Is that possible? Are there memory tradeoffs? There could be potentially on the order of 100 responses per user and each of those is a Response object. Is there a way to estimate memory footprint for that? Is this even worth the effort -- the individual queries are about .001s, and in total about 0.065s for the particular page I'm looking at. I've thought about the idea of turning the resulting list into a dictionary keyed by varname so I can get the Response object by varname. But there are other scenarios where I'd like to filter the data in different ways. So in a general case I'm looking for other ideas. Thanks, Rob [1] Oregon Center for Applied Science (http://www.orcasinc.com/) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---