WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 5 years ago

Last modified 5 years ago

#7443 closed enhancement (duplicate)

Having many Pages with the same stub causes excess queries

Reported by: Viper007Bond Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.6
Component: Optimization Keywords: needs-patch
Focuses: Cc:

Description

If you have many Pages with the same stub, many queries can be required to view the Page. This is because it first grabs all Pages with the stub (1 query). Then it loops through each result and queries the details for that result's parent looking for a match.

Instead, why not turn the IDs to search for into a list and grab all of those parents at once? It's a little heavier query, but it's one query rather than tons. Then you can loop through those results checking via PHP.

Thoughts? Am I missing something?

Attachments (1)

7443.diff (1.2 KB) - added by ryan 8 years ago.

Download all attachments as: .zip

Change History (12)

#1 @Viper007Bond
8 years ago

Otto pointed out on wp-hackers that get_post_ancestors() may do the trick.

#2 @ryan
8 years ago

We need to walk the parents, not the ancestors.

This untested patch might help a bit. It does one query for the immediate parents, which primes the cache.

@ryan
8 years ago

#3 @Denis-de-Bernardy
7 years ago

another alternative would be to walk nothing: when implementing permalink history (another ticket), I'll need to insert post_meta fields. we could then do a direct db check to find a post against a post_meta value.

#4 @Denis-de-Bernardy
7 years ago

  • Owner changed from anonymous to Denis-de-Bernardy
  • Status changed from new to accepted

#5 @Denis-de-Bernardy
7 years ago

  • Owner Denis-de-Bernardy deleted
  • Status changed from accepted to assigned

#6 follow-up: @scribu
7 years ago

Sorry for the noob question, but what exactly is a page stub?

#7 in reply to: ↑ 6 @Viper007Bond
7 years ago

Replying to scribu:

Sorry for the noob question, but what exactly is a page stub?

It's the thing in the URL.

http://site.com/post-parent/this-is-the-slug/

#8 @ryan
6 years ago

  • Milestone changed from 2.9 to Future Release

#9 @johnbillion
5 years ago

  • Resolution set to duplicate
  • Status changed from assigned to closed

This is being addressed in #16687

#10 @johnbillion
5 years ago

At least, I think it is. Re-open if not.

#11 @SergeyBiryukov
5 years ago

  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.