如何優化這條sql語句呢

2021-08-29 12:45:05 字數 386 閱讀 7134

select * from declarebill where modyfytime like "%2008-02-22%" and enterprisetype='外商投資企業' and single_audit='1' and billmode='02' or enterprisetype='中外合資企業' and modyfytime like "%2008-02-22%" and single_audit='1' and billmode='02'

我想enterprisetype欄位中的'外商投資企業'和'中外合資企業' 都擁有這個條件modyfytime like "%2008-02-22%" and single_audit='1' and billmode='02'

應該如何優化呢?我現在寫的太長啦!

SQL語句如何優化?

核心思想 多快好省 多 查詢的不漏是基本的正確準確需要 快 減少不必要的查詢,如全表掃瞄和空值查詢 好 不過度影響查詢效果的情況下,資料可以較好地展示收集 省 減少資源消耗 具體實現舉例 1 查詢語句中不要使用select 2 儘量減少子查詢,使用關聯查詢 left join,right join,...

MySQL的SQL語句如何優化?

1 現場抓出慢查詢語句 show full processlist 2 配置引數 slow query log file on 慢查詢開啟開關 long query time 2 記錄大於2秒的sql語句 log queries not using indexes on 沒有使用索引的sql語句 m...

SQL 語句優化 OR 語句優化案例

從上海來到溫州,看了前幾天監控的sql語句和資料變化,發現有一條語句的io次數很大,達到了150萬次io,而兩個表的資料也就不到20萬,為何有如此多的io次數,下面是執行語句 select ws.nodeid,wi.laststepid,wi.curstepid from workflowinfo ...