Actually, it does make a difference.
When you have separate INSERT
s, you have to take care to do it inside a transaction, so that you have a consistent state at all times. But, since they're separate, the amount of memory required for the server to complete is less because every INSERT
has it's own result set - when the query completes the server is free to perform another query etc...
When you have everything inside one big query joined by UNION ALL
the server would need more temp tables and more memory to complete. But, this way you have something of a 'bulk' insert, and could result in faster insert.
Personally, I'd go with separate inserts inside a transaction. Sometimes just by having something done simpler is way more beneficial in terms of maintainability and debugging than some minor performance gain (if any, depends on the number of rows actually getting inserted)