For me, I just use engine.execute most of the time, any problem with this? Or if I use session or connect, do I need to close the session or connection everytime? otherwise, it will trigger the pool size limit error as the connection is increasing, right?
在 2014年4月8日星期二UTC+8下午8时49分16秒,Michael Bayer写道: > > To make more connections, call connect(), and/or use more session objects. > Each session uses one connection. > > If you see three connections, that means your script has only worked with > three connections at once, such as, you opened three Session objects > concurrently. > > Sqlalchemy does not initiate any concurrent operations on its own. > > > Sent from my iPhone > > On Apr 8, 2014, at 5:03 AM, Ni Wesley <[email protected] <javascript:>> > wrote: > > Hi all, > I have a question here. > > Here is my db init code snippet: > > engine = create_engine(db_url, > pool_size=100,max_overflow=150,echo=engine_echo,pool_recycle=3600) > session = scoped_session(sessionmaker(bind=engine)) > metadata = MetaData(bind=engine) > > Then, I use engine to do update/insert operations. > > There is no problem here, then I find during the performance test that, > it's too slow to insert/update mysql server. > When my script running, on mysql server, use mysql 'show processlist;' > command, I see only 2 or 3 active connections kept. > > Then,within my script, I use multiprocessing.pool(defaults to cpu core > size, which is 4 for me) to do mysql insert/update operations. > > Finally, I see 4 or 5 connections kept from mysql server. > > So, seems db operation is bottleneck because I cannot use more connections > yet. > > How to push the conncurrent connections up? I am sure script generating db > tasks are fast enough. > > Thanks. > Wesley > > -- > 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 [email protected] <javascript:>. > To post to this group, send email to [email protected]<javascript:> > . > Visit this group at http://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. > > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
