按降序排序需要花费很多时间在mysql中加载

时间:2017-11-09 14:39:27

标签: mysql database sorting sql-order-by load-time

我有一张表有33,107,887条记录。

表结构:tablename

id - bigint - uniqu
text - text - fulltex index
cate_id - bigint - btree index
marchant_name - varchare - btree index
created_on - timestamp - btree index

当我在查询下方运行时,它需要花费60多秒

SELECT * FROM tablename where marchant_name='marchant name x' order by id  desc limit 20

但如果我运行此查询,则只需1秒

SELECT * FROM tablename where marchant_name='marchant name x' order by id  asc limit 20

注意:这里的名字x在主表中有8mn +记录。

听到“oc by asc”和“by desc”的问题。有没有人可以帮助我?

由于

0 个答案:

没有答案