Discussion:
Performance improvement -- '/%postname%/%post_id%/' over '/%postname%/'?
Aahan Krish
2014-01-11 16:44:41 UTC
Permalink
I am building a WordPress Multisite network for my college. One of the
subsites works like a bookmarking service where registered students can
share useful links; each post is equivalent to a bookmark. (Custom fields &
meta boxes are used for custom UI in post editor.)

Considering that many posts are made each day (upwards 50), which of these
two permalink structures would suit us best?

/%postname%/, e.g. domain.com/sample-post/

/%postname%/%post_id%/, e.g. domain.com/sample-post/123/

Will the '/%postname%/%post_id%/' permalink structure help as the database
size grows (i.e. the no. of posts)? or can we simply stick with
'/%postname%/' no matter what?

best,
Aahan
Nicholas Ciske
2014-01-11 16:57:16 UTC
Permalink
Theoretically the second would be faster but as of 3.3 it's pretty negligible unless you have a lots of pages or very deep page hierarchy.

http://ottopress.com/2011/how-the-postname-permalinks-in-wordpress-3-3-work/

Cached version (above gave me a nginx error)
http://webcache.googleusercontent.com/search?q=cache:KiMNuNmIbykJ:ottopress.com/2011/how-the-postname-permalinks-in-wordpress-3-3-work/

_________________________
Nick Ciske
http://thoughtrefinery.com/
@nciske
Post by Aahan Krish
Considering that many posts are made each day (upwards 50), which of these
two permalink structures would suit us best?
/%postname%/, e.g. domain.com/sample-post/
/%postname%/%post_id%/, e.g. domain.com/sample-post/123/
Will the '/%postname%/%post_id%/' permalink structure help as the database
size grows (i.e. the no. of posts)? or can we simply stick with
'/%postname%/' no matter what?
Otto
2014-01-11 19:31:28 UTC
Permalink
Post by Nicholas Ciske
Theoretically the second would be faster but as of 3.3 it's pretty negligible unless you have a lots of pages or very deep page hierarchy.
http://ottopress.com/2011/how-the-postname-permalinks-in-wordpress-3-3-work/
Cached version (above gave me a nginx error)
Sorry about that. My site has been getting hammered by bots a lot
lately. Can't block them when I'm asleep. :)

-Otto
Otto
2014-01-11 19:48:13 UTC
Permalink
Post by Aahan Krish
Considering that many posts are made each day (upwards 50), which of these
two permalink structures would suit us best?
/%postname%/, e.g. domain.com/sample-post/
/%postname%/%post_id%/, e.g. domain.com/sample-post/123/
Will the '/%postname%/%post_id%/' permalink structure help as the database
size grows (i.e. the no. of posts)? or can we simply stick with
'/%postname%/' no matter what?
They will be basically identical in terms of performance, for any
WordPress version. Using either form will trigger the
"verbose_page_rules" flag.

- This will cause WP versions pre-3.3 to generate individual Page
rules in the rewrite rules list. This can be a problem if you have
lots of Pages.
- This will cause WP versions post-3.3 to generate 1 extra SQL query
to determine if the URL matches an existing Page in the database.

In either case, the impact of the two different rules is identical. No
need to tack a post ID on there.

-Otto
Nikola Nikolov
2014-01-11 19:54:14 UTC
Permalink
What could possibly be faster though would be to create a custom post type
with it's own custom rewrite rules(in the form of
"/cpt/%cpt_name%/%post_id%/" - you would get slightly longer permalinks,
but it might be worth it. You wouldn't have to pass the post name to the
query, but just the ID. It will also require some extra code - to create
the proper permalinks when they are requested for a post of that post type,
to add in the rewrite rules, etc.
Post by Aahan Krish
Post by Aahan Krish
Considering that many posts are made each day (upwards 50), which of
these
Post by Aahan Krish
two permalink structures would suit us best?
/%postname%/, e.g. domain.com/sample-post/
/%postname%/%post_id%/, e.g. domain.com/sample-post/123/
Will the '/%postname%/%post_id%/' permalink structure help as the
database
Post by Aahan Krish
size grows (i.e. the no. of posts)? or can we simply stick with
'/%postname%/' no matter what?
They will be basically identical in terms of performance, for any
WordPress version. Using either form will trigger the
"verbose_page_rules" flag.
- This will cause WP versions pre-3.3 to generate individual Page
rules in the rewrite rules list. This can be a problem if you have
lots of Pages.
- This will cause WP versions post-3.3 to generate 1 extra SQL query
to determine if the URL matches an existing Page in the database.
In either case, the impact of the two different rules is identical. No
need to tack a post ID on there.
-Otto
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Otto
2014-01-11 20:36:46 UTC
Permalink
Post by Nikola Nikolov
What could possibly be faster though would be to create a custom post type
with it's own custom rewrite rules(in the form of
"/cpt/%cpt_name%/%post_id%/" - you would get slightly longer permalinks,
but it might be worth it. You wouldn't have to pass the post name to the
query, but just the ID. It will also require some extra code - to create
the proper permalinks when they are requested for a post of that post type,
to add in the rewrite rules, etc.
The post_name and the ID are both indexed fields in the database. The
performance difference for querying on one vs. the other is either
negligible or actually non-existent.

-Otto
Aahan Krish
2014-01-13 11:25:49 UTC
Permalink
Thank you, Nikola and Otto. In the end I went with '/%year%/%postname%/'
permalink structure.
Post by Otto
Post by Nikola Nikolov
What could possibly be faster though would be to create a custom post
type
Post by Nikola Nikolov
with it's own custom rewrite rules(in the form of
"/cpt/%cpt_name%/%post_id%/" - you would get slightly longer permalinks,
but it might be worth it. You wouldn't have to pass the post name to the
query, but just the ID. It will also require some extra code - to create
the proper permalinks when they are requested for a post of that post
type,
Post by Nikola Nikolov
to add in the rewrite rules, etc.
The post_name and the ID are both indexed fields in the database. The
performance difference for querying on one vs. the other is either
negligible or actually non-existent.
-Otto
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...