1. 程式人生 > >MySQL調優學習

MySQL調優學習

兩點:避免全表掃描和新增索引

1.如何避免全表掃描

    a.避免使用select * from ~

    b.避免在where語句中出現null,可以將null替換為0

        select ~ from ~ where ~=null;

        select ~ from ~ where ~=0;

    c.避免在where語句中出現模糊查詢和!=

        select ~ from ~ where ~like '%a';

        select ~ from ~ where ~ != num;

2.新增索引

    a.在使用order by語句中可以不用排序

    b.在使用where語句時可以查詢索引