Lukas Eder does a performance test:
But what if you want to check if there are at least
2
(orN
) rows? In that case, you cannot useEXISTS
, but have to revert to usingCOUNT(*)
. However, instead of just counting all matches, why not add aLIMIT
clause as well? So, if you want to check if actors called WAHLBERG have played in at least 2 films, instead of this:
Lukas compares performance between two query options in Postgres, Oracle, SQL Server, and MySQL. Because Oracle has weird behavior in the test, Lukas shares a third option that works well for it.