简体   繁体   English

WordPress插入数千条记录

[英]Wordpress insert thousands of records

I am facing issue server execution timeout and sometime maximum memory used. 我面临问题服务器执行超时和有时使用的最大内存。

I want to insert 30k records into database from a CSV. 我想从CSV将3万条记录插入数据库。

The issue is everything is going through the one loop. 问题是一切都在一个循环中进行。

I have changed the entries in wp-config and php.ini like excution time = 0 , maximum memory = -1 . 我已经更改了wp-config和php.ini中的条目,例如执行时间= 0,最大内存= -1。 This has solved the FATAL errors but leaking memory. 这已经解决了致命错误,但内存泄漏。 HTTPD eats all my computer ram and still has to process 25K records. HTTPD吞噬了我所有的计算机内存,仍然需要处理25K条记录。

I would like to release memory after every insertion (I am using wordpress default function to insert in to database not SQL). 我想在每次插入后释放内存(我正在使用wordpress默认函数插入数据库而不是SQL)。

I have searched alot and found that in SQL we can write GO after insert query this releases the memory but what we can do in wordpress. 我进行了大量搜索,发现在SQL中我们可以在插入查询后写GO,这样可以释放内存,但是我们可以在wordpress中做些什么。

I am using CSV import export plugin to import CSV. 我正在使用CSV导入导出插件来导入CSV。 [Please don't recommend WP-All import it is not fulfilling my requirement to enter data in custom field in taxonomy]. [请不要推荐WP-All导入,因为它不满足我在分类法的自定义字段中输入数据的要求]。

Calling : 致电:

wp_cache_flush(); 

Solved my issue. 解决了我的问题。

您可以使用禁用当前请求的缓存

wp_suspend_cache_addition(true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM