Subject | Re: [ib-support] First Keyword (Performance question, not related to why is it there) |
---|---|
Author | Svein Erling Tysvær |
Post date | 2002-07-15T07:47:54Z |
Hi Jason!
length worries you - you could just do
select first 1 1 from people where lname = 'Smith'
a common name ;=)
Another option you do not mention at all, is to use exists. I think it can
be used directly within stored procedures and if you work with client
applications you can do something like
SELECT 1 FROM RDB$DATABASE
WHERE EXISTS(select 1 from people where lname = 'Smith')
But I think your first option (select first 1) should execute equally quick.
Set
>select first 1 lname from people where lname = 'Smith'; // Only grabs theThis should be OK and you don't have to select a column if the potential
>first, but has to return a string. Result string has the potential to be
>large, depending on column definition
length worries you - you could just do
select first 1 1 from people where lname = 'Smith'
>select count(*) from people where lname = 'Smith'; // Has to countThis could be considerably slower, especially if Smith should happen to be
>everything, but it returns a single integer. My thought is that the index
>might have this number already.
a common name ;=)
Another option you do not mention at all, is to use exists. I think it can
be used directly within stored procedures and if you work with client
applications you can do something like
SELECT 1 FROM RDB$DATABASE
WHERE EXISTS(select 1 from people where lname = 'Smith')
But I think your first option (select first 1) should execute equally quick.
Set