使用主键中断MySQL行检查
考虑:使用主键中断MySQL行检查,mysql,sql,database,Mysql,Sql,Database,考虑: id int(primary key , unique) status enum('enable','disable') round tinyint(1) (index) core tinyint(1) (index) timestamp int(10) (index) 我在一个大约有1800000行的表中得到了一个查询。有这样一个查询: SELECT * FROM tblmatch WHERE status = 'disable' and round
id int(primary key , unique)
status enum('enable','disable')
round tinyint(1) (index)
core tinyint(1) (index)
timestamp int(10) (index)
我在一个大约有1800000行的表中得到了一个查询。有这样一个查询:
SELECT *
FROM tblmatch
WHERE status = 'disable'
and round=0
AND core = 3
AND time_stamp < UNIX_TIMESTAMP()
ORDER BY time_stamp ASC
LIMIT 0,10
然而,row考试是一样的。有没有办法打破排考?你说的“*排考”到底是什么意思?这在“数据库世界”中不是一个常用术语。id是否从1开始?我没有看到任何自动增量。发布一些示例数据。实际上它记录在我的慢速查询日志中,需要6-10秒。那排考试也在那里!PEACE,你能详细说明什么是“行检查”吗?完整的
SHOW CREATE TABLE
&EXPLAIN
输出比你总结它更有用。你能分享一下吗?另外,显示tablename中的索引
可能有助于提高索引的基数。另一方面:如果有1.8M行,然后假设id大于1.6M,则只选择其顶部,则可能不正确。这取决于活动的id
是什么。
SELECT *
FROM tblmatch
WHERE id > 1600000
AND status = 'disable'
and round=0
AND time_stamp < UNIX_TIMESTAMP()
ORDER BY time_stamp ASC
LIMIT 0,10