Oracle 查詢記錄相關(guān)效率的查詢
以下的文章主要是對Oracle 查詢記錄是否真正存在的相關(guān)效率問題的介紹,由于我最近要對Oracle數(shù)據(jù)庫的效率進(jìn)行優(yōu)化,所以在一些信譽(yù)度比較好的網(wǎng)上查詢了很多關(guān)于判斷記錄是否存在的高效率方法。
網(wǎng)上有很多的建議***種方法,我做了一個測試,但是可能數(shù)據(jù)量不夠大,42667條記錄,不知道很大的數(shù)據(jù)量是什么一個情況,網(wǎng)上好多高效的建議方式
- select * from item where item='1B241371X0021' and rownum<2;
但是我測試的結(jié)果:
- select * from item where item='1B241371X0021' and rownum<2;
- 1 rows selected in 0.047 seconds
count(*) 方式
- select count(*) from item where item='1B241371X0021';q
- 1 rows selected in 0.016 seconds
exists方式
- select count(*) from dual where exists(select 1 from item where item='1B241371X0021');
- 1 rows selected in 0.015 seconds
從測試的結(jié)果看,后兩種方式比前一種方式的效率明顯要高.以上的相關(guān)內(nèi)容就是對Oracle 查詢記錄是否存在的效率問題的介紹,望你能有所收獲。
【編輯推薦】