Imagine I have these tables:
table_1:
id col_1 col_2
1 val_1 val_10
2 val_2 val_20
table_2:
id col_1 col_2
1 val_3 val_30
3 val_4 val_40
I want to do an union of table_1 and table_2, removing duplicate ids, and selecting the values of table_2 over table_1 when an id is present in both tables.
union_result:
id col_1 col_2
1 val_3 val_30
2 val_2 val_20
3 val_4 val_40
Both tables are massive (billions of records). What is the most efficient way to achieve this?
Thanks!
2