Subject | Re: [firebird-support] Re: Is "EXISTS()" cheap? |
---|---|
Author | Sándor Tamás |
Post date | 2005-09-16T14:12:35Z |
I think it returns at once when it finds the first occurance. This is what "exists" means :-)
----- Original Message -----
From: Bambang P
To: Ali Gökçen
Sent: Friday, September 16, 2005 4:25 PM
Subject: Re: [firebird-support] Re: Is "EXISTS()" cheap?
On Friday, September 16, 2005, 7:03:41 PM, Ali Gökçen wrote:
> --- In firebird-support@yahoogroups.com, Bambang P <bpranoto@g...>
> wrote:
>> In this stored procedure statement:
>>
>> if (exists(select 1 from HOLIDAYS where ADate>=DSTART and
> AData<=DEND))
>> then begin
>> .....
>> end
>>
>> Question:
>>
>> Does the select statement step through all records which meet the
> condition
>> or does it return immediately after the first occurance of the
> condition?
> Hi,
> it is not free but cheapest, if there is an index on ADate field.
> ... where ADate between DSTART and DEND ..
> isn't more clear?
Sorry, I was wrong in my example. ADate is a variable while DSTART and
DEND is fields. Indexes on DSTART and DEND are available.
I am rephrasing my example with your suggestion:
if (exists(select 1 from HOLIDAYS where where :ADate between DSTART
and DEND)) then begin
....
The question remains:
Does the select statement step through all records which meet the
condition?
or
Does it return immediately after the first occurance of the
condition?
Thanks anyway.
--
Bambang P.
I want to move to Theory...Everything works in Theory
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Visit http://firebird.sourceforge.net and click the Resources item
on the main (top) menu. Try Knowledgebase and FAQ links !
Also search the knowledgebases at http://www.ibphoenix.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yahoo! Groups Links
[Non-text portions of this message have been removed]