Skip to content

Avoid unnecessary SQL query when calling ActiveRecord::Relation#cache_key#38099

Merged
eileencodes merged 1 commit intorails:masterfrom
alipman88:avoid_unecessary_query_if_cache_versioning_enabled
Jan 6, 2020
Merged

Avoid unnecessary SQL query when calling ActiveRecord::Relation#cache_key#38099
eileencodes merged 1 commit intorails:masterfrom
alipman88:avoid_unecessary_query_if_cache_versioning_enabled

Conversation

@alipman88
Copy link
Contributor

@alipman88 alipman88 commented Dec 26, 2019

With collection_cache_versioning enabled, a collection's volatile info (size & max updated_at timestamp) is included in ActiveRecord::Relation#cache_version, not #cache_key.

Avoid the SQL query to used determine this volatile info when generating an un-versioned cache key. This query does not need to be executed unless #cache_version is called separately.

With collection_cache_versioning enabled, a collection's volatile info
(size & max updated_at timestamp) is included in
ActiveRecord::Relation#cache_version, not #cache_key.

Avoid the SQL query to used determine this volatile info when generating
an un-versioned cache key. This query does not need to be executed
unless cache_version is called separately.
@alipman88 alipman88 force-pushed the avoid_unecessary_query_if_cache_versioning_enabled branch from 68965c3 to 76bb971 Compare December 26, 2019 18:10
@alipman88 alipman88 marked this pull request as ready for review December 26, 2019 18:11
@eileencodes eileencodes merged commit be40e8e into rails:master Jan 6, 2020
@eileencodes
Copy link
Member

Thanks for the PR @alipman88!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants