[前][次][番号順一覧][スレッド一覧]

mysql:16066

From: < <coolguy318@xxxxxxxxxx>>
Date: Mon, 16 Dec 2013 16:16:52 +0900
Subject: [mysql 16066] Re: MySQL tunning(count句)

2013. 12. 16.  4:14 "" <coolguy318@xxxxxxxxxx> :

> ml@xxxxxxxxxx
> 2013. 12. 16.  4:12 "" <swhwang@xxxxxxxxxx> :
>
>> お疲れ様です。
>>
>> 黄と申します。
>>
>> 今、MySQLのTunningに関して、悩んでいます。
>>
>>
>>
>> クエリは以下になります。
>>
>> select count(group_code) from tb_ims_sip
>>
>> このクエリをどうやって、 Tunningすればいいのか、教えていたqだけませんか?
>>
>>
>>
>>
>>
>> mysql> select count(*) from TB_IMS_SIP;
>>
>> +----------+
>>
>> | count(*) |
>>
>> +----------+
>>
>> | 13844348 |
>>
>> +----------+
>>
>> 1 row in set (8 min 17.94 sec)
>>
>>
>>
>> mysql> select count(group_code) from TB_IMS_SIP;
>>
>> +-------------------+
>>
>> | count(group_code) |
>>
>> +-------------------+
>>
>> |          13857208 |
>>
>> +-------------------+
>>
>> 1 row in set (8 min 9.95 sec)
>>
>>
>>
>> mysql> show profiles;
>>
>> +----------+--------------+------------------------------------------+
>>
>> | Query_ID | Duration     | Query                                    |
>>
>> +----------+--------------+------------------------------------------+
>>
>> |        1 |   0.00014000 | select count(group_code) from tb_ims_sip |
>>
>> |        2 | 490.01962800 | select count(group_code) from TB_IMS_SIP |
>>
>> +----------+--------------+------------------------------------------+
>>
>> 2 rows in set (0.00 sec)
>>
>>
>>
>> mysql> show profile for QUERY 1;
>>
>> +----------------------+----------+
>>
>> | Status               | Duration |
>>
>> +----------------------+----------+
>>
>> | starting             | 0.000054 |
>>
>> | checking permissions | 0.000009 |
>>
>> | Opening tables       | 0.000054 |
>>
>> | query end            | 0.000003 |
>>
>> | closing tables       | 0.000003 |
>>
>> | freeing items        | 0.000013 |
>>
>> | logging slow query   | 0.000002 |
>>
>> | cleaning up          | 0.000002 |
>>
>> +----------------------+----------+
>>
>> 8 rows in set (0.00 sec)
>>
>>
>>
>>
>>
>>
>>
>> mysql> show profile for QUERY 2;
>>
>> +----------------------+------------+
>>
>> | Status               | Duration   |
>>
>> +----------------------+------------+
>>
>> | starting             |   0.000049 |
>>
>> | checking permissions |   0.000009 |
>>
>> | Opening tables       |   0.000019 |
>>
>> | System lock          |   0.000010 |
>>
>> | init                 |   0.000016 |
>>
>> | optimizing           |   0.000005 |
>>
>> | statistics           |   0.000011 |
>>
>> | preparing            |   0.000009 |
>>
>> | executing            |   0.000006 |
>>
>> | Sending data         | 490.019393 |
>>
>> | end                  |   0.000013 |
>>
>> | query end            |   0.000006 |
>>
>> | closing tables       |   0.000008 |
>>
>> | freeing items        |   0.000015 |
>>
>> | logging slow query   |   0.000003 |
>>
>> | logging slow query   |   0.000050 |
>>
>> | cleaning up          |   0.000006 |
>>
>> +----------------------+------------+
>>
>> 17 rows in set (0.00 sec)
>>
>>
>>
>>
>>
>> mysql> explain select count(group_code) from TB_IMS_SIP;
>>
>>
>> +----+-------------+------------+-------+---------------+-----------------------+---------+------+----------+-------------+
>>
>> | id | select_type | table      | type  | possible_keys |
>> key                   | key_len | ref  | rows     | Extra       |
>>
>>
>> +----+-------------+------------+-------+---------------+-----------------------+---------+------+----------+-------------+
>>
>> |  1 | SIMPLE      | TB_IMS_SIP | index | NULL          |
>> IDX_TB_IMS_SIP_SERVER | 30      | NULL | 12730949 | Using index |
>>
>>
>> +----+-------------+------------+-------+---------------+-----------------------+---------+------+----------+-------------+
>>
>> 1 row in set (0.00 sec)
>>
>>
>>
>>
>>
>> mysql> explain select count(group_code) from TB_IMS_SIP\G
>>
>> *************************** 1. row ***************************
>>
>>           id: 1
>>
>>   select_type: SIMPLE
>>
>>         table: TB_IMS_SIP
>>
>>          type: index
>>
>> possible_keys: NULL
>>
>>           key: IDX_TB_IMS_SIP_SERVER
>>
>>       key_len: 30
>>
>>           ref: NULL
>>
>>          rows: 14140764
>>
>>         Extra: Using index
>>
>> 1 row in set (0.00 sec)
>>
>>
>>
>>
>>
>> mysql> describe TB_IMS_SIP;
>>
>> +-------------------+----------+------+-----+---------+-------+
>>
>> | Field             | Type     | Null | Key | Default | Extra |
>>
>> +-------------------+----------+------+-----+---------+-------+
>>
>> | GROUP_CODE        | char(10) | NO   | PRI | NULL    |       |
>>
>> | SERVER_NAME       | char(20) | NO   | PRI | NULL    |       |
>>
>> | OBJECT_ID         | int(11)  | NO   | PRI | NULL    |       |
>>
>> | SERVICE_TYPE_CODE | char(20) | NO   | PRI | NULL    |       |
>>
>> | SERVICE_NAME      | char(20) | NO   | PRI | NULL    |       |
>>
>> | STAT_TYPE         | int(11)  | NO   | PRI | NULL    |       |
>>
>> | DATETIME          | char(14) | NO   | PRI | NULL    |       |
>>
>> | SERVER            | char(16) | NO   | PRI |         |       |
>>
>> | SERVICE           | char(16) | NO   | PRI |         |       |
>>
>> | NUM_TYPE          | char(16) | NO   | PRI |         |       |
>>
>> | BRANCH            | char(16) | NO   | PRI |         |       |
>>
>> | IO_TYPE           | char(8)  | NO   | PRI |         |       |
>>
>> | ATTEMPT           | int(11)  | YES  |     | 0       |       |
>>
>> | SUCCESS           | int(11)  | YES  |     | 0       |       |
>>
>> | COMPLETE          | int(11)  | YES  |     | 0       |       |
>>
>> | PROVISIONING      | int(11)  | YES  |     | 0       |       |
>>
>> | SUCCESS_RATE      | int(11)  | YES  |     | 0       |       |
>>
>> | COMPLETE_RATE     | int(11)  | YES  |     | 0       |       |
>>
>> | PROVISIONING_RATE | int(11)  | YES  |     | 0       |       |
>>
>> | COUNT             | int(11)  | YES  |     | NULL    |       |
>>
>> +-------------------+----------+------+-----+---------+-------+
>>
>> 20 rows in set (0.00 sec)
>>
>>
>>
>>
>>
>> Slowqueryの結果
>>
>> # Time: 131216 10:42:25
>>
>> # User@Host: root[root] @ localhost []
>>
>> # Query_time: 490.019558  Lock_time: 0.000073 Rows_sent: 1
>> Rows_examined: 13857208
>>
>> SET timestamp=1387158145;
>>
>> select count(group_code) from TB_IMS_SIP;
>>
>>
>>
>>
>>
>>
>>
>> 開発社からの依頼
>>
>>
>>
>> 一般的なクエリ(単純なカウント - PK)をする場合にも、場合によっては、6分以上を示しています。
>>
>> データの数が約800万件程度と、通常は0.1ms以内に応答を与えるのですが、現在インストールされてMysqlは
>>
>> 応答速度が6mを超えています。
>>
>> mysqlのInsertが多く発生(IO)しているからであろうと推定されます。
>>
>> もう一つの影響では、DBが保存されるパスは、現在のNASになっており、このために発生する影響もあると思います。
>>
>>
>>
>> Mysqlエンジニア【かにサポートを受ける部分は、現在のクエリをした場合の結果が正常であることを確認お願いしており、その部分に問題がある場合
>> 、どのよう
>>
>> チューニングをするか、チューニングポイントを探してほしいという要求です
>>
>>
>>
>> ==============================
>>
>> ()
>>
>> SK   
>>
>> Mobile. 010-6718-1196
>>
>> Tel. 02-6207-1159,1160
>>
>> Fax. 02-6207-1161
>>
>> E-mail. swhwang@xxxxxxxxxx
>>
>>    166-5  2F
>>
>> :135-090
>>
>> ==============================
>>
>>
>>
>


添付ファイル

[前][次][番号順一覧][スレッド一覧]