Mysql 我如何进一步优化这个?

Mysql 我如何进一步优化这个?,mysql,sql,Mysql,Sql,我的桌子大约有121246211行。这些记录是简单的页面印象信息 以下是模式: 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 time

我的桌子大约有121246211行。这些记录是简单的页面印象信息

以下是模式:

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;

我认为我索引了正确的东西;这张桌子是不是太大了?是否有人对如何更快地从此表中获取信息提出了建议?

以下索引将提高该查询的性能:

create index ix1 on stat_page (pageId, timestamp);

此查询受益于此“复合”索引。

@DStanley我认为切换列的顺序将改进其他查询,但不会改进此查询。此查询在
pageId
列中有一个相等(
=
),将此列放在第一位将大大有利于此查询。非常好,谢谢,我不知道为什么我没有想到这一点。干杯