当前位置:首页 >系统运维 >MySQL数据库下limit与join的优化方案 正文

MySQL数据库下limit与join的优化方案

来源:益强资讯优选   作者:系统运维   时间:2025-11-05 08:39:36
MySQL数据库下limit与join的优化方案
复制mysql> select id,据库substr(mobile from 1 for 7),time,cpid,linkid from cp_mo100227 where cpid=769 limit 888888,10;   +———-+—————————–+———————+——+———————-+   | id | substr(mobile from 1 for 7) | time | cpid | linkid |   +———-+—————————–+———————+——+———————-+   | 11535090 | 1353554 | 2010-02-24 21:07:48 | 769 | 21064905903309587933 |   | 11535091 | 1353750 | 2010-02-24 21:07:48 | 769 | 21064912943389480033 |   | 11535093 | 1353394 | 2010-02-24 21:07:48 | 769 | 21064912945389480075 |   | 11535098 | 1343073 | 2010-02-24 21:07:50 | 769 | 21064905865309587977 |   | 11535100 | 1369270 | 2010-02-24 21:07:51 | 769 | 21064926770369210194 |   | 11535103 | 1355683 | 2010-02-24 21:07:51 | 769 | 21064912944389480113 |   | 11535104 | 1368959 | 2010-02-24 21:07:51 | 769 | 21064902508384448468 |   | 11535105 | 1365243 | 2010-02-24 21:07:51 | 769 | 21064905907309403124 |   | 11535106 | 1362145 | 2010-02-24 21:07:52 | 769 | 21065002511384448497 |   | 11535107 | 1369228 | 2010-02-24 21:07:52 | 769 | 21064902514384448437 |   +———-+—————————–+———————+——+———————-+   10 rows in set (3.84 sec)   mysql> select id,substr(mobile from 1 for 7),time,cpid,linkid from cp_mo100227 where cpid=769 and id>=11535090 limit 10;   +———-+—————————–+———————+——+———————-+   | id | substr(mobile from 1 for 7) | time | cpid | linkid |   +———-+—————————–+———————+——+———————-+   | 11535090 | 1353554 | 2010-02-24 21:07:48 | 769 | 21064905903309587933 |   | 11535091 | 1353750 | 2010-02-24 21:07:48 | 769 | 21064912943389480033 |   | 11535093 | 1353394 | 2010-02-24 21:07:48 | 769 | 21064912945389480075 |   | 11535098 | 1343073 | 2010-02-24 21:07:50 | 769 | 21064905865309587977 |   | 11535100 | 1369270 | 2010-02-24 21:07:51 | 769 | 21064926770369210194 |   | 11535103 | 1355683 | 2010-02-24 21:07:51 | 769 | 21064912944389480113 |   | 11535104 | 1368959 | 2010-02-24 21:07:51 | 769 | 21064902508384448468 |   | 11535105 | 1365243 | 2010-02-24 21:07:51 | 769 | 21064905907309403124 |   | 11535106 | 1362145 | 2010-02-24 21:07:52 | 769 | 21065002511384448497 |   | 11535107 | 1369228 | 2010-02-24 21:07:52 | 769 | 21064902514384448437 |   +———-+—————————–+———————+——+———————-+   10 rows in set (0.00 sec)   mysql> select id,substr(mobile from 1 for 7),time,cpid,linkid from cp_mo100227 where cpid=769 and time>=’2010-02-24 21:07:48′ limit 10;   +———-+—————————–+———————+——+———————-+   | id | substr(mobile from 1 for 7) | time | cpid | linkid |   +———-+—————————–+———————+——+———————-+   | 11535090 | 1353554 | 2010-02-24 21:07:48 | 769 | 21064905903309587933 |   | 11535091 | 1353750 | 2010-02-24 21:07:48 | 769 | 21064912943389480033 |   | 11535093 | 1353394 | 2010-02-24 21:07:48 | 769 | 21064912945389480075 |   | 11535098 | 1343073 | 2010-02-24 21:07:50 | 769 | 21064905865309587977 |   | 11535100 | 1369270 | 2010-02-24 21:07:51 | 769 | 21064926770369210194 |   | 11535103 | 1355683 | 2010-02-24 21:07:51 | 769 | 21064912944389480113 |   | 11535104 | 1368959 | 2010-02-24 21:07:51 | 769 | 21064902508384448468 |   | 11535105 | 1365243 | 2010-02-24 21:07:51 | 769 | 21064905907309403124 |   | 11535106 | 1362145 | 2010-02-24 21:07:52 | 769 | 21065002511384448497 |   | 11535107 | 1369228 | 2010-02-24 21:07:52 | 769 | 21064902514384448437 |   +———-+—————————–+———————+——+———————-+   10 rows in set (0.01 sec)  1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.

标签:

责任编辑:域名