Subject | Re: [firebird-support] select in (subquery) |
---|---|
Author | Helen Borrie |
Post date | 2004-11-30T01:17:40Z |
At 09:15 PM 29/11/2004 -0300, you wrote:
this statement to the following (which does allow use of the index for the
existential search):
select p.Apellido, p.Nombre
from Personas p
where EXISTS(
SELECT select 1 from Beneficiarios b
WHERE p.Persona_id = b.Persona_id
and b.Beneficiario_Titular_Id = :Titular_ID
)
using InterBase. If you need more, come back and tell us what database
server you are using.
./hb
>I'm using the following sentence, where the Personas table has more thanYou don't say what database engine you are using. Firebird should optimize
>19000 rows and the subquery returns, more or less, 5 rows.
>
>
>
>select p.Apellido, p.Nombre
>
> from Personas p
>
> where p.Persona_ID in
>
> (select b.Persona_ID
>
> from Beneficiarios b
>
> where b.Beneficiario_Titular_Id = :Titular_ID
>
> )
>
>
>I think the problem is that the engine doesn't know how many rows the
>subquery will return (neither me :-)).
this statement to the following (which does allow use of the index for the
existential search):
select p.Apellido, p.Nombre
from Personas p
where EXISTS(
SELECT select 1 from Beneficiarios b
WHERE p.Persona_id = b.Persona_id
and b.Beneficiario_Titular_Id = :Titular_ID
)
>I'm wondering if there is some way to force the execution plan to use theTry this query and compare it with your original - especially if you are
>index PERSONAS_PK?
using InterBase. If you need more, come back and tell us what database
server you are using.
./hb