Skip to content

Commit 3813fcc

Browse files
author
Joachim Jablon
authored
Merge pull request #48 from pmourlanne/add-k4nar-answer-regarding-iterator-to-readme
Add a FAQ section to the README
2 parents 1e282b7 + 05a73e7 commit 3813fcc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.rst

+16
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ You can also use ``values()``:
5454
you'll have several small queries. This will save your RAM instead, because
5555
you'll not load a huge queryset result before looping on it.
5656

57+
5758
If you want to manipulate the pages directly, you can use `chunkator_page`:
5859

5960
.. code:: python
@@ -63,6 +64,21 @@ If you want to manipulate the pages directly, you can use `chunkator_page`:
6364
for page in chunkator_page(queryset, 200):
6465
launch_some_task([item['pk'] for item in page])
6566
67+
68+
FAQ
69+
===
70+
71+
- How is django-chunkator different from Django's `iterator <https://docs.djangoproject.com/en/2.2/ref/models/querysets/#django.db.models.query.QuerySet.iterator>`_?
72+
73+
If you have server-side cursors (using Postgres or Oracle & not setting `DISABLE_SERVER_SIDE_CURSORS`), then the main difference is that the cursor is in the hands of the application instead of the server. It really depends on your constraints, but sometimes server side cursors can put too much strains on your DB.
74+
75+
If you don't have server-side cursors, then chunkator will allow you to iterate over your queryset by batch, without relying on LIMIT/OFFSET. The problem with LIMIT/OFFSET is that computing a large offset (when you're at the end of your queryset) requires the DB to go through all the previous entries. With large tables this can be a huge issue.
76+
77+
- Will django-chunkator preserve the ordering on my querysets?
78+
79+
No, it orders the queryset by pk. However you could do the same thing than chunkator with another field, given that it's unique and not nullable, see `here <https://github.com/peopledoc/django-chunkator/blob/master/chunkator/__init__.py#L27-L33>`_ for more details.
80+
81+
6682
License
6783
=======
6884

0 commit comments

Comments
 (0)