> On 26 May 2015, at 09:16, Burak Arslan <burak.ars...@arskom.com.tr> wrote:
> 
> same here but before passing the model instance from controller to view,
> all instances are detached from session (via expunge()). this 1)
> prevents a lot of unexpected db queries. 2) lets you recycle db
> connections as soon as possible.

Oh, that's clever.

One of the shortcomings of SQLAlchemy is that it makes it easy to produce a 
"query within a loop" anti-pattern through relation traversal. So far I 
prevented this by avoiding loading mapped objects as much as possible, instead 
loading only specific columns — with the nice side effect of reducing data 
transfer with the database.

Now, thanks to you I realise I can prevent the anti-pattern with less code 
using Session.expunge_all().


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to