某梦的系统,数据23.8万,调用最新文章:
SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,
tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
FROM `dede_archives` arc LEFT JOIN `dede_arctype` tp on arc.typeid=tp.id
WHERE arc.typeid IN (6) And arc.arcrank > -1 ORDER BY arc.sortrank desc LIMIT 0,10;
去掉order by 执行很快,加上5~7秒之间。
表索引:
操作 键名 类型 唯一 Packed 字段 基数 整理 Null Comment
编辑 删除 PRIMARY BTREE 是 否 id 238281 A
编辑 删除 channel BTREE 否 否 channel 1 A
编辑 删除 ismake BTREE 否 否 ismake 3 A
编辑 删除 sortrank BTREE 否 否 sortrank 238281 A
编辑 删除 typeid BTREE 否 否 typeid 105 A
EXPLAIN结果:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE arc index typeid sortrank 4 NULL 215 Using where
1 SIMPLE tp const PRIMARY PRIMARY 2 const 1
尝试组合索引:typeid、arcrank、sortrank,执行时间没变化。尝试不同组合索引无果。
SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,
tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
FROM `dede_archives` arc LEFT JOIN `dede_arctype` tp on arc.typeid=tp.id
WHERE arc.typeid IN (6) And arc.arcrank > -1 ORDER BY arc.sortrank desc LIMIT 0,10;
去掉order by 执行很快,加上5~7秒之间。
表索引:
操作 键名 类型 唯一 Packed 字段 基数 整理 Null Comment
编辑 删除 PRIMARY BTREE 是 否 id 238281 A
编辑 删除 channel BTREE 否 否 channel 1 A
编辑 删除 ismake BTREE 否 否 ismake 3 A
编辑 删除 sortrank BTREE 否 否 sortrank 238281 A
编辑 删除 typeid BTREE 否 否 typeid 105 A
EXPLAIN结果:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE arc index typeid sortrank 4 NULL 215 Using where
1 SIMPLE tp const PRIMARY PRIMARY 2 const 1
尝试组合索引:typeid、arcrank、sortrank,执行时间没变化。尝试不同组合索引无果。
解决方案 »
- MYSQL 查询数据的时候,mysql服务直接挂掉
- binlog为什么没有记录一些insert操作呢
- 求解,问题很简单,大家来看看,谢谢了
- 多个like搜索出每项like的唯一结果 怎么写sql?
- 数据库设计的问题!急!求教高手
- mysql的gui管理工具winmysqladmin中database里面没有create database选项
- 俺WINNT上安装了MySql3.23用NET START MySql启动后,键入mysqlshow,显示错误。
- 求高手,难,mysql 300万数据查询500多秒怎么优化啊
- 请帮忙看看有关IF函数的表达式怎么写~
- Mysql并发控制加锁问题
- 如何把标题相同的时间不是最早的标注del为1,把url相同的,时间不是最早的,del标注为1
- mysql bit型 默认值
不要用in, 尝试对 arc.typeid, arc.arcrank 建联合索引, tp.id 建索引
如果还是解释使用索引 arc.sortrank , 建议强制使用上面的联合索引试试
create index xxx on dede_archives (typeid,sortrank);
create index xxx on dede_arctype (id);