I have to run a select statement across several tables. I am sure the tables return different records. I am anyway using UNION ALL.
Is it better to use UNION or of U
UNION implement internally two queries.
1.SELECT which will return a dataset
2.DISTINCT.
Anyone who has studied database internals can easily understand that a DISTINCT clause is extremely costly in terms of processing.
If you are pretty sure that the resultant dataset need not have unique rows then we can skip UNION and use UNION ALL instead.
UNION ALL will be same as UNION except that it doesn't fire a DISTINCT internally sparing us costly operations