【发布时间】:2015-11-19 15:18:21
【问题描述】:
我有一个日志表,它有数百万条记录。我想提高我的 sql 查询速度,但我不知道如何生成最佳索引组或索引组。如何找到 sql 表的最佳索引?
目前我正在使用;
索引:my_test_index
定义: 键入 BTREE
唯一编号
A 列 F 乙 D C
这是我对日志表的所有 sql 查询;
$sql = "select *
from log
where columnA=1 and (columnB=6 or columnB=4 or columnB=7) and columnC= ... order by columnD desc LIMIT 0,100;
$sql = "select *
from log
where columnA=1 and (columnB=6 or columnB=4) and columnE= ... and ((date(columnD))>=... and (date(columnD))<=...) order by columnD desc";
$sql = "select *
from log
where columnA=1 and (columnB=6 or columnB=4 or columnB=7) and columnE= ... order by columnD desc ";
$sql = "select *
from log
where columnA=1 and (columnB=6 or columnB=4) and columnE= ... and ((date(columnD))>=... and (date(columnD))<=...) order by columnD desc";
$sql = "select *
from log
where columnA=1 and (columnB=6 or columnB=4 or columnB=7) and columnF= ... order by columnD desc LIMIT 0,100;
$sql = "select *
from log
where columnA=1 and (columnB=6 or columnB=4 or columnB=7) and columnG= ... order by columnD desc LIMIT 0,100;
【问题讨论】: