简体   繁体   English

MySQL:Select语句并有选择地检索数据

[英]MySQL: Select statement and selectively retrieve data

I have a large dataset in MySQL and I would like to speed up the select statement when reading data. 我在MySQL中有一个大型数据集,并且在读取数据时想加快select语句的速度。 Assuming that there are 1000 records, I would like to issue a select statement that retrieves half of them for example but based on time-stamp. 假设有1000条记录,我想发出一条选择语句,该语句检索例如其中一半但基于时间戳的记录。

Using something like this will not work, while id is not tightly coupled with time-stamp 使用id这样的东西是行不通的,而id与时间戳不紧密相关

select * from table where table.id mod 5 = 0;

Retrieving all the data and afterwards select the data needed is not a solution while I want to avoid retrieving the large dataset. 检索所有数据并随后选择所需的数据不是解决方案,而我想避免检索大型数据集。 Thus, I 'm looking for something that would distinguish the records upon select. 因此,我正在寻找一种可以在选择时区分记录的东西。

Thnx n

If you need speed then try this 如果您需要速度,请尝试一下

select * from table ORDER BY table.id DESC LIMIT 0,500;

select * from table ORDER BY table.id DESC LIMIT 500,500;

and so on... 等等...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM