On Wednesday, October 1, 2003, at 06:25 PM, Simon Willison wrote:
> When you run a SQLObject SELECT statement and get back an array of
> objects matching that select, are all of the represented rows from the
> database loaded in to memory? If so, that could cause a great deal of
> memory usage for large queries. An interesting trick I saw a while ago
> was using generators to yield a single row from a query at a time,
> allowing code to iterate through a whole database result set without
> first having to load everything in to a Python list:
>
> http://www.halfcooked.com/mt/archives/000497.html
>
> Are there any plans to add some kind of mechanism to SQLObject to
> support this kind of more efficient SELECT access? Or does it exist
> already and I juste haven't spotted it yet.
Yes, this is what SQLObject already does. SQLObject.SelectResults is
what .select() returns, and when you iterate over it you get an
iterator from DBConnection.DBAPI._iterSelect
(How exactly this interacts with caching under different loads, I'm not
as sure)
Ian
|