Skip to content

Commit

Permalink
get values_list and delete them
Browse files Browse the repository at this point in the history
  • Loading branch information
moonsikpark committed Jun 4, 2024
1 parent 9e13d6e commit b575a84
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion silk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def garbage_collect(cls, force=False):
time_cutoff = timezone.now()
# recursively delete every 10000 rows to prevent running out of memory
while cls.objects.filter(start_time__lte=time_cutoff).count() > 0:
cls.objects.filter(start_time__lte=time_cutoff)[:10000].delete()
pks = cls.objects.filter(start_time__lte=time_cutoff)[:10000].values_list('pk', flat=True)
cls.objects.filter(pk__in=pks).delete()
return

try:
Expand Down

0 comments on commit b575a84

Please sign in to comment.