On Dec 15, 2009, at 6:09 PM, Michael Bayer wrote: > > On Dec 15, 2009, at 11:47 AM, Michael Bayer wrote: > >>> >> >> the 53K calls to mapper._save_obj() indicate that your flush plan is >> creating an enormous dependency tree. Or, much less likely, you're using >> the "batch=False" flag on mapper, which is highly not recommended. For a >> simple flush plan, such as a list of objects A each of which contain a >> one-to-many collection of objects B, _save_obj() would be called about >> four times. A flush plan like the one you have could for example occur >> in some self-referential scenarios, if you have a deep tree of recursive >> relationships for example. A test script illustrating mappings and >> sample objects which produce a huge flush like this would be helpful, as >> there may be either an improvement to your mapping, or within the unit of >> work code which could optimize whatever is occurring here. > > > just in case you're not motivated to share mappings here, I would note that > an incorrect placement of a flag like "remote_side" on a relation() may be > causing this. I've never seen a flush plan that results in _save_obj() being > called more than a few dozen times, in fact. So we really need to see how > you're getting that result, since if its a configurational error I'll add a > check such that the incorrect configuration becomes impossible.
yet another thought, which again reveals how much easier this would be with some sample code - if you're in a loop that is calling query(), then changing things, then around again, you may have excessive triggering of autoflush going on, which also can result in lots of _save_obj() calls. Set the "autoflush" flag on your Session to be false, which you can do temporarily within a particular section or across the whole session. Calling commit() will issue a flush(), or alternatively you can call flush() every few thousand new records. > > > > >> >> >> >> >> >> >> >> >>> >>> -- >>> >>> You received this message because you are subscribed to the Google Groups >>> "sqlalchemy" group. >>> To post to this group, send email to [email protected]. >>> 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. >>> >>> >>> >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To post to this group, send email to [email protected]. >> 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. >> >> > > -- > > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > 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. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. 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.
