2013-11-04 91 views
0

這此查詢使用索引查詢我怎麼能在提高性能

SELECT cs_checkroll_txn_id,ad_division_id,ad_fld_info_id,transaction_date,mandays,man_day_type,ot_hours,ot_type,norm, qty, over_qty, lent_devision,lent_field_no,block_no, latex_ltr, drc,latex_kg,scarp, condition, noofbushes, wt_bunch,harvest_round,w.work_code work_code,w.work_category work_category,w.unit_of_measure unit_of_measure,w.isnorm,r.type,r.rate_code rate_code,reguler_norm, regular_over,reguler_extra, sunday_norm, sunday_over,sunday_extra, holiday_norm, holiday_over,holiday_extra, special_day_norm,special_day_extra, unit, special_day_over 
FROM adempiere.cs_checkroll_txn t,adempiere.cs_work_code w,adempiere.ad_checkroll_rates r 
WHERE t.cs_work_code_id = w.cs_work_code_id 
    AND w.ad_checkroll_rates_id = r.ad_checkroll_rates_id 
    AND iscontract <> 'Y' 
    AND t.isactive = 'Y' 
    AND w.isactive = 'Y' 
    AND r.isactive = 'Y' 
    AND t.cs_worker_cont_id = 1005312 
    AND t.ad_client_id = 1000002 
    AND t.ad_org_id = 1000042 
    AND t.transaction_date between to_date('20130401','yyyymmdd') 
    AND to_date('20130930','yyyymmdd') 

回答

0

的一般規則是爲所有人,你將不得不頻繁地執行搜索或排序的列上創建索引。在你的情況下,這是:

t.cs_work_code_id 
w.cs_work_code_id 
w.ad_checkroll_rates_id 
r.ad_checkroll_rates_id 
iscontract 
t.isactive 
w.isactive 
r.isactive 
t.cs_worker_cont_id 
t.ad_client_id 
t.ad_org_id 
t.transaction_date 
0

我會propably建立索引與場ad_org_id,AD_CLIENT_ID,cs_worker_cont_id。假設它們的熵是有序的。