Subject Re: [firebird-support] Re: The First to select
Author Alexandre Benson Smith
Woody wrote:
> From: "Ann W. Harrison" <aharrison@...>
>
>> A slightly more conventional version would be
>>
>> select 1
>> from rdb$database
>> where exists (select 1
>> from <table>
>> where <field> is NULL)
>>
>>
>> Either is exactly a full table scan if the field is never null, but
>> less than that if the field can be null.
>>
>
> Ann,
>
> In what way is
>
> select 1
> from rdb$database
> where exists (select 1
> from <table>
> where <field> is NULL)
>
> any better than just
>
> select 1 from <table> where <field> is NULL
>
> ?
>
> Does selecting 1 from rdb$database cause the fb engine to shortcut the
> select as soon as it finds 1 record or does the scan happen in the same way
> for both?
>
> Woody (TMW)
>
>
>
Woody,

No, the EXISTS stop the query as soon it finds one that match the search
criteria.

see you !

--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br