Subject | RE: [ib-support] query plan |
---|---|
Author | PODESTA Mariano APRE |
Post date | 2003-04-30T11:42:13Z |
this is the complete query plan:
(it seems ibmanager truncates the plan)
select
cu.id_cuenta
from cuenta cu
join notificacion nt on nt.id_cuenta = cu.id_cuenta
join noti_recipiente nr on nr.id_notificacion = nt.id_notificacion
join recipiente re on re.id_recipiente = nr.id_recipiente
join noti_servicio ns on ns.id_noti_servicio = re.id_noti_servicio
left join noti_reglas ng on ng.id_noti_reglas = nt.id_noti_reglas and
ng.activo = 1
where
cu.id_cuenta = 696 and
nt.id_evento = 123
PLAN JOIN (JOIN (NS NATURAL,RE INDEX (RDB$FOREIGN56),NR INDEX
(RDB$FOREIGN57),NT INDEX (RDB$PRIMARY48,RDB$FOREIGN50),CU INDEX
(RDB$PRIMARY1)),NG INDEX (PK_NOTI_REGLAS))
every table has an index or a pk on fields "id_".
but, i think helen was right.
(it seems ibmanager truncates the plan)
select
cu.id_cuenta
from cuenta cu
join notificacion nt on nt.id_cuenta = cu.id_cuenta
join noti_recipiente nr on nr.id_notificacion = nt.id_notificacion
join recipiente re on re.id_recipiente = nr.id_recipiente
join noti_servicio ns on ns.id_noti_servicio = re.id_noti_servicio
left join noti_reglas ng on ng.id_noti_reglas = nt.id_noti_reglas and
ng.activo = 1
where
cu.id_cuenta = 696 and
nt.id_evento = 123
PLAN JOIN (JOIN (NS NATURAL,RE INDEX (RDB$FOREIGN56),NR INDEX
(RDB$FOREIGN57),NT INDEX (RDB$PRIMARY48,RDB$FOREIGN50),CU INDEX
(RDB$PRIMARY1)),NG INDEX (PK_NOTI_REGLAS))
every table has an index or a pk on fields "id_".
but, i think helen was right.
> If the FK index has low selectivity, or notificacion
> table has not many rows, the optimizer may calculate that a scan will be
> faster than using the index.
>
> Pavel, I think you're wrong this time. The left outer join relates to
> noti_reglas (ng), which correctly uses an index. The
> where-clause, however,
> limits the left side of the left join (with all the other
> tables) and for
> some reason Firebird thinks its best bet is to use natural on
> the noti_servicio (ns) table. Though the plan doesn't quite
> make sense.
> It doesn't mention the cuenta (cu) or notificacion (nt) tables, which
> should contain vital information as to why Firebird chose the
> plan it did.
>
> So Mariano, please tell us the full plan including the CU and
> NT tables. It
> would also be good to know some statistics about these two
> tables as well
> as the NS table.
>
> >See you at the First European Firebird Conference in May in Fulda,
> >Germany
> >http://www.firebird-conference.com
>
> Sure, I'll be there Pavel!
>
> HTH,
> Set
>
>
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~-->
> Get 128 Bit SSL Encryption!
> http://us.click.yahoo.com/xaxhjB/hdqFAA/bW3JAA/67folB/TM
> --------------------------------------------------------------
> -------~->
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>