[wp-testers] Wordpress scaling problems

DD32 wordpress at dd32.id.au
Thu Jan 29 00:29:11 GMT 2009


As mentioned on that ticket, If you're using a sane rewrite pattern,
then theres no problem at all, Most people will have about 20 rewrite
rules no matter how many posts/attachments/pages they have.

The moment you introduce %category% or %postname% to the start of the
rewrite structure, You start hitting problems relating to what to
match..

Does /abcxyz/ match a category? A Post? A Page?
Eg:
/category-name/subcategory/
/page-name/sub-pagename/
/category-name/post-name/
They're all on the same regular expression, In order to separate them,
you've either got to do at least a few queries (3-5 i think), and
they're not fast queries generally either.. in the time you've spent
querying, most other blogs would've served another page or 2..

Whereas, With the other forms,
/2006/08/23/postname
its easy to tell straight up this is a post, it starts with a number -
year archive, another number, month archive, another number, day
archve, a string, a postname,
Then, Is it followed by another string? Attachment, Is that string
'attachment'? Then the attachment name(which is likely a number)
follows that. Was the string 'page'? Then the next item is the posts
pagenumber

Its straightforward and easy to match.

/%category%/%postname%/ leaves us with
Ok, first string, Is it a pagename, No. Is it a category? Yes. Ok,
Ignore it. Next, Is it a category? No. Is it a post? Yes. Does
anything more follow?
Or
First string, Is it a page, Yes, (Hey, what if theres a category of
the same slug?), Is the next a string? Yes, Ok, is that a page? no..
ok, is it an attachment? no.. ok.. what then.. 404, oh hang on, lets
just check its not a dodgy url *queries for the page*

The other thing is, That what i've written there is a lot more
straight forward than WP does, Since it also has to deal with authors,
tags, exclusions, etc. its never a straightforward thing..

So it comes down to, Having to put the pagenames or categories into
the rewrite rules in order to speed the matching up.. But as you've
found, Theres a point where you exceed MySQL's limits.

/me wishes that %category% was never allowed in the permalinks


2009/1/29 scribu <scribu at gmail.com>:
> On Wed, Jan 28, 2009 at 7:57 PM, matthijs <matthijsenator at gmail.com> wrote:
>
>> Recently I discovered that the current way wordpress handles permalinks is
>> not scalable. All rewrite_rules are at the moment held in a single database
>> field in the wp_options table. If you have a few dozens pages and posts,
>> you
>> have maybe a few hundred rewrite_rules in it and all is well. But as soon
>> as
>> you start to have a few hundred pages and attachments, the amount of
>> rewrite_rules explodes as well as the field size. This also depends on the
>> permalinks settings. On one of my sites I can't even open the database
>> field
>> to take a look because my browser and text editor crash because of its
>> size.
>> At some point the rewrite_rules don't fit anymore and wordpress needs to
>> run
>> thousands of queries for each page load (because wp is rebuilding the rules
>> each time but can't insert them in the db).
>>
>> See also trac 8958
>> http://trac.wordpress.org/ticket/8958
>>
>> I was wondering:
>> What are the ideas about how this issue can be solved? Are there plans to
>> restructure the way permalinks and rewrite rules are kept in the database?
>> Or on how to deal with uploads/attachments?
>>
>> Wouldn't it be better to put the rules in their own db table?
>> _______________________________________________
>> wp-testers mailing list
>> wp-testers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-testers
>>
>
>
> Aren't most rewrite rules based on regex patterns? I.E., if you have
> %postid% as the structure, there would be only one rule that matches one
> post ID or none. Right?
>
> --
> http://scribu.net
> _______________________________________________
> wp-testers mailing list
> wp-testers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-testers
>


More information about the wp-testers mailing list