diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-06-03 21:53:10 -0400 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-08-21 16:47:41 +0200 |
| commit | d3cf24e9b415b41f570c9f426b2cd113b5fdb4de (patch) | |
| tree | a3f5ba9a228551d83014dc6d9a47fc0002c14a73 /django | |
| parent | a2ce4900a63f91f0cc685ac157762610c199c391 (diff) | |
Refs #36430, #36416, #34378 -- Simplified batch size calculation in QuerySet.in_bulk().
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/query.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index 9f245b02ca..7ae9f53bfd 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -1187,10 +1187,8 @@ class QuerySet(AltersData): if not id_list: return {} filter_key = "{}__in".format(field_name) - 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) + batch_size = connections[self.db].ops.bulk_batch_size([opts.pk], id_list) # If the database has a limit on the number of query parameters # (e.g. SQLite), retrieve objects in batches if necessary. if batch_size and batch_size < len(id_list): |
