Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#43891 closed enhancement (invalid)

Performance improvement for WP_Query

Reported by: rnaby's profile rnaby Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords: has-patch needs-testing
Focuses: Cc:


WP_Query has some(10 I think) use of reset() function. But it has a performance drawback. So here I'm proposing to replace the PHP native reset() function with class method which will work with foreach() loop.

Here is the benchmark-

Attachments (1)

43891.diff (3.6 KB) - added by rnaby 6 years ago.
The patch for the issue.

Download all attachments as: .zip

Change History (5)

6 years ago

The patch for the issue.

#1 @johnbillion
6 years ago

  • Keywords reporter-feedback added; 2nd-opinion dev-feedback removed
  • Severity changed from major to normal
  • Version trunk deleted

Thanks for the ticket and the patch, @rnaby, but I think your benchmarks are flawed. If you add judge($a, 'reset'); to the end of the test (after judge($a, '_reset'); you'll see that directly calling reset() is faster than the other methods. Your _reset() function incurs overhead that the reset() function doesn't.

Can you confirm?

Last edited 6 years ago by johnbillion (previous) (diff)

#2 @rnaby
6 years ago

@johnbillion Understood!

Last edited 6 years ago by rnaby (previous) (diff)

#3 @rnaby
6 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

#4 @SergeyBiryukov
6 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution changed from worksforme to invalid
Note: See TracTickets for help on using tickets.