mysql longtext查询非常慢_mysql中longtext存在大量数据时,会导致查询很慢?

一个表,1.5w条数据,字段: id,name,content,last_update_time

id,自定义主键

name,varchar类型

content是longtext类型,

last_update_time为datetime类型,不为空

content当中是文本和代码等,平均长度在20k+。

case1:

select id, name from t order by last_update_time limit 10000, 10

当content当中有大量的文本时,case1的效率极慢。

及时给 last_update_time 加上btree索引, 效率有提升,但是依然慢

把content一列删掉,效率很高。毫秒级别。

使用explain:

有content时结果:

mysql> explain select id, name, last_update_time from t order by last_update_time desc limit 11120, 11;

+----+-------------+-----------+-------+---------------+----------------------+---------+------+-------+-------+

| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |

+----+-------------+-----------+-------+---------------+----------------------+---------+------+-------+-------+

| 1 | SIMPLE | t | index | NULL | idx_last_update_time | 8 | NULL | 11131 | NULL |

+----+-------------+-----------+-------+---------------+----------------------+---------+------+-------+-------+

无content列的结果:

+----+-------------+----------------+------+---------------+------+---------+------+-------+----------------+

| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |

+----+-------------+----------------+------+---------------+------+---------+------+-------+----------------+

| 1 | SIMPLE | t2 | ALL | NULL | NULL | NULL | NULL | 15544 | Using filesort |

+----+-------------+----------------+------+---------------+------+---------+------+-------+----------------+

1 row in set (0.00 sec)

请大神请教,是什么问题?该怎么优化?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值