Subject | slow join query |
---|---|
Author | flashjobs |
Post date | 2006-09-09T09:57:42Z |
Hello all
I have a problem that the query is very slow. Can anybody help?
Thanks
Shinelal
SELECT PRODUCTCODE
, PRODUCTNAME
, PRODUCTCOSTLOCALCURRENCY
, PRODUCTCOSTORGCURRENCY
, PRODUCTISBN
, PRODUCTBARCODE
, PRODUCTSTOCKUPDATE
, CURRENCYNAME
, P.CURRENCYCODE
, TAXDESCRIPTION
, TAXPERCENTAGE
, PRODUCTPUBLISHINGYEAR
, SUPPLIERNAME
, CURRENCYCONVERTRATE
, CURRENCYLOCALASREF
FROM (((PRODUCTMASTER P
LEFT OUTER JOIN CURRENCYMASTER C ON C.CURRENCYCODE = P.CURRENCYCODE)
LEFT OUTER JOIN TAXMASTER T ON T.TAXCODE = P.TAXCODE)
LEFT OUTER JOIN SUPPLIERMASTER S ON S.SUPPLIERCODE=P.PUBLISHERCODE)
WHERE PRODUCTSTOCKUPDATE = 'Y' AND
((PRODUCTCODE IN (SELECT PRODUCTCODE FROM STOCKMASTER WHERE
OUTLETCODE=?OUTLET
AND BRANCHCODE=?BRANCH )or 2=0) OR
PRODUCTCODE NOT IN(SELECT PRODUCTCODE FROM STOCKMASTER))
I have a problem that the query is very slow. Can anybody help?
Thanks
Shinelal
SELECT PRODUCTCODE
, PRODUCTNAME
, PRODUCTCOSTLOCALCURRENCY
, PRODUCTCOSTORGCURRENCY
, PRODUCTISBN
, PRODUCTBARCODE
, PRODUCTSTOCKUPDATE
, CURRENCYNAME
, P.CURRENCYCODE
, TAXDESCRIPTION
, TAXPERCENTAGE
, PRODUCTPUBLISHINGYEAR
, SUPPLIERNAME
, CURRENCYCONVERTRATE
, CURRENCYLOCALASREF
FROM (((PRODUCTMASTER P
LEFT OUTER JOIN CURRENCYMASTER C ON C.CURRENCYCODE = P.CURRENCYCODE)
LEFT OUTER JOIN TAXMASTER T ON T.TAXCODE = P.TAXCODE)
LEFT OUTER JOIN SUPPLIERMASTER S ON S.SUPPLIERCODE=P.PUBLISHERCODE)
WHERE PRODUCTSTOCKUPDATE = 'Y' AND
((PRODUCTCODE IN (SELECT PRODUCTCODE FROM STOCKMASTER WHERE
OUTLETCODE=?OUTLET
AND BRANCHCODE=?BRANCH )or 2=0) OR
PRODUCTCODE NOT IN(SELECT PRODUCTCODE FROM STOCKMASTER))