plugins - how to insert thousands of posts faster?

I'm trying to insert thousands of posts in my database using a script. I read a xlsx file (I test this one only, ar

I'm trying to insert thousands of posts in my database using a script. I read a xlsx file (I test this one only, around 19 seconds to read the 4k rows). I'm using wp_insert_post to create and update_post_meta to add/update the metas of each post. The timing of my script to do this is aroung 20 minutes. I'm looking for ways to do this operation faster. I tried use API Rest, but it's the same timing to insert. And now, I use this code:

//i use this 3 functions(I found it on answers in stackoverflow)

wp_suspend_cache_addition(true);
wp_defer_term_counting( true );
wp_defer_comment_counting( true );

//read all file in 20 seconds, and insert a post for each row

//wp_insert_post here, with the all code

And then turn to false the 3 functions again. Any tip or trick to improve the speed? I thought in turn all of this in a line of SQL and pass only one big string as query to my database, but I guess that is not safe(wp_insert_posts take care of the data to me, is'nt?)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745452914a4628352.html

相关推荐

  • plugins - how to insert thousands of posts faster?

    I'm trying to insert thousands of posts in my database using a script. I read a xlsx file (I test this one only, ar

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信