On Mar 18, 2011, at 11:19 AM, Sebastian Elsner wrote:

> Hello,
> 
> I wanted to make sure, I get this right: every session creates its own 
> connection on demand (only if I actually do query with the session), right?

right

> So, using MySQL with max_connections = 100 I quickly run out of connections, 
> because every client is using about 6 connections, one for each dialog 
> window, which has its own session instance.

seems like an architecture that could use some trimming....

> 
> Now I am playing with poolclass = StaticPool instead of QueuePool, which 
> seems to give me the the same speed per query. Or is there any difference to 
> expect, which I just haven't encountered?

Only the enormous difference that MySQL connections aren't threadsafe, as well 
as the fact that each Session runs its own transaction, a pattern that cannot 
be shared by multiple sessions on one connection.   Though MySQL in MyISAM mode 
renders the latter point to be moot.


> Also, is there something about StaticPool which prohibits me to do certain 
> things a QueuePool could (except the reconnection note in the docs)? I guess 
> having multiple threads with their own session querying would not work?!

The timeout thing is pretty key with MySQL since their client lib times out a 
connection unused for 8 hours (such as, overnight).   QueuePool has a 
"threadlocal" flag that returns the same connection in the same thread (on 
create_engine() its via use_threadlocal=True, and it appears that flag didn't 
make it into the docs) that may be able to help here.


> 
> Thank you,
> 
> Sebastian
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> 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.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
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