Subject Re: Exists versus select first
Author csswa
> >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

Ah yes, I hadn't figured on views... I think I'll stick to using
dbkeys the accepted ways.

> 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.

Very neat! I'm going to use a 'Y', though, as a kind of boolean
reminder. Plus it knocks another byte off, doesn't it? -- returns
one-byte char instead of two-byte smallint? Either way, an
improvement on dbkey's eight bytes. Thanks, Ann.

Andrew Ferguson