Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Inserting Hundreds of Thousands of Posts at Once

There are two reasons I can think of that may cause negative impact

  1. wp_insert_post retrieves the post from the DB after writing it to it. this is not fun but should have only a constant impact, so I’m guessing it is not your main problem

  2. Each post is being stored in memory as part of the caching process, and in the end this makes your server choke when it runs out of physical memory and starts swapping. try calling wp_suspend_cache_addition which suspends caching in the beginning of your script.

wp_suspend_cache_addition(true);

echo "get list of posts to be created in wordpress \n";

Related Posts:

  1. Why are simple updates to wp_postmeta’s “_edit_lock” so slow?
  2. How many ‘wp_insert_post’ calls can be performed in one shot, in a very long ‘for’ loop?
  3. HTML Entities in Post Title
  4. Insert two row in wordpress database
  5. MySQL Error: : ‘Access denied for user ‘root’@’localhost’
  6. MySQL Error: : ‘Access denied for user ‘root’@’localhost’
  7. How to use mysqli_query() in PHP?
  8. Access Denied for User ‘root’@’localhost’ (using password: YES) – No Privileges?
  9. Access Denied for User ‘root’@’localhost’ (using password: YES) – No Privileges?
  10. ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
  11. Column count doesn’t match value count at row 1
  12. ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
  13. MySQL string replace
  14. Cannot add or update a child row: a foreign key constraint fails
  15. ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
  16. String concatenation in MySQL
  17. What’s the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN? [duplicate]
  18. Cannot add or update a child row: a foreign key constraint fails
  19. MySQL Error “Operand should contain 1 column”
  20. How to use MySQL DECIMAL?
  21. Access denied for user ‘root@localhost’ (using password:NO)
  22. Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (38)
  23. How to make MySQL table primary key auto increment with some prefix
  24. Access denied for user ‘root@localhost’ (using password:NO)
  25. MySQL ERROR 1290 (HY000) –secure-file-priv option
  26. MySQL error 2006: mysql server has gone away
  27. Which MySQL data type to use for storing boolean values
  28. sql query with multiple where statements
  29. ERROR 2003 (HY000): Can’t connect to MySQL server on localhost (10061)
  30. ERROR 1698 (28000): Access denied for user ‘root’@’localhost’
  31. Cannot delete or update a parent row: a foreign key constraint fails
  32. Cannot delete or update a parent row: a foreign key constraint fails
  33. ERROR 2003 (HY000): Can’t connect to MySQL server on localhost (10061)
  34. MySQL server startup error ‘The server quit without updating PID file’
  35. Rename a column in MySQL
  36. “INSERT IGNORE” vs “INSERT … ON DUPLICATE KEY UPDATE”
  37. Cannot delete or update a parent row: a foreign key constraint fails
  38. MySQL server startup error ‘The server quit without updating PID file’
  39. How do I restore a dump file from mysqldump?
  40. Syntax error due to using a reserved word as a table or column name in MySQL
  41. ERROR 1698 (28000): Access denied for user ‘root’@’localhost’
  42. MySQL root password change
  43. Installation of MySQL for Visual Studio 1.2.8 failed
  44. Not unique table/alias
  45. How do I import an SQL file using the command line in MySQL?
  46. PHP Connection failed: SQLSTATE[HY000] [2002] Connection refused
  47. #1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’
  48. MySQL ERROR 1045 (28000): Access denied for user ‘bill’@’localhost’ (using password: YES)
  49. Your password does not satisfy the current policy requirements
  50. How do I quickly rename a MySQL database (change schema name)?
  51. What does SQL Select symbol || mean?
  52. Install mysql-python (Windows)
  53. MySQL: Access denied for user ‘test’@’localhost’ (using password: YES) except root user
  54. PHP Connection failed: SQLSTATE[HY000] [2002] Connection refused
  55. SQL – Update multiple records in one query
  56. Mysql: Setup the format of DATETIME to ‘DD-MM-YYYY HH:MM:SS’ when creating a table
  57. What is the definition of cardinality in SQL
  58. How to restart remote MySQL server running on Ubuntu linux?
  59. Authentication plugin ‘caching_sha2_password’ cannot be loaded
  60. MySQL DROP all tables, ignoring foreign keys
  61. #1055 – Expression of SELECT list is not in GROUP BY clause and contains nonaggregated column this is incompatible with sql_mode=only_full_group_by
  62. When to use SELECT … FOR UPDATE?
  63. Host ‘xxx.xx.xxx.xxx’ is not allowed to connect to this MySQL server
  64. Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
  65. Setting up foreign keys in phpMyAdmin?
  66. Select from multiple tables without a join?
  67. PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP
  68. ERROR 1396 (HY000): Operation CREATE USER failed for ‘jack’@’localhost’
  69. SQL Query Where Field DOES NOT Contain $x
  70. Create a new database with MySQL Workbench
  71. Duplicating a MySQL table, indices, and data
  72. Disable ONLY_FULL_GROUP_BY
  73. what does “/index.php?admin/admin_dashboard” in my url mean
  74. Column ‘user_id’ in field list is ambiguous
  75. How to join two tables by multiple columns in SQL?
  76. How to get size of mysql database?
  77. mysql Foreign key constraint is incorrectly formed error
  78. Database sharding vs partitioning
  79. Selecting data from two different tables without using joins
  80. MySQL WHERE IN ()
  81. Access Denied for User ‘root’@’localhost’ (using password: YES) – No Privileges?
  82. Is there an SQLite equivalent to MySQL’s DESCRIBE [table]?
  83. ERROR 2003 (HY000): Can’t connect to MySQL server on ‘127.0.0.1’ (111)
  84. SQL – Update multiple records in one query
  85. Difference between VARCHAR and TEXT in MySQL
  86. mysql is not recognised as an internal or external command,operable program or batch
  87. 1052: Column ‘id’ in field list is ambiguous
  88. Escape string Python for MySQL
  89. 1052: Column ‘id’ in field list is ambiguous
  90. MySQL Error 1093 – Can’t specify target table for update in FROM clause
  91. MySQL: Invalid use of group function
  92. SELECT list is not in GROUP BY clause and contains nonaggregated column …. incompatible with sql_mode=only_full_group_by
  93. Host ‘xxx.xx.xxx.xxx’ is not allowed to connect to this MySQL server
  94. difference between primary key and unique key
  95. mysqladmin: connect to server at ‘localhost’ failed
  96. mysql update multiple columns with same now()
  97. Mysql command not found in OS X 10.7
  98. SELECT * FROM multiple tables. MySQL
  99. Usage of MySQL’s “IF EXISTS”
  100. MySQL error code: 1175 during UPDATE in MySQL Workbench
Categories MySQL Tags mysql, post-meta, wp-insert-post
wp_specialchars and wp_specialchars_decode in a shortcode plugin
How can a Theme Contain no Header File or Footer File?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress