【正文】
。最后可行的解決辦法是將兩個(gè)查詢 UNION達(dá)到解決問(wèn)題實(shí)例 續(xù) 8先按照計(jì)劃表上有存貨的進(jìn)行查詢select /*+ rule */ , …..from ( SELECT , , FROM po_plan_h, po_plan_b where = and = 0 and = 0 and = 39。%39。 CREATE INDEX IDX_PO_PLAN_B_1 ON PO_PLAN_B(CPLANHID) 。 實(shí)例 續(xù) 5發(fā)現(xiàn)計(jì)劃表上相應(yīng)日期列沒有索引。 and is not null ) or is null ) and = and = group by 。查詢執(zhí)行數(shù)據(jù) SQL如下: select , sum ( ), sum……from ( SELECT , , , , , , , FROM po_plan_h, po_plan_b, bd_invcl aa where = and = 0 and = 0 and ( + ) = and = 39。Select .. From 主表 where 主表?xiàng)l件 and 主表關(guān)聯(lián)字段 in ( Select子表 PK from 子表 where 子表?xiàng)l件 )Step9:NOT IN盡量不要使用 NOT INNOT IN都可以改造成 NOT EXISTSNOT IN中子查詢?nèi)绻麑?duì)某個(gè)記錄返回空,整個(gè)結(jié)果集都會(huì)為空Step10:視圖視圖?不要存在視圖套視圖情況?視圖中不要使用 Distinct?視圖中希望作為條件的關(guān)聯(lián)列和結(jié)果列,不要進(jìn)行運(yùn)算。) and in (select pk_invmandoc from bd_invmandoc where =39。Select .. From 主表 where 主表?xiàng)l件 and exists (Select * from 子表 where 子表?xiàng)l件 and 主表關(guān)聯(lián)字段=子表 PK)Step8:IN?查詢基本格式例: select count(*) from prm_adjustprice main,prm_adjustprice_b detail where = and in (39。) and exists (select * from bd_invmandoc where =39。Step7:EXIST?查詢基本格式例: select count(*) from prm_adjustprice main,prm_adjustprice_b detail where = and in (39。Select .. From so_order,so_order_b,.. where = and ccustomerid=:1 and …….. 最后發(fā)現(xiàn)情況是這樣的:企業(yè)是做批發(fā)業(yè)務(wù)的,政策法規(guī)上不允許直接銷售給個(gè)人,內(nèi)部職工需要購(gòu)買時(shí)都是按照統(tǒng)一個(gè)特定的客戶開票,因此數(shù)據(jù)庫(kù)中數(shù)據(jù)嚴(yán)重不均,此客戶的訂單數(shù)量大于總數(shù)的 10%。整型數(shù)據(jù)列 +0字符型加 trim函數(shù)例如:在進(jìn)行調(diào)撥的時(shí)候需要判斷這個(gè)倉(cāng)庫(kù)中此存貨不存在沒有記帳的出庫(kù)單 Select count(*) from XXX where pk_inv=:1 and status=0 這個(gè)查詢會(huì)用到存貨索引,但是速度還是慢。?建議建索引的列。Step3:不該建的索引錯(cuò)誤索引:?對(duì)于只有少數(shù)一個(gè)可能值的列,不應(yīng)該建索引。條件中包含:訂單日期等于某天和存貨編碼等于某個(gè)值。Hash_Area_Size RAM驅(qū)動(dòng)表大表散列訪問(wèn) ROWIDRAM溢出使用臨時(shí)表空間表連接操作 33,排序合并連接 MERGE JOIN兩個(gè)表都使用全表掃描,分別進(jìn)行排序,然后再合并成查詢的結(jié)果集。查詢返回大