[Answer]-Computing a large dataset in Django

1👍

Actually, your solution is almost ok. There are few advices:

  1. Don’t deepcopy queryset, it’s cloned when you slice it anyway.
  2. Slicing is inefficient from database perspective (large offset in a sql), it means database needs to prepare many rows and then pass you only few.
  3. Slicing is also unsafe if anything can be added or deleted from table in between.

You can adapt this thing to your case. Just use item_id instead of pk. It uses condition instead of offset so it’s much more efficient.

👤Suor

Leave a comment