Skip to content

Commit 968946a

Browse files
committed
removed bytesize calculation
1 parent 3d8643e commit 968946a

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

django_mongodb_backend/compiler.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import itertools
22
from collections import defaultdict
33

4-
from bson import SON, encode, json_util
4+
from bson import SON, json_util
55
from django.core.exceptions import EmptyResultSet, FieldError, FullResultSet
66
from django.db import IntegrityError, NotSupportedError
77
from django.db.models import Count
@@ -326,21 +326,10 @@ def cursor_iter(self, cursor, _, columns):
326326
Read more here: https://www.mongodb.com/docs/manual/core/cursors/#cursor-batches
327327
"""
328328
chunk = []
329-
chunk_size = 101 # MongoDB's default initial batch size
330329

331-
for i, row in enumerate(cursor):
330+
for row in cursor:
332331
chunk.append(self._make_result(row, columns))
333-
334-
if len(chunk) == chunk_size:
335-
if i == chunk_size - 1: # First chunk complete
336-
# Using current row as representation, approximate
337-
# how many rows can fit in a 16MB payload
338-
# (MongoDB batch_size max), then set that as the new size.
339-
approx_chunk_size = MAX_BATCH_SIZE_MB // len(encode(row))
340-
chunk_size = max(chunk_size, approx_chunk_size)
341-
yield chunk
342-
chunk = []
343-
yield chunk
332+
return chunk
344333

345334
def check_query(self):
346335
"""Check if the current query is supported by the database."""

0 commit comments

Comments
 (0)