现在的位置: 首页 > 综合 > 正文

sql 优化 ·· 持续更新··

2014年09月05日 ⁄ 综合 ⁄ 共 847字 ⁄ 字号 评论关闭

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()) >= 30
Fixed: 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

抱歉!评论已关闭.