Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've seen in various places, including the Wordpress admin and on this page, that using string based identifiers is "strongly not recommended for performance reasons".

I understand that looking up a string in the database is slower than looking up an integer, but in my experience it's never a huge difference, assuming the slug field has a fulltext index.

Why is there such a strong discouragement of using this method?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

This is much more complex than looking up string versus integer. WordPress sifts permalink through a set of persistent regexp-based rules. And it affects logic a lot that string might be many more things than number. See one of better writeups on topic for details.

Practical point to know - this doesn't concern most sites, except those that have many pages (like PAGE pages, not posts).

Even better point to know - this is all getting fixed in WP 3.3 and will be thing of the past.

share|improve this answer
    
...which is a well-written way to say: "yes, it really is that bad for performance for now, but that performance issue is being addressed in WordPress 3.3". –  Chip Bennett Aug 16 '11 at 16:02
    
I stumbled upon an old thread on Wordpress.org recently, I'll have to dig it up. Someone had quite a few pages and page admin screens were running 2000+ queries, mostly rewrite rules due to the use of /%postname%/. –  Milo Aug 16 '11 at 16:17
    
Based on that article, does it mean if you have no pages then it is just a simple lookup for the postname? And vice-versa - if you use a numeric identifier then it doesn't add all those separate page names, it just looks up the slug as a page name instead? –  DisgruntledGoat Aug 16 '11 at 16:19
    
@DisgruntledGoat it means that such permalink format specifically affects page-related rules. So performance starts to degrade more the more pages you have. This is not at database query stage, this is when matching link against regular expressions of rewrite rules. –  Rarst Aug 16 '11 at 17:50
    
@Milo that should not happen and likely caused by plugin flushing rewrite rules (which should not be done, because rewrite rules are being saved persistently). The performance problem is size of rewrite rules array, not that it causes additional queries to database. –  Rarst Aug 16 '11 at 17:53

Just adding another perspective from Chris Coyier: http://digwp.com/2011/06/dont-use-postname/

There is also some good feedback in the comments section from one of the WordPress developers about why it happens and what they are doing to fix it.

share|improve this answer
    
It would be far better if you would summarize that other perspective, rather than merely linking to it. Also: if that perspective merely supports @Rarst's answer above, this would probably be better-suited as a comment to his answer, rather than a separate answer. –  Chip Bennett Aug 16 '11 at 16:09
1  
Sorry I'm new to the site and was just trying to pass along a helpful link in the middle of a busy work day. Chris basically explains how the number of queries that WordPress must make to determine whether a URL represents a post or a page goes up significantly when the permalink starts with a string. Either a date or a post ID could be used to avoid slowdown. –  Kevin Hoffman Aug 16 '11 at 16:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.