> Whether Firebird takes advantage of this fact
That was my hope, but I don't think that's happening.

-----Original Message-----
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Tomasz Tyrakowski
Sent: Tuesday, April 03, 2012 3:31 AM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] Not Exists cost

>> SELECT *
>> FROM A_TABLE at
>> WHERE
>> at.VALUE1 = 'Y' AND
>> NOT EXISTS (
>>    SELECT 1
>>    FROM B_TABLE bt
>>    WHERE bt.VALUE2 = 'X');
>
> The query PLAN would tell you for certain, but I would expect the
answer to be:
>       half of A_TABLE rows times all of B_TABLE rows.

If there's an index on B_TABLE.VALUE2, it would be at most half of
A_TABLE rows times log(B_TABLE rows). Besides, your sub-query doesn't
use values from A_TABLE, so in fact it would be enough to evaluate it
once (it yields the same results for all records of A_TABLE). Whether
Firebird takes advantage of this fact or not is unfortunately beyond my
league and someone with more thorough knowledge about Firebird internals
would have to cast some light on this matter.

regards
Tomasz


Disclaimer: This message (including attachments) is confidential and may be 
privileged. If you have received it by mistake please notify the sender by 
return e-mail and delete this message from your system. Any unauthorized use or 
dissemination of this message in whole or in part is strictly prohibited. 
Please note that e-mails are susceptible to change. RxStrategies, Inc. shall 
not be liable for the improper or incomplete transmission of the information 
contained in this communication or for any delay in its receipt or damage to 
your system. RxStrategies, Inc. does not guarantee that the integrity of this 
communication has been maintained nor that this communication is free from 
viruses, interceptions or interference. 


Reply via email to