- 论坛徽章:
- 0
|
本帖最后由 ayalastrike 于 2012-06-28 13:28 编辑
查询最慢的三组表
# Profile
# Rank Query ID Response time Calls R/Call Apdx V/M Item
# ==== ================== =============== ===== ====== ==== ===== ========
# 1 0xC319B7318AA6C2BA 3081.0000 3.5% 1175 2.6221 0.49 0.24 UPDATE s_user_ssss_setting_?
# 2 0xA0037A413053117E 2839.0000 3.3% 1131 2.5102 0.49 0.21 SELECT s_user_ssss_account_?
# 3 0xA0339F9508706779 2723.0000 3.1% 1033 2.6360 0.49 0.22 UPDATE s_user_ssss_building_?
比如第一个,update时where查询走的是主键啊,我也不明白怎么有的时候怎么会超过1秒
# Query 1: 0.01 QPS, 0.03x concurrency, ID 0xC319B7318AA6C2BA at byte 133991
# This item is included in the report because it matches --limit.
# Scores: Apdex = 0.49 [1.0], V/M = 0.24
# Query_time sparkline: | ^ |
# Time range: 2012-06-27 06:18:06 to 2012-06-28 11:18:05
# Attribute pct total min max avg 95% stddev median
# ============ === ======= ======= ======= ======= ======= ======= =======
# Count 3 1175
# Exec time 3 3081s 2s 6s 3s 4s 792ms 2s
# Lock time 2 22s 0 3s 19ms 0 161ms 0
# Rows sent 0 0 0 0 0 0 0 0
# Rows examine 0 0 0 0 0 0 0 0
# Query size 6 268.46k 122 950 233.96 833.10 226.23 124.25
# String:
# Databases ssss
# Hosts
# Users ssss
# Query_time distribution
# 1us
# 10us
# 100us
# 1ms
# 10ms
# 100ms
# 1s ################################################################
# 10s+
# Tables
# SHOW TABLE STATUS FROM `ssss` LIKE 's_user_ssss_setting_7'\G
# SHOW CREATE TABLE `ssss`.`s_user_ssss_setting_7`\G
update s_user_ssss_setting_7 set mtime = '2012-06-27 07:40:02', setting = '11' where uid = '49655175' and skey = 'rp_now_tag'\G
# Converted for EXPLAIN
# EXPLAIN /*!50100 PARTITIONS*/
select mtime = '2012-06-27 07:40:02', setting = '11' from s_user_ssss_setting_7 where uid = '49655175' and skey = 'rp_now_tag'\G
这里我把update替换成select跑一下查询
mysql> select * from s_user_ssss_setting_7 where uid = '49655175' and skey = 'rp_now_tag';
+----------+------------+---------+---------------------+---------------------+
| uid | skey | setting | mtime | ctime |
+----------+------------+---------+---------------------+---------------------+
| 49655175 | rp_now_tag | 12 | 2012-06-28 07:44:41 | 2011-12-17 18:58:34 |
+----------+------------+---------+---------------------+---------------------+
1 row in set (0.11 sec)
mysql> show profile;
+--------------------+----------+
| Status | Duration |
+--------------------+----------+
| starting | 0.114216 |
| Opening tables | 0.000019 |
| System lock | 0.000010 |
| Table lock | 0.000014 |
| init | 0.000050 |
| optimizing | 0.000019 |
| statistics | 0.000065 |
| preparing | 0.000020 |
| executing | 0.000008 |
| Sending data | 0.000093 |
| end | 0.000009 |
| end | 0.000007 |
| query end | 0.000007 |
| freeing items | 0.000010 |
| closing tables | 0.000008 |
| logging slow query | 0.000007 |
| cleaning up | 0.000006 |
+--------------------+----------+
17 rows in set (0.00 sec)
mysql> explain select * from s_user_ssss_setting_7 where uid = '49655175' and skey = 'rp_now_tag';
+----+-------------+-----------------------+-------+---------------+---------+---------+-------------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------------------+-------+---------------+---------+---------+-------------+------+-------+
| 1 | SIMPLE | s_user_city_setting_7 | const | PRIMARY | PRIMARY | 26 | const,const | 1 | |
+----+-------------+-----------------------+-------+---------------+---------+---------+-------------+------+-------+
1 row in set (0.00 sec)
|
|