当前位置:网站首页>What does SQL replace or

What does SQL replace or

2022-06-12 19:50:00 WD Technology

(1) use UNION Replace OR ( For index columns )
Usually , use UNION Replace WHERE In Clause OR Will play a better effect . Use for non indexed columns OR Will cause a full table scan . pay attention to , The above rules are only valid for multiple index columns . If there is column
Not indexed , Query efficiency may be because you don't have a choice OR And lower . In the following example , LOC_ID and REGION There's an index on it .
Efficient :
SELECT LOC_ID , LOC_DESC, REGION FROM LOCATION WHERE LOC_ID = 10 UNION SELECT LOC_ID , LOC_DESC ,REGION FROM LOCATION WHERE REGION = “MELBOURNE”
Inefficient :
SELECT LOC_ID , LOC_DESC, REGION FROM LOCATION WHERE LOC_ID = 10 OR REGION = “MELBOURNE”
If you insist on using OR, Then you need to return the index column with the least number of records, which is written at the top .

(2) use IN To replace OR

原网站

版权声明
本文为[WD Technology]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202281534381780.html