It's hard to tell what could cause the issue: How many horses are there? What is going on in that other function? Are there foreign key checks involved with the commit?
If you want to break a huge batch into smaller commits, there is the `Windowed Range Query` strategy -- https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/WindowedRangeQuery -- 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.