Postgresql UNION takes 10 times as long as running the individual queries
问题 I am trying to get the diff between two nearly identical tables in postgresql. The current query I am running is: SELECT * FROM tableA EXCEPT SELECT * FROM tableB; and SELECT * FROM tableB EXCEPT SELECT * FROM tableA; Each of the above queries takes about 2 minutes to run (Its a large table) I wanted to combine the two queries in hopes to save time, so I tried: SELECT * FROM tableA EXCEPT SELECT * FROM tableB UNION SELECT * FROM tableB EXCEPT SELECT * FROM tableA; And while it works, it takes