Hi burgiduroy,

On Wednesday, 11 July 2012 15:24:59 UTC, burgiduroy wrote:
>
> Are there any performance difference between the two?
>
> for row in  query_object.all():
>    do_something()
>
> AND
>
> for row in query_object:
>    do_something()
>

The first fetches and processes all rows in one go before executing the 
loop body. The second streams them in.

How much that really matters depends on the DBAPI (it may fetch all rows in 
one go anyway), and maybe on how heavy the object mapping is ... and on 
whether you end up exiting your loop early (and so avoid processing the 
rest unnecessarily).

Regards,

Gulli

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/rtdpsUfOa1QJ.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to