![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
![]() 猫猫猫 ![]() ![]() ![]() Group: Power Cat Posts: 626 Joined: 2006-12-8 Member No.: 2 ![]() |
查询时使用 count() 函数,操作上会将所有匹配的行读取一遍,而且与原本的结果集不能同时输出
改用 SQL_CALC_FOUND_ROWS 配合 FOUND_ROWS() 函数会快得多 举例 代码 SELECT * FROM T1 WHERE C1='V1' LIMIT 10; SELECT COUNT(*) FROM T1 WHERE C1='V1'; 改为 代码 SELECT SQL_CALC_FOUND_ROWS * FROM T1 WHERE C1='V1' LIMIT 10;
SELECT FOUND_ROWS(); |
|
|
![]() ![]() |
Lo-Fi Version | Time is now: 2025-4-4 12:48 |