python - Peewee: delete with limit -
i have (very) large table mit >100m rows. want delete 1m rows condition without running in table lock or timeout issue. imo delete limit best choice in case. i'm trying find peewee equivalent simple sql query
delete users condition=1 limit 10
my first approach is:
users.delete().where(condition=10).limit(10)
but deletequery doesn't have limit method. oops...
so, best practice delete huge number of rows peewee?
if want delete limit, use subquery:
users_to_delete = user.select().where(...).limit(10) users.delete().where(user.id << users_to_delete)
Comments
Post a Comment