Repository navigation
Perf: Fewer and lighter SQL queries for uncached category pages #1346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
06b90cd
c44cadb
296d490
f49a1cc
04f7e9f
988e00d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -396,6 +396,7 @@ private function addControllerSpecificFilters() | |
| // we add this one specific category ID, otherwise, we will add everything using nleft and nright | ||
| if (Configuration::get('PS_LAYERED_FULL_TREE')) { | ||
| $this->getSearchAdapter()->addFilter('nleft', [$category->nleft], '>='); | ||
| $this->getSearchAdapter()->addFilter('nleft', [$category->nright], '<='); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello guys, just one question, what this line does?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logically this changes nothing, in the nested set, every subcategory already has its nleft between the category's nleft and nright. The extra condition is only there for MySQL. Without an upper bound on nleft, the index range runs to the end of the tree, so MySQL was starting from all of the shop's products instead of just the subtree.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Hlavtox is this PR ok for you ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, now I understand. @LameuleFR Can you add some comment for next generations? :D Something like:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 988e00d, on both places using this bound ( |
||
| $this->getSearchAdapter()->addFilter('nright', [$category->nright], '<='); | ||
| } else { | ||
| $this->addFilter('id_category', [$idCategory]); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary abstraction, why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it removes an N+1:
getFeaturesBlock()ran one feature value query per displayed feature. Measured on 42 features, cold page: 42 queries / ~9.5 ms of SQL → 1 query / ~2.3 ms.getFeatureValues()keeps its signature for the other callers (Converter) and only loads what isn't loaded yet.