[wp-hackers] Unique permalinks vs. unique post slugs
Otto
otto at ottodestruct.com
Wed Dec 17 05:38:16 GMT 2008
On Tue, Dec 16, 2008 at 11:30 PM, Otto <otto at ottodestruct.com> wrote:
> On Tue, Dec 16, 2008 at 4:45 PM, scribu <scribu at gmail.com> wrote:
>> What about nested pages? You can have pages with different parents and the
>> same slug. Why isn't that expensive?
>
> Pages are different. Each page URL is individually built and matched
> against to start with. So if a page URL matches completely, then
> everything else is overridden and the page is directly pulled.
>
> This is actually quite expensive when you scale it up, because if you
> have LOTS of pages, then the page permalink URLs list gets quite large
> and slow to pull out of the DB. But, since most sites have a low Page
> count, it's not expensive enough to mess with.
>
Okay, actually, that's somewhat simplistic...
There's a flag called use_verbose_page_rules in the rewrite system
that gets invoked whenever you include %postname%, %category%, %tag%,
or %author% in your permalink settings.
When you're not using one of those, then pages are matched like
everything else on the pagename, which makes it quite quick. Pages, in
that case, get matched last, when nothing else works.
When you are using one of those, then it has to build the page URI
list in order to match against them directly, *before* all the other
rules, so that it pulls the matching pages before it matches against
something else inadvertently.
The WP_Rewrite class can be quite complex at times.
More information about the wp-hackers
mailing list