From: Michael Tremer Date: Fri, 20 Feb 2026 16:37:03 +0000 (+0000) Subject: lists: Update domains in batches of 100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=833f7a6213f47f46cc1ed622c1af26d1f26174be;p=dbl.git lists: Update domains in batches of 100 The asyncpg driver does not support an infinite amount of arguments in a single query. Signed-off-by: Michael Tremer --- diff --git a/src/dbl/lists.py b/src/dbl/lists.py index 33f7616..0cc43b4 100644 --- a/src/dbl/lists.py +++ b/src/dbl/lists.py @@ -21,6 +21,7 @@ import datetime import functools import io +import itertools import logging import sqlalchemy.dialects.postgresql import sqlalchemy.orm @@ -878,22 +879,23 @@ class List(sqlmodel.SQLModel, database.BackendMixin, table=True): ) # De-list the redundant domains - await self.backend.db.execute( - sqlmodel - .update( - domains.Domain, - ) - .values( - subsumed = True, - ) - .where( - domains.Domain.list == self, - domains.Domain.removed_at == None, - domains.Domain.name.in_( - redundant_names, + for batch in itertools.batched(redundant_names, 1000): + await self.backend.db.execute( + sqlmodel + .update( + domains.Domain, + ) + .values( + subsumed = True, + ) + .where( + domains.Domain.list == self, + domains.Domain.removed_at == None, + domains.Domain.name.in_( + batch, + ) ) ) - ) # Update all stats afterwards if update_stats: