2
A colleague mentioned that by making a 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 to do:
SELECT *
FROM CLIENTES
WHERE NOT EXISTS (SELECT DISTINCT 1
FROM VENDAS
WHERE VENDAS.CODCLI = CLIENTES.CODCLI)
There is difference (performance) in the execution of SQL s above?
Which would be recommended?
Banks: Oracle and Firebird (ATM system).
Sql-Server or Mysql?
– Sveen
In the newer versions of Oracle is indifferent , in any case I use the "select null from" in subselect , in some cases in Oracle a hint is useful
– Motta
@Sveen I edited the question
– Andrey
Depending on the Data volume I think you have an improved SQL performance.
– Edu Mendonça