第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

sql語句執(zhí)行性能分析

sql語句執(zhí)行性能分析

蝴蝶刀刀 2019-03-21 18:14:18
問題一:1.有什么可視化的,能夠特別直觀的分析SQL語句性能的工具?問題二:select *  limit offset,amount;select *  where id between offset and offset+amount;select *  where id > offset limit amount;以上三個SQL語句,哪個性能更佳呢?項目中我們一般用的好像是limit a b 這樣的吧,性能又如何呢?
查看完整描述

4 回答

?
慕哥6287543

TA貢獻1831條經(jīng)驗 獲得超10個贊

  1. explain

  2. 根據(jù)上面提到的explain去比較,就可以得出結(jié)果了

mysql> explain select * from users  limit 1000,20;

+----+-------------+-------+------+---------------+------+---------+------+--------+-------+

| id | select_type | table | type | possible_keys | key  | key_len | ref  | rows   | Extra |

+----+-------------+-------+------+---------------+------+---------+------+--------+-------+

|  1 | SIMPLE      | users | ALL  | NULL          | NULL | NULL    | NULL | 169847 |       |

+----+-------------+-------+------+---------------+------+---------+------+--------+-------+

1 row in set (0.00 sec)

mysql> explain select * from users where uid>1000  limit 20;

+----+-------------+-------+-------+---------------+---------+---------+------+-------+-------------+

| id | select_type | table | type  | possible_keys | key     | key_len | ref  | rows  | Extra       |

+----+-------------+-------+-------+---------------+---------+---------+------+-------+-------------+

|  1 | SIMPLE      | users | range | PRIMARY       | PRIMARY | 4       | NULL | 84923 | Using where |

+----+-------------+-------+-------+---------------+---------+---------+------+-------+-------------+

1 row in set (0.00 sec)

mysql> explain select * from users where uid  between 1000 and 1020;

+----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+

| id | select_type | table | type  | possible_keys | key     | key_len | ref  | rows | Extra       |

+----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+

|  1 | SIMPLE      | users | range | PRIMARY       | PRIMARY | 4       | NULL |    1 | Using where |

+----+-------------+-------+-------+---------------+---------+---------+------+------+-------------+

1 row in set (0.00 sec)


查看完整回答
反對 回復(fù) 2019-04-22
  • 4 回答
  • 0 關(guān)注
  • 516 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號