sql 优化 ·· 持续更新··

来源:互联网 发布:2017 9月编程语言排行 编辑:程序博客网 时间:2024/05/26 19:20

oracle的 ::

http://www.cnblogs.com/wxj1020/archive/2008/04/27/1173638.html



sql server :

The most common thing that will make a query non-sargable is to include a field inside a function in the where clause:

SELECT ... FROM ...WHERE Year(myDate) = 2008

The SQL optimizer can't use an index on myDate, even if one exists. It will literally have to evaluate this function for every row of the table. Much better to use:

WHERE myDate >= '01-01-2008' AND myDate < '01-01-2009'

Some other examples:

Bad: Select ... WHERE isNull(FullName,'') = 'Ed Jones'Fixed: Select ... WHERE ((FullName = 'Ed Jones') OR (FullName IS NULL))Bad: Select ... WHERE SUBSTRING(DealerName,4) = 'Ford'Fixed: Select ... WHERE DealerName Like 'Ford%'Bad: Select ... WHERE DateDiff(mm,OrderDate,GetDate()) >= 30Fixed: Select ... WHERE OrderDate < DateAdd(mm,-30,GetDate())
http://www.legalsoft.com.cn/docs/968.html 


http://www.oschina.net/translate/performance-tuning-essentials-for-sql-server-dba

0 0
原创粉丝点击