[wp-hackers] WP_Rewrite: Disable post/Page paging ability?
Otto
otto at ottodestruct.com
Thu Jul 31 14:27:35 GMT 2008
Hang on, there's a function to do this sort of thing already.
get_post_ancestors. Why isn't it using that? Just do a get_post on the
page, then a get_post_ancestors on it..
Even if that doesn't make sense for some reason, if this function was
adding the results of those lookups to the cache, then it wouldn't
have to lookup any given parent more than once. You've got half a
dozen queries each for the parent of pages 4 and 3 in there.
On Wed, Jul 30, 2008 at 5:20 PM, Viper007Bond <viper at viper007bond.com> wrote:
> Yeah, that's what I figured.
>
> This same issue though could easily be reproduced though without any plugins
> (say by having a bunch of Pages with stubs that are all "foobar"). Perhaps
> it's worth grabbing all parents of the post_name query at once and then
> looping through those results rather than querying for each parent one by
> one?
>
> On Wed, Jul 30, 2008 at 7:12 AM, Otto <otto at ottodestruct.com> wrote:
>
>> get_page_by_path makes a call to get all the pages matching a post
>> name. In the case of http://asdfsa345.pastebin.com/m4c8095f3, that is
>> query number 9:
>> SELECT ID, post_name, post_parent FROM wp_posts WHERE post_name = '8'
>> AND (post_type = 'page' OR post_type = 'attachment')
>>
>> It then loops through all the found page parents to build the page
>> path, one at a time. Then it tries to match that path with the actual
>> path it's looking for. When it finds a match, it stops and gets that
>> page.
>>
>> You're getting all these queries because you have, by my quick count,
>> at least seven pages with a post_name of "8", before it finds the one
>> it's looking for.
>>
>>
>>
>> On Tue, Jul 29, 2008 at 8:20 PM, Viper007Bond <viper at viper007bond.com>
>> wrote:
>> > Found a bad side effect -- it's nearly doubling my queries on those
>> Pages.
>> >
>> > Query dump: http://asdfsa345.pastebin.com/m4c8095f3
>> >
>> > Seems get_page_by_path() is being called a couple dozen times. Why I have
>> no
>> > clue...
>> >
>> > For example: SELECT ID, post_name, post_parent FROM wp_posts WHERE ID =
>> 46
>> > and post_type='page'
>> >
>> >
>> > Some example URL structures incase it helps:
>> >
>> > http://site.com/mypage/8/
>> > http://site.com/mypage/8/1/
>> > http://site.com/mypage/8/8/
>> > http://site.com/mypage/1/8/
>> > http://site.com/mypage/5/
>> > http://site.com/mypage/5/8/
>> > http://site.com/mypage/5/6/
>> > etc.
>> >
>> > Any ideas what's wrong and what I can do to cut it down? It's the end of
>> the
>> > world as I Super Cache, but I'd still like to figure out what's going on
>> > behind the scenes. :)
>> >
>> > --
>> > Viper007Bond | http://www.viper007bond.com/ | http://www.finalgear.com/
>> > _______________________________________________
>> > wp-hackers mailing list
>> > wp-hackers at lists.automattic.com
>> > http://lists.automattic.com/mailman/listinfo/wp-hackers
>> >
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>
> --
> Viper007Bond | http://www.viper007bond.com/ | http://www.finalgear.com/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list