Which database are you talking about? Which database? When it comes to performance, it is difficult to make definitive assertions. You can change according to the implementation, then SQL Server can give one thing and Postgresql can give another. It can change from one version to another, it can change according to the configuration of that bank or the whole system. May vary according to stored data. Performance depends on implementation detail.
If the database optimizer thinks it should be exactly the same.
Note that the syntax there is very simple. In darlings more complex (JOIN
) may not even give the expected result when using COUNT(1)
. Otherwise the fact of having a constant in place of all fields will not differ because the count will be done on all lines that pass through the filter.
Has a excellent response on this in the OS.
Some say that
count(1)
may be faster on sql server, but I’ve never actually seen it myself. I just know that by putting*
or any constant is faster than referencing column– Jefferson Quesado
In recent versions of Oracle "dá igual", https://asktom.oracle.com/pls/apex/f?p=100:11:1337911574066::NO::P11_QUESTION_ID:1156159920245
– Motta
You’ll find in some places it’s the same thing, but I like it of that explanation.
– Sidon
For what explains here not the difference. The same goes for
exists
– Marconi
In the latest and most common DBMS engines, there is no difference.
– Renato Afonso