黑马程序员技术交流社区

标题: 在千万级的数据库查询中,如何提高效率之SQL 语句方面 [打印本页]

作者: 小白进阶之路    时间: 2018-4-18 13:28
标题: 在千万级的数据库查询中,如何提高效率之SQL 语句方面
f. 应尽量避免在 where 子句中对字段进行表达式操作,这将导致引擎放弃使用索引而进行全表扫描。如:
select id from t where num/2=100 应改为: select id from t where num=100*2
g. 应尽量避免在where子句中对字段进行函数操作,这将导致引擎放弃使用索引而进行全表扫描。如: select
id from t where substring(name,1,3)= ‘ abc’ – name 以 abc 开头 的 id select id from t where
datediff(day,createdate,’2005-11-30′)=0–‘2005-11-30’生成的 id 应改为: select id from t where name
like ‘abc%’ select id from t where createdate>=’2005-11-30′ and createdate<’2005-12-1′
作者: 小白进阶之路    时间: 2018-4-19 10:09
占座00000000000000
作者: 小白进阶之路    时间: 2019-5-5 09:55
11111111111111111111111111
作者: 小白进阶之路    时间: 2019-5-7 11:32
222222222222222222




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2