wc-smooth-generator
wc-smooth-generator copied to clipboard
[Enhacement]: Improve getting a random user
All Submissions:
- [x] Have you followed the Contributing guidelines?
- [x] Does your code follow the WordPress' coding standards?
- [x] Have you checked to ensure there aren't other open Pull Requests for the same update/change?
Changes proposed in this Pull Request:
Closes #78 .
This PR will simply replace the expensive query generated by the ORDER BY rand() LIMIT 1 and instead, it computes the offset from the user's tables and uses that along with wp_rand to get a record using the LIMIT offset, 1 query which proves to be less expensive on sites with a large number of users.
How to test the changes in this Pull Request:
- merge the PR
- ideally, a large set of over 100K records in wp_users table should exist
- measure the time for
time wp wc generate orders 10before and after the change
Other information:
- [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
- [ ] Have you written new tests for your changes, as applicable?
- [ ] Have you successfully run tests with your changes locally?
Changelog entry
Improves order generate for sites that have a large user base.
FOR PR REVIEWER ONLY:
- [x] I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.