作爲對這兩個問題的跟進和其答案Question 1和Question 2。Oracle查詢性能
使用運算符in
,or
或union
的Oracle在Oracle上的性能如何?我認爲在一張桌子上,行數> 1 mio,每行10-500行,每行的y值不同。
select * from table where y in (1,2,3)
或
select * from table where (y = 1 or y = 2 or y = 3)
或
select * from table where y = 1
union
select * from table where y = 2
union
select * from table where y = 3
如何,如果我添加一個and x = 1
的性能影響?列x也被索引並具有相同的選擇性。
摘要: 沒有最佳實踐或建議使用一個操作員比其他更好。在最好的情況下,所有3個語句的性能指標都相同但可以這樣說,一個聲明比其他聲明更好。
有一些線程在那裏,討論的Oracle SQL語句的性能指標:
- http://forums.oracle.com/forums/thread.jspa?threadID=501834
- http://asktom.oracle.com/tkyte/runstats.html
- How to measure performance of query in oracle
的工具,你必須處理的execution plans and tracing tools以獲得最佳性能。
+1對於UNION ALL提示! – Christian13467 2009-09-09 09:25:14