Yes it’s a good idea to avoid the use of prepared queries if something like wp_update_post can be used instead. The difference is that rather than passing one query per author to update the posts it will pass as many queries as there are posts.
Have you looked at how this will perform with a few thousand posts? Let me know if it performs ok and we can swap it in.
I would recommend turning off caching for the duration of importing, in fact I’d recommend turning off as many other plugins and themese as you can.
All forms of caching should be entirely disabled when doing an import of any sort. In fact, I’d go so far as to say that all other plugins should be disabled when performing an import.
The purpose of an import is to get the content into the system, one time. To do this in a sane and fast manner, a fair amount of the normal publishing process is usually bypassed. Caches are disabled, meta queries aren’t run, things like that.
The thing is that inserting a post is usually a rather expensive operation in WordPress, mainly because it isn’t something you do often. Once or twice an hour, tops. When you’re talking about inserting several thousand posts in a few minutes, all that extra work that happens on post creation needs to be skipped. Since importing is generally a one-time operation, and one that usually happens on a new site (migration from an older site is the most common case for needing an importer), then it’s not usually the case where caching plugins already exist and such.
If there was a solid and safe way to force disable all other plugins and all other caching mechanism during an import, I’d add that to the code. But there isn’t. Too many plugins doing too many odd things. So at the moment, my suggestion would be to add “disable all other plugins and caching during the import” to the instructions instead.
I see that my suggestion to run wp_update_post was a shortsighted, since this can spiral out of control for large sites.
I agree with adding the language as Samuel Wood suggested. This way users can either choose to disable other plugins beforehand, or at least fix the problem by clearing cache afterwards.
Thanks.
I’ve added the following to the readme
= Preparation =
It is strongly recommended that you **disable all other plugins and caching** during the import.
This will ensure that the information transfers across as smoothly as possible and that posts and comments are correctly transferrred.