从底部扫描mysql表 [英] Scanning a mysql table from the bottom

查看:153
本文介绍了从底部扫描mysql表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行mysql select语句时,它需要很长时间,因为我以前已经删除了很多行.

When i run a mysql select statement, it takes very long because i have already previously deleted a very large number of rows.

表格是否可以从底部开始而不是从顶部开始扫描?

Is there a way for the table to start scanning from the bottom, as opposed to from the top?

推荐答案

查询不会以任何特定顺序扫描表;如果碰巧按顺序遍历特定索引(例如范围扫描),则可能会这样做,这可能是因为您使用了ORDER BY.

A query does not scan the table in any particular order; it might do so if it happens to traverse a particular index in order (e.g. a range scan), which MIGHT be because you used an ORDER BY.

数据库不能那样工作.您不能以这种方式依赖他们的行为.

Databases just don't work like that. You cannot rely on their behaviour in that way.

如果要进行全表扫描,则需要一段时间,特别是如果您最近删除了很多行.但是,如果您有很多行,则将花费更长的时间.

If you're doing a full table scan, expect it to take a while, particularly if you've deleted a lot of rows recently. However, it will take even longer if you have lots of rows.

确保查询使用索引代替.查看说明计划,并确保它使用索引.

Ensure that the query uses indexes instead. Looks at the explain plan and make sure it uses indexes.

这篇关于从底部扫描mysql表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆