数据库的优化手段

1.sql语句优化

(where条件位置的优化)

  eg.     select * from student where sex ='男' and department ='中文系';

       替换为

      select * from student where department = '中文系' and sex ='男';

    (哪个where条件能筛选出更少的数据,将哪个条件放在前面)

 

( colx not in (select colx from table where ...) )(not exits)

 //主表数据量大,从表数据量小,适合用 in 或者 not in;反之主表数据量小,从表数据量大,适合用  exist 或 not exist

(*号影响性能,替换为字段1,字段2.。。。。)

2.库设计优化

(分库分表/分布式...)

(合理设置索引)

(合理设置冗余字段)

(硬件优化/服务器固态硬盘)

 

posted @ 2017-07-19 10:33  日常写bug  阅读(169)  评论(0编辑  收藏  举报