#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)
Change History (12)
#2
@
16 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.
#3
@
15 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
@
15 years ago
- Owner changed from anonymous to Denis-de-Bernardy
- Status changed from new to accepted
#7
in reply to:
↑ 6
@
15 years ago
Replying to scribu:
Sorry for the noob question, but what exactly is a page stub?
It's the thing in the URL.
Otto pointed out on wp-hackers that
get_post_ancestors()
may do the trick.