Not much noticeable when working with individual posts, but when you create or delete multiple thousands in bulk and by code - process is quite slow.

Are there any good tweaks to apply and corners to cut?


  • wp_insert_post() with categories and tags passed;
  • add several custom fields;
  • create and associate attachments (from existing files).
  • 1
    It would be interesting to profile this operation so we can study the bottlenecks. Measure before you optimize!
    – Jan Fabry
    Feb 17 '11 at 15:06
  • @Jan Fabry makes sense. I will try to setup a profiled test run after I am done with it.
    – Rarst
    Feb 17 '11 at 15:09

When updating post taxonomies, you can call wp_defer_term_counting( true ) before you do your mass operation, and then wp_defer_term_counting( false ) to update the term counts only once per term.

  • Good one! I've seen this tweak mentioned, but completely forgot about it.
    – Rarst
    Feb 17 '11 at 15:10
  • nice one, never heard of it. you got my +1
    – Bainternet
    Feb 17 '11 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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