Skip to content

Conversation

@rbino
Copy link
Contributor

@rbino rbino commented Dec 22, 2025

Highly dynamic queries with many different combinations of joins can generate unique cache keys on every execution, causing cache bloat while providing little performance benefit. This option allows selectively disabling Ecto's internal query cache for such cases, preventing cache pollution while still maintaining normal caching behavior for typical queries.

When set to false, the query bypasses cache lookup, cache insertion, and cache update callbacks, going directly to query normalization and adapter preparation on each execution.

Highly dynamic queries with many different combinations of joins can generate
unique cache keys on every execution, causing cache bloat while providing little
performance benefit. This option allows selectively disabling Ecto's internal
query cache for such cases, preventing cache pollution while still maintaining
normal caching behavior for typical queries.

When set to false, the query bypasses cache lookup, cache insertion, and cache
update callbacks, going directly to query normalization and adapter preparation
on each execution.
@greg-rychlewski greg-rychlewski merged commit 36c6804 into elixir-ecto:master Dec 23, 2025
7 checks passed
@greg-rychlewski
Copy link
Member

Thanks :)

@josevalim I could think of a couple small follow ups that might be good. If you agree, I wouldn't mind taking a stab at these:

  1. Make it so this option takes priority over our automatic cache disables. So basically enabling the opposite direction this PR is addressing. For example we disable the caching of values because we got some complaints about it not hitting the cache often enough. But there will be cases where people can be sure it will hit the cache.
  2. I think it should be possible to cleanly move this option deeper into the planner so that we don't generate the key at all if the option is set to false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants