This comment has been minimized.

When prefetch method was added, the goal was not in minimizing SQL queries, but in loading all necessary data before exiting of db_session. Pony assumes that processing of any ORM objects take place inside db_session, but some users want to have the ability to read attribute values when the db_session is already over. So we added prefetch method which walks through the query result and preloads all specified attributes so they can be accessed later.

But you are right that prefetching can be optimized, at least in simple cases. So I just added an optimization which includes specified attributes into initial SELECT, if possible.

When prefetch method was added, the goal was not in minimizing SQL queries, but in loading all necessary data before exiting of db_session. Pony assumes that processing of any ORM objects take place inside db_session, but some users want to have the ability to read attribute values when the db_session is already over. So we added prefetch method which walks through the query result and preloads all specified attributes so they can be accessed later.

But you are right that prefetching can be optimized, at least in simple cases. So I just added an optimization which includes specified attributes into initial SELECT, if possible.

kozlovsky
changed the title from
Prefetch lazy attribute?
to
Query prefetch() method should load specified lazy attributes right in the main query if possibleApr 4, 2016