I found that it seems not the transaction cause the performance problem. I think it maybe cause by use one session for a long time. Performance getting slower with the program run longer time. Once I stop the program and run it again, at first it works fast.
So I think it is the problem of using a session for too many query and insert? I think the identify map or something else getting bigger and bigger with time. Is that correct? How to solve this problem? Thanks. Victor Lin. On 8月17日, 下午10時16分, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Aug 17, 2008, at 8:50 AM, Victor Lin wrote: > > > > > > > Hi, > > > I am using SQLAlchemy to write a application. > > I add a losts of rows into database and commit. > > > Code like this: > > > for item in itemList: > > # do some query > > session.query(...) > > # add a row > > newItem = newItem(...) > > session.commit() > > > At first few rows, it gos fast. > > But after that, I found the loop getting slow when there is more and > > more data in one transaction. > > If I put commit inside loop, it runs very fast. > > > for item in itemList: > > # do some query > > session.query(...) > > # add a row > > newItem = newItem(...) > > session.commit() > > > What makes my program getting slow? And how to solve that problem(all > > stuff in transaction). > > Thanks. > > the size of the object list to be reconciled and sorted during flush > gets very large - so issue a flush() after every 100 or so entries > added to the session. they'll all execute within the context of the > enclosing transaction. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---