【发布时间】:2019-01-02 22:09:43
【问题描述】:
我的桌子大约有。 121,246,211 行。记录是简单的页面展示信息。
这是架构:
create table stat_page
(
id int auto_increment primary key,
pageId int not null,
timestamp int not null
)
collate = utf8_unicode_ci;
create index pageIdIndex
on stat_page (pageId);
create index timestampIndex
on stat_page (timestamp);
此查询需要 15 秒:
select count(*)
from stat_page
where `timestamp` > 1543622400;
此查询耗时近 7 分钟:
select count(*)
from stat_page
where `timestamp` > 1543622400
and pageId = 87;
我认为我索引了正确的东西;桌子太大了吗?有没有人建议如何更快地从此表中获取信息?
【问题讨论】: