summaryrefslogtreecommitdiff
path: root/django/db/models/query.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/query.py')
-rw-r--r--django/db/models/query.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index bb5462037c..1270141619 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1149,7 +1149,9 @@ class QuerySet(AltersData):
if not id_list:
return {}
filter_key = "{}__in".format(field_name)
- batch_size = connections[self.db].features.max_query_params
+ max_params = connections[self.db].features.max_query_params or 0
+ num_fields = len(opts.pk_fields) if field_name == "pk" else 1
+ batch_size = max_params // num_fields
id_list = tuple(id_list)
# If the database has a limit on the number of query parameters
# (e.g. SQLite), retrieve objects in batches if necessary.