Skip to content

Commit b99d290

Browse files
committed
fix: stop iterating when batch returns fewer than batch_size candidates
Avoids redundant SELECT queries when the previous batch already exhausted all matching rows.
1 parent c90f8ce commit b99d290

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

diracx-logic/src/diracx/logic/jobs/sandboxes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,8 @@ async def _delete_chunk(chunk: list[int], _sem: asyncio.Semaphore = sem) -> int:
291291
total_deleted,
292292
)
293293

294+
# If we got fewer than batch_size, there are no more candidates
295+
if len(sb_ids) < batch_size:
296+
break
297+
294298
return total_deleted

0 commit comments

Comments
 (0)