django-cachalot icon indicating copy to clipboard operation
django-cachalot copied to clipboard

Add a setting for enabling iterator caching

Open danlamanna opened this issue 1 year ago • 1 comments

Fixes https://github.com/noripyt/django-cachalot/issues/256

Description

This adds a setting to enable caching query results when they're generators.

Rationale

Caching iterators causes OOM errors as documented in #256 when using QuerySet.iterator for large result sets because of list coercion.

I defaulted this setting to False since I think that's less surprising behavior, but this does change the existing behavior, so it would be a breaking change. Let me know if I should invert it to cache iterators by default as it currently does.

danlamanna avatar Sep 03 '24 18:09 danlamanna

@Andrew-Chen-Wang Thoughts on this?

danlamanna avatar Oct 01 '24 16:10 danlamanna

Gentle bump - any updates on this?

danlamanna avatar Jan 15 '25 20:01 danlamanna

lgtm thank you

Andrew-Chen-Wang avatar Jan 16 '25 03:01 Andrew-Chen-Wang

thx for this. I don't think it's a breaking change albeit a changing behavior. As they say, don't add performance improvements until you notice performance hits. If people notice a slowdown, I'm sure they can check the CHANGELOG to see this change and re-enable the setting.

Andrew-Chen-Wang avatar Jan 16 '25 03:01 Andrew-Chen-Wang

hi this should be included in the new version (coming in an hour or two); i've reverted it to True again FYI, so you'll need to have it set to False.

Andrew-Chen-Wang avatar Apr 17 '25 00:04 Andrew-Chen-Wang