Subject Re: [firebird-support] Check if record exist
Author Ann W. Harrison
Greg Strauss wrote:
>
> Would doing:
> select 1 from Person where PersId=:PersId

If you have more than one qualifying person, that query will not be a
singleton select.
>
> select 1 from rdb$database
> where exists (select 1 from Person where PersId=:PersId)
>

Because there is only one rdb$database record, that is a singleton
select and stops after the first qualifying record.

Assuming that there's an ascending index on PersId, this singleton
select will also touch only one record and is more generic:

select min (p.PersId) from Person p where p.PersId = :PersId


Regards,


Ann