On Mon, Dec 22, 2008 at 9:21 AM, Diez B. Roggisch <[email protected]> wrote:
>
> If you can cope with the overall data being processed as whole, wy don't
> you convert the above list to a list of objects?
>
> files = [model.Files.get(id) for id in files] # where files is done as above
>

The problem with the above solution is that it can be very
inefficient.  If you have 2000 ids in that list at any time you will
have 2001 queries executed to populate your list comprehension.  It
would be better to use the sqlbuilder IN function:

files = model.Files.select(IN(model.Files.q.id, [f[0] for f in files]))

This should only execute 2 queries no matter how many records are
returned from your first query.



-- 
Lee McFadden

blog: http://www.splee.co.uk
rejaw: http://rejaw.com/splee
twitter: http://twitter.com/splee

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to