Skip to content
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

Grid range filter - optimize SQL query when from === to #1637

Conversation

Sekiphp
Copy link
Collaborator

@Sekiphp Sekiphp commented May 24, 2021

Description (*)

Optimalize SQL query in grid, when you filter same values in range field (number range) + added some docs & type hints.

SQL before

SELECT `main_table`.* 
FROM `sometable` AS `main_table` 
WHERE (`sid` >= '31233' AND `sid` <= '31233') ORDER BY sid DESC LIMIT 20

image

SQL after

SELECT `main_table`.* 
FROM `sometable` AS `main_table` 
WHERE (`sid` = '31233') ORDER BY sid DESC LIMIT 20

image

Special thanks to: original idea from @midlan

Manual testing scenarios (*)

  1. Put same values to from and to in grid and check SQL query
    image

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)

@github-actions github-actions bot added the Component: Adminhtml Relates to Mage_Adminhtml label May 24, 2021
@Sekiphp Sekiphp changed the title Grid + Range filter - add doc, hints, optimize SQL query when from ==… Grid range filter - optimize SQL query when from === to May 24, 2021
Copy link
Collaborator

@kiatng kiatng left a comment

Choose a reason for hiding this comment

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

Nice work.

app/code/core/Mage/Adminhtml/Block/Widget/Grid.php Outdated Show resolved Hide resolved
@Sekiphp
Copy link
Collaborator Author

Sekiphp commented May 26, 2021

@kiatng Thank you for your suggestions! Implemented :-)

@Flyingmana Flyingmana merged commit 061dbe0 into OpenMage:1.9.4.x Jul 13, 2021
@github-actions
Copy link

Unit Test Results

1 files  ±0  1 suites  ±0   0s ⏱️ ±0s
0 tests ±0  0 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
6 runs  ±0  4 ✔️ ±0  2 💤 ±0  0 ❌ ±0 

Results for commit 061dbe0. ± Comparison against base commit 76e8fe3.

@joshua-bn
Copy link
Contributor

Interesting that MySQL didn't catch that to optimize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Adminhtml Relates to Mage_Adminhtml
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants