• I have a plugin that inserts a post. It used to run fast, but now it takes upwards of 8 minutes to do its job. I’ve used time() to calculate execution times at various stages. The part that I expected to be slow (using GD to resize images) is actually real quick. What kills me is one call to wp_insert_post() that reliably takes 259 seconds.

    Following that call, I use $wpdb to insert two categories for this post and 7 postmeta values. All that database work takes ANOTHER 258 seconds. Those two numbers are suspiciously close.

    Also, posting a post in the admin interface takes a hellatiously long time too. Obviously I haven’t hacked into the core code to profile it, but I’d say it’s taking at least several minutes.

    I’ve run myisamchk on my databases. Several say that they are usable but could stand fixing. You think running repairs on the database might fix this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Try timing it with nothing in “Update Services” at Options -> Writing.

    Thread Starter ratbastid

    (@ratbastid)

    Oh. My. God.

    My client had 64 ping targets in there. Sixty-effing-four. He’s SO fired.

    Clearing them out makes my posting go lickety-split. I’m glad I just spent my whole day hacking a mechanism to make the posting happen in the background.

    Thanks for your help HandySolo.

    So glad to help. ??

    And hey, that reminds me (if you’re still working on the background thing) that there is a plugin floating around that’ll do just that: All the pings in the background. NoPingWait I think it’s called?

    Incidentally, letting us know about the plugin would be nice. I have to do a plugin that automatically inserts a post every week and it seems wp_insert_post() is not documented anywhere I can find.

    The plugin isn’t necessary – you replied to a post that is 5 months old. Since that last post, several versions of WP have come out and outbound pings are handled completely differently and no longer affect post insertion times

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Why does wp_insert_post() take 4.5 minutes?’ is closed to new replies.