[SQLObject] Indexed access to a SelectResults
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Matt G. <ma...@po...> - 2003-07-16 13:28:56
|
If you have code like this all = Entity.select('all') for i in range(len(all)): print all[i] you get a whole stream of SQL calls. For a table with n rows you actually get 2n+1 SQL calls: 1 initial COUNT(*) and then a COUNT(*) and SELECT for each row. It makes sense for a SelectResults objects to cache the COUNT result on the first len() so that future len() calls don't go back to the database? Another relatively easy way of improving performance in the above scenario would be if SelectResults read and cache blocks of objects, 10 at a time for example, even if only one of those objects was actually returned to the caller. Anyway, just some thoughts to help SQLObject "scale up" a bit. I have no idea whether these ideas would break other parts of SQLObject ;-). Cheers, Matt -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenationinternet.com e: ma...@po... |