Skip to content

Remove redundant COUNT() call for 1st page of results #34484

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

Conversation

lbajsarowicz
Copy link
Contributor

@lbajsarowicz lbajsarowicz commented Oct 29, 2021

Description (*)

Magento is performing lots of redundant DB calls in all the places where pagination is used.

The Category Edit page is one of the examples. If you are on the 1st page, it does not make sense to calculate the last page and redirect to the 1st one... Because you are on the 1st one.

The results of this optimization are worth the change :)

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes magento/magento2#<issue_number>

Manual testing scenarios (*)

  1. ...
  2. ...

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Oct 29, 2021

Hi @lbajsarowicz. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.

For more details, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@lbajsarowicz
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@ihor-sviziev ihor-sviziev self-assigned this Oct 30, 2021
@ihor-sviziev ihor-sviziev added Area: Performance Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Oct 30, 2021
Copy link
Contributor

@ihor-sviziev ihor-sviziev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lbajsarowicz,
Great improvement! I guess for large data sets it might be really noticeable. Do you have some measurements?
PS: I guess you're talking about the grid of the products that are used in the category, right?

Could you cover this change with a simple unit test?

@ihor-sviziev ihor-sviziev added Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests Risk: low labels Oct 30, 2021
@lbajsarowicz
Copy link
Contributor Author

lbajsarowicz commented Oct 30, 2021

@ihor-sviziev Of course, Unit Tests are coming in another commit.

@OlgaVasyltsun Quick hint for you: When you are creating a new plugin, like \Magento\Theme\Plugin\Data\Collection:

  1. It's more helpful when you are navigating through the plugins when name of a plugin contains Plugin suffix
  2. I strongly recommend naming the plugins by their role, not the class they override. Why? It's simple:
    • It helps to keep Single Responsibility in the class, as lazy developers won't add other logic into the same plugin,
    • A single plugin can be applied to different classes, based on the Interface passed in $subject.

Of course, these are only hints.

@lbajsarowicz
Copy link
Contributor Author

@magento run unit tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@Den4ik Den4ik self-requested a review October 30, 2021 11:33
@ihor-sviziev
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

1 similar comment
@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@ihor-sviziev
Copy link
Contributor

@magento run Functional Tests EE, Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@nrkapoor nrkapoor added this to the 2.4.4 milestone Nov 2, 2021
@nrkapoor nrkapoor added Severity: S1 Affects critical data or functionality and forces users to employ a workaround. and removed Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Nov 2, 2021
@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@ihor-sviziev
Copy link
Contributor

@magento run Functional Tests EE, Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

1 similar comment
@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@sidolov sidolov added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Nov 3, 2021
@ihor-sviziev
Copy link
Contributor

@magento convert to patch for 2.4.3

@ihor-sviziev
Copy link
Contributor

@magento convert to patch for 2.3.7

@m2-github-services
Copy link
Collaborator

@ihor-sviziev changes has been successfully converted for 2.4.3 version and pushed to the converted-magento-magento2-2.4.3 branch.

You may submit a pull request using the link: 2.4.3-release...magento:converted-magento-magento2-2.4.3

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Nov 4, 2021

Hi @lbajsarowicz,
Could you create a new PR (in addition to this) for the following changes 2.4.3-release...magento:converted-magento-magento2-2.4.3 to convert them to a quality patch?

@Den4ik
Copy link
Contributor

Den4ik commented Nov 4, 2021

@sidolov, I believe that we could move it to "Merge in Progress".

@sidolov
Copy link
Contributor

sidolov commented Nov 4, 2021

@magento convert to patch for 2.3.7

@sidolov
Copy link
Contributor

sidolov commented Nov 4, 2021

@magento convert to patch for 2.3.7

@magento magento deleted a comment from m2-github-services Nov 4, 2021
@m2-github-services
Copy link
Collaborator

@sidolov an error occurred during the patch generation.
Failure can be caused by the incompatible with base branch changes.
To replicate the issue try to apply patch locally using git am command.

@magento magento deleted a comment from m2-github-services Nov 4, 2021
@magento magento deleted a comment from m2-github-services Nov 4, 2021
@ihor-sviziev
Copy link
Contributor

@magento convert to patch for 2.4.3

@m2-github-services
Copy link
Collaborator

@ihor-sviziev changes has been successfully converted for 2.4.3 version and pushed to the converted-magento-magento2-34484-2.4.3 branch.

You may submit a pull request using the link: 2.4.3-release...magento:converted-magento-magento2-34484-2.4.3

@magento-engcom-team magento-engcom-team merged commit 4bf488d into magento:2.4-develop Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Performance Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: test coverage Component: Theme Partner: Blue Acorn iCi partners-contribution Pull Request is created by Magento Partner Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: ready for testing Release Line: 2.4 Risk: low Severity: S1 Affects critical data or functionality and forces users to employ a workaround.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants