One colleague mentioned that when doing EXISTS
in SQL, it is recommended to use DISTINCT 1
to improve performance.
For example, instead of doing:
SELECT *
FROM CLIENTES
WHERE NOT EXISTS (SELECT CODCLI
FROM VENDAS
WHERE VENDAS.CODCLI = CLIENTES.CODCLI)
He suggested doing:
SELECT *
FROM CLIENTES
WHERE NOT EXISTS (SELECT DISTINCT 1
FROM VENDAS
WHERE VENDAS.CODCLI = CLIENTES.CODCLI)
Is there a difference (performance) in the execution of the above SQL?
What would be recommended?
Banks: Oracle and FireBird (ATM).