admin管理员组文章数量:1429828
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?)
本文标签: pluginshow to insert thousands of posts faster
版权声明:本文标题:plugins - how to insert thousands of posts faster? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745452913a2658968.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论