When I insert a post I’ve found that there is a slow call to wp_unique_post_slug from within insert_post (In the database I’m using to test there is 155,000 posts – live would have considerably more). As I don’t believe a slug is important for what I’m doing (a person who is browsing our site will probably never see a single page view for this post type), is there anything I can do that can either speed up the call or (better yet) eliminate it.
Looking at the code for insert_post, I couldn’t see a way of doing it without modifying core (which is something I’d rather not do). The code I’m using is:
$post = array(
'post_title' => 'post_title',
'post_type' => 'character',
'post_status' => 'publish'
);
$post_id = wp_insert_post( $post );
Edit:
As it appears people are missing the information that I have written in this question. Here is the issue as clear as I can make it.
The Problem:
Slow performance. I have tracked this down to the function wp_unique_post_slug
called from within wp_insert_post
The code that calls wp_insert_post
:
$post = array(
'post_title' => 'post_title',
'post_type' => 'character',
'post_status' => 'publish'
);
$post_id = wp_insert_post( $post );
(yes they are all strings and not variables being assigned to $post)
Other information:
The post status needs to be ‘publish’ as these posts are presented to the user (although not in the standard WordPress manner).
I could fix it by editing core, but this is a BAD idea for a number of reasons.
A slug is not important as the user shouldn’t be going to a single page view of this content type.