Subject | default plan no good for many joins? |
---|---|
Author | Michael Fung |
Post date | 2003-07-17T03:04:30Z |
Dear all,
Is the following query considered poor if executed with the server
default plan:
SELECT I.ID
, P.PN
, B.NAME
, O.PO_NO
, S.SUPP_NO
, I.QTY
, I.OUTS_QTY
, U.NAME
, E.EMP_NO
FROM PO_ITEM I
LEFT OUTER JOIN PO O ON O.ID = I.PO_ID
LEFT OUTER JOIN PRODUCT P ON P.ID = I.PRODUCT_ID
LEFT OUTER JOIN BRAND B ON B.ID = P.BRAND_ID
LEFT OUTER JOIN UNIT U ON U.ID = P.UNIT_ID
LEFT OUTER JOIN SUPPLIER S ON S.ID = O.SUPPLIER_ID
LEFT OUTER JOIN EMPLOYEE E ON E.ID = O.EMPLOYEE_ID
WHERE
OUTS_QTY > 0
Server default plan is:
PLAN JOIN (JOIN (JOIN (JOIN (JOIN (JOIN (I NATURAL,O INDEX
(RDB$PRIMARY26)),P INDEX (RDB$PRIMARY30)),B INDEX (RDB$PRIMARY3)),U
INDEX (RDB$PRIMARY37)),S INDEX (RDB$PRIMARY36)),E INDEX
(RDB$PRIMARY17))
Do I need to specify a custom plan every time for such kind of query?
TIA
- Michael
Is the following query considered poor if executed with the server
default plan:
SELECT I.ID
, P.PN
, B.NAME
, O.PO_NO
, S.SUPP_NO
, I.QTY
, I.OUTS_QTY
, U.NAME
, E.EMP_NO
FROM PO_ITEM I
LEFT OUTER JOIN PO O ON O.ID = I.PO_ID
LEFT OUTER JOIN PRODUCT P ON P.ID = I.PRODUCT_ID
LEFT OUTER JOIN BRAND B ON B.ID = P.BRAND_ID
LEFT OUTER JOIN UNIT U ON U.ID = P.UNIT_ID
LEFT OUTER JOIN SUPPLIER S ON S.ID = O.SUPPLIER_ID
LEFT OUTER JOIN EMPLOYEE E ON E.ID = O.EMPLOYEE_ID
WHERE
OUTS_QTY > 0
Server default plan is:
PLAN JOIN (JOIN (JOIN (JOIN (JOIN (JOIN (I NATURAL,O INDEX
(RDB$PRIMARY26)),P INDEX (RDB$PRIMARY30)),B INDEX (RDB$PRIMARY3)),U
INDEX (RDB$PRIMARY37)),S INDEX (RDB$PRIMARY36)),E INDEX
(RDB$PRIMARY17))
Do I need to specify a custom plan every time for such kind of query?
TIA
- Michael