python - Deleting in Smaller Quantities SQLAlchemy MySQL -
mysql table space tends increase large deletions.
i doing:
s = session.query(model) s.delete()
i understand can add
s.limit(1000)
and sleep
after each deletion , re-querying s.all()
determine if entries have been wiped. there way delete in batches of 1000
until original records have been cleaned out?
your transaction log , required space going huge if you're deleting large number of records in single transaction. if need transaction, unavoidable (refactor not require it). otherwise, call .commit() between smaller chunks of (say 100,000 or so) records.
Comments
Post a Comment