Subject Using FIRST in IF EXISTS(SELECT...)
Author csswa
Say I have a table of a million unindexed records. The first record
and the last record are the only fields that match my select criteria
in the code below:

if (exists (select 1 from bigtable where criteria))
then <reselect and process> ...

Will the EXISTS test be satisfied as soon as the first row matches,
or will it only be satisfied after the server has walked through the
whole table to get the selected subset?

I'm just wondering if there is any advantage in always using FIRST
when testing for existence. With this:

if (exists (select first 1 1 from bigtable where criteria))
then <reselect and process> ...

would it still walk the entire table or quit after fetching the first
row?

Thanks,
Andrew Ferguson