Subject Re: [ib-support] Re: Exists versus select first
Author Ann W. Harrison
At 03:57 PM 3/21/2002 +0000, csswa wrote:

>AFAIK, 'if exists' is the most streamlined way to check on a record
>configuration in a table.


>What I'd like to know: is it any quicker to use rdb$db_key as the
>SELECTed field instead of * or another individual field ?? Claudio
>has shown how rdb$db_key can be used to speed certain operations...
>just wondering if it works in this minor case too.

I don't think it would make any difference and might cause problems
if you were checking on a view. Tables have eight byte dbkeys.
Views have eight bytes per input stream. Anyway, a stylistic thing
that I tend to do with sub-selects that are intended to determine
the existence of something is this:

if exists (select 1 from <table> where <whatever>)

The select 1 reminds me that I'm not doing useful work.




Regards,

Ann
www.ibphoenix.com
We have answers.