Subject | Question about PLANs |
---|---|
Author | José Lacerda |
Post date | 2003-12-05T19:08:14Z |
Hi,
I've the following query witch is running correctly:
SELECT
L.COD_ART,
ART.DESIGN_IDIOM1,
L.COD_ARMAZ,
ARM.NOME AS ARMAZ,
L.LOTE,
L.COD_SUB_ART,
DSA1.NOME AS DIMENS_SUB_ART1,
DSA2.NOME AS DIMENS_SUB_ART2,
DSA3.NOME AS DIMENS_SUB_ART3,
L.COD_ENTID,
E.NOME AS ENTID,
L.COD_CAB,
C.COD_AUX,
P.COD_PROC_CARG,
(L.NUM_VOLUM_ENT - L.NUM_VOLUM_SAI - L.NUM_VOLUM_DEVOL -
L.NUM_VOLUM_TRANSF) AS NUM_VOLUM_DISPON
FROM LIN_PROG_EMB_DESEMB L
INNER JOIN CAB_PROG_EMB_DESEMB C ON (L.COD_CAB = C.COD_CAB)
INNER JOIN ART ART ON (L.COD_ART = ART.COD_ART)
INNER JOIN ENTID E ON (L.COD_ENTID = E.COD_ENTID)
INNER JOIN PROC P ON (C.COD_PROC = P.COD_PROC)
INNER JOIN ARMAZ ARM ON (L.COD_ARMAZ = ARM.COD_ARMAZ)
LEFT JOIN SUB_ART SA ON (SA.COD_SUB_ART = L.COD_SUB_ART)
LEFT JOIN DIMENS_SUB_ART DSA1 ON (SA.COD_DIMENS_SUB_ART1 =
DSA1.COD_DIMENS_SUB_ART)
LEFT JOIN DIMENS_SUB_ART DSA2 ON (SA.COD_DIMENS_SUB_ART2 =
DSA2.COD_DIMENS_SUB_ART)
LEFT JOIN DIMENS_SUB_ART DSA3 ON (SA.COD_DIMENS_SUB_ART3 =
DSA3.COD_DIMENS_SUB_ART)
WHERE L.COD_ART ='1'
The selected PLAN is:
PLAN JOIN (JOIN (JOIN (JOIN (JOIN (ARM NATURAL,L INDEX
(RDB$FOREIGN185,RDB$FOREIGN186),E INDEX (RDB$PRIMARY53),C INDEX
(RDB$PRIMARY180),P INDEX (RDB$PRIMARY101),ART INDEX
(RDB$PRIMARY91)),SA INDEX (RDB$PRIMARY96)),DSA1 INDEX
(RDB$PRIMARY94)),DSA2 INDEX (RDB$PRIMARY94)),DSA3 INDEX
(RDB$PRIMARY94))
The table ARMAZ is indexed on the field COD_ARMAZ (Primary Key), but
this index isn't used.
If I change the INNER JOIN to LEFT JOIN for the table ARMAZ, then the
index is used.
At the moment, the table ARMAZ has only 5 records and, in the future,
it should have about 10/15.
IMHO, this question will not have a large impact in the speed but I
would appreciate it if someone could help me to understand this
question.
I'm using FB 1.0.3.972 with Win XP Pro-Portuguese
Thanks in advance.
With regards,
José Lacerda
UTILsoft, Lda
Portugal
I've the following query witch is running correctly:
SELECT
L.COD_ART,
ART.DESIGN_IDIOM1,
L.COD_ARMAZ,
ARM.NOME AS ARMAZ,
L.LOTE,
L.COD_SUB_ART,
DSA1.NOME AS DIMENS_SUB_ART1,
DSA2.NOME AS DIMENS_SUB_ART2,
DSA3.NOME AS DIMENS_SUB_ART3,
L.COD_ENTID,
E.NOME AS ENTID,
L.COD_CAB,
C.COD_AUX,
P.COD_PROC_CARG,
(L.NUM_VOLUM_ENT - L.NUM_VOLUM_SAI - L.NUM_VOLUM_DEVOL -
L.NUM_VOLUM_TRANSF) AS NUM_VOLUM_DISPON
FROM LIN_PROG_EMB_DESEMB L
INNER JOIN CAB_PROG_EMB_DESEMB C ON (L.COD_CAB = C.COD_CAB)
INNER JOIN ART ART ON (L.COD_ART = ART.COD_ART)
INNER JOIN ENTID E ON (L.COD_ENTID = E.COD_ENTID)
INNER JOIN PROC P ON (C.COD_PROC = P.COD_PROC)
INNER JOIN ARMAZ ARM ON (L.COD_ARMAZ = ARM.COD_ARMAZ)
LEFT JOIN SUB_ART SA ON (SA.COD_SUB_ART = L.COD_SUB_ART)
LEFT JOIN DIMENS_SUB_ART DSA1 ON (SA.COD_DIMENS_SUB_ART1 =
DSA1.COD_DIMENS_SUB_ART)
LEFT JOIN DIMENS_SUB_ART DSA2 ON (SA.COD_DIMENS_SUB_ART2 =
DSA2.COD_DIMENS_SUB_ART)
LEFT JOIN DIMENS_SUB_ART DSA3 ON (SA.COD_DIMENS_SUB_ART3 =
DSA3.COD_DIMENS_SUB_ART)
WHERE L.COD_ART ='1'
The selected PLAN is:
PLAN JOIN (JOIN (JOIN (JOIN (JOIN (ARM NATURAL,L INDEX
(RDB$FOREIGN185,RDB$FOREIGN186),E INDEX (RDB$PRIMARY53),C INDEX
(RDB$PRIMARY180),P INDEX (RDB$PRIMARY101),ART INDEX
(RDB$PRIMARY91)),SA INDEX (RDB$PRIMARY96)),DSA1 INDEX
(RDB$PRIMARY94)),DSA2 INDEX (RDB$PRIMARY94)),DSA3 INDEX
(RDB$PRIMARY94))
The table ARMAZ is indexed on the field COD_ARMAZ (Primary Key), but
this index isn't used.
If I change the INNER JOIN to LEFT JOIN for the table ARMAZ, then the
index is used.
At the moment, the table ARMAZ has only 5 records and, in the future,
it should have about 10/15.
IMHO, this question will not have a large impact in the speed but I
would appreciate it if someone could help me to understand this
question.
I'm using FB 1.0.3.972 with Win XP Pro-Portuguese
Thanks in advance.
With regards,
José Lacerda
UTILsoft, Lda
Portugal