A union is probably less costly. But as usual with databases, it depends.
Why?
Because what you are doing right now is this:
- Scan table B and insert into A.
- Scan table C and insert into A (where not exists).
- Scan table D and insert into A (where not exists).
With a union you would be doing this:
- Scan table B.
- Scan table C.
- Scan table D.
- Insert unique values to table A.
I.e. your current queries scans table B, C, D and table A twice plus overhead for three separate queries. A union-query would scan table B, C, D, and sort the rows (to get unique values) and then insert them into table A. At a first glance it seems that union would be faster because you are doing two less scans and only one insert (and thus less locking).
What I mean by it depends is:
Indexes: Correctly indexed, seeks might be faster than sorting the data from B, C and D.
Amount of data: If you have little data compared to the hardware you are running the database on then this discussion might be pointless. I.e. there's no point in optimizing parts that are not bottlenecks.