wc-smooth-generator icon indicating copy to clipboard operation
wc-smooth-generator copied to clipboard

[Enhacement]: Improve getting a random user

Open ovidiul opened this issue 3 years ago • 0 comments

All Submissions:

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:

  1. merge the PR
  2. ideally, a large set of over 100K records in wp_users table should exist
  3. measure the time for time wp wc generate orders 10 before 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.

ovidiul avatar Jan 27 '22 13:01 ovidiul