On Dec 14, 2005, at 8:47 PM, Tim Keating wrote:
I expected to see 1 call to function_get_iterator, or, at worst, 1
call
for every GET_ITERATOR_CHUNK_SIZE rows. Instead, I'm seeing *3* calls
to function_get_iterator for every row, which I find perplexing. I
intend to dig into this further but I thought perhaps someone who's
been elbow-deep in the ORM could offer some enlightenment, rather than
sending me in there cold turkey.
I *suspect* (not knowing much about Python's internals) that this has
something to do with the way that generator functions work internally.
See, if you put a print statement before line 1398 in meta/
__init__.py (just before the "yield" statement) you'll see that the
statement is, as you might expect, only being executed once for each
object. If you put that print statement right at the start of
function_get_iterator, you'll see that as you might expect the
function is only being called once.
Because function_get_iterator is a generator, I suspect that
internally Python is doing strange things that hotshot is
misinterpreting -- does anyone on this list know more about internals?
There's always going to be a drastic difference between "vanilla"
performance and real-world performance once you start hitting the
database. I'd suggest playing around with the queries you're running
using EXPLAIN ANALYZE (or the equivalent if you're not using
Postgres) to see if those queries are somehow mistuned.
Jacob