One:
MySQL defaults to the physical order of the installation records, and if you do not order BY, you may not get the expected results.
(1) Get the ID of two time points (soon)
$sql = ' Select id from apply_info where create_time< {$now} limit 1 '; (To add order by id DESC)
Get Idnow
$sql = ' Select id from apply_info where create_time>= {$yesterday} limit 1 ' (to add order by ID ASC)
Get Idyt
(2) 1000 per fetch
do{
Select User_mobile,user_from from Apply_info where ID <= {$idNow} limit 1000;
Idnow-= 1000;
Todo
} while (Idnow >= idyt)
Two:
Explain can be misleading when using limit
(1) Explain estimated number of rows, regardless of limit, may be too many rows to check for queries
(2) similar to select ... Queries from TBL LIMIT n are reported as slow queries because they are not used, (if n is small, real fast)
Profile settings Min-examined-row-limit=num of rows, number of rows checked >= This amount of queries will be reported as slow queries to avoid miscalculation
(3) Similar to this select: From TB where key_part1=? Order BY Key_part2 limit N,explain also estimates excessive number of check rows
MySQL uses the pit