We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When running the clean_tables script to prepare a database for import, the process gets killed if there are too many rows in a particular table.
The clean_tables script to prepare a database for import, the process is successful regardless of the number of rows in a table.
Staging
Peer Dave Kennedy:
def delete_objects_in_batches(model): total_deleted = 0 while True: pks = list(model.objects.values_list('pk', flat=True)[:BATCH_SIZE]) if not pks: break with transaction.atomic(): deleted, _ = model.objects.filter(pk__in=pks).delete() total_deleted += deleted logger.info(f"Deleted {deleted} objects, total deleted: {total_deleted}") sleep(0.1) logger.info(f"Finished deleting. Total deleted: {total_deleted}")
No response
The text was updated successfully, but these errors were encountered:
Per approval by Alysia to move this up a sprint since it's already in "In review" status. Moved from sprint 50 to sprint 49.
Sorry, something went wrong.
Per guideline, all "In review" tickets from Sprint 49 will moved forward at noon EST on Day 4 to current sprint (Sprint 50).
Merge pull request #2482 from cisagov/meoward/2459-clean-tables
f9606ac
Issue #2459: updated clean_tables to run in batches of 1000 rows
dave-kennedy-ecs
Successfully merging a pull request may close this issue.
Current Behavior
When running the clean_tables script to prepare a database for import, the process gets killed if there are too many rows in a particular table.
Expected Behavior
The clean_tables script to prepare a database for import, the process is successful regardless of the number of rows in a table.
Steps to Reproduce
Environment
Staging
Additional Context
Peer Dave Kennedy:
def delete_objects_in_batches(model):
total_deleted = 0
while True:
pks = list(model.objects.values_list('pk', flat=True)[:BATCH_SIZE])
if not pks:
break
with transaction.atomic():
deleted, _ = model.objects.filter(pk__in=pks).delete()
total_deleted += deleted
logger.info(f"Deleted {deleted} objects, total deleted: {total_deleted}")
sleep(0.1)
logger.info(f"Finished deleting. Total deleted: {total_deleted}")
Issue Links
No response
The text was updated successfully, but these errors were encountered: