@Jesper, this looks really great! Do you know if this takes care of the secondary indexing for labels, specifically the wbt_item_terms, wbt_term_in_lang, wbt_text, and wbt_text_in_lang tables? I notice that these tables are not mentioned in the code.
The experiment was performed with version 1.34. I have used and extended the code in a real-world project to work with LTS version 1.35. That was quite a bit of work again. I will check if it is possible to understand the new code without the context of the real-world project.
Also one doubt: when you say "if you do this without a transaction", here you mean that if you do it without an explicit transaction / with a transaction per operation?
The greatest speedup is achieved when many thousands of items and statements are added in a single database transaction. The normal importer starts and commits a database transaction for every single item - or maybe even statement.
Best wishes, Jesper