Use comments counter cache instead of additional query#7627
Merged
mrcasals merged 2 commits intodecidim:developfrom Mar 25, 2021
Merged
Use comments counter cache instead of additional query#7627mrcasals merged 2 commits intodecidim:developfrom
mrcasals merged 2 commits intodecidim:developfrom
Conversation
mrcasals
approved these changes
Mar 25, 2021
entantoencuanto
added a commit
that referenced
this pull request
Mar 26, 2021
* develop: (64 commits) Fix report mailers when author is a meeting (#7683) New Crowdin updates (#7729) Fix form builder assuming proposals module availability (#7689) Fix a series of issues with proposal attachments in the public area (#7699) New Crowdin updates (#7711) Add accessibility labels to the <nav> menus (#7709) Fix heading order on the home page (#7710) Fix dropdown menu accessibility audits (#7708) Fix the aria attribute names (no aria prefix) (#7707) Fix validations for registration related fields in Conference form (#7675) New Crowdin updates (#7613) Use comments counter cache instead of additional query (#7627) Upgrade to decidim-bulletin_board 0.15.2 (#7659) Bump mimemagic to 0.3.6 (#7701) Ensure pagination elements per page is a valid option (#7680) Fix link to "Getting started guide" in README.adoc (#7695) Fix link to CONTRIBUTING.adoc in PR template (#7696) Fix the screen reader class name for comments opinion toggle (#7698) Fix initiative-m card hashtags (#7679) Don't run all jobs on every PR (#7693) ...
ahukkanen
added a commit
to mainio/decidim
that referenced
this pull request
Jul 12, 2021
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎩 What? Why?
When browsing e.g. the blogs index, you can see from the benchmarks that there are bunch of
COUNTqueries done against the comments table.The counter caches were already added at #6438 but they are not properly used.
It also does not work if we would add
counter_cache: :comments_countto the commentable concern:decidim/decidim-comments/lib/decidim/comments/commentable.rb
Line 13 in 96c78cb
Even after it is added there and the
Commentmodel (as with other counter caches), the queries won't disappear.The only way how I could figure out to get rid of the extra queries was by accessing the cache column directly.
📌 Related Issues
Testing
COUNTqueries against the comments table (see screenshot)📋 Checklist
docs/.📷 Screenshots