2016-10-07 11 views
0

Sending dataを大量に実行している次のクエリがあり、その理由を理解できません。mysqlクエリプロファイリングループ送信データ?

INSERT INTO 
Member_multi_site (
    Person_id, 
    Site_id 
) 
SELECT 
Person_id, 
Site_id 
FROM 
Members m CROSS 
JOIN 
Sites s 
WHERE NOT EXISTS (
SELECT 
    1 
FROM 
    Member_multi_site 
WHERE 
    person_id = m.person_id 
AND 
    site_id = s.site_id 
); 

クエリプロフィール:

+--------------------+-----------+ 
| Status    | Duration | 
+--------------------+-----------+ 
| Sending data  | 0.000007 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000004 | 
| Sending data  | 0.000007 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000003 | 
| Sending data  | 0.000008 | 
| executing   | 0.000003 | 
| Sending data  | 0.000007 | 
| executing   | 0.000004 | 
| Sending data  | 0.000009 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000010 | 
| Sending data  | 0.000010 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000003 | 
| Sending data  | 0.000008 | 
| executing   | 0.000003 | 
| Sending data  | 0.000008 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000003 | 
| Sending data  | 0.000007 | 
| executing   | 0.000003 | 
| Sending data  | 0.000010 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000004 | 
| Sending data  | 0.000007 | 
| executing   | 0.000004 | 
| Sending data  | 0.000007 | 
| executing   | 0.000003 | 
| Sending data  | 0.000007 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000003 | 
| Sending data  | 0.000008 | 
| executing   | 0.000003 | 
| Sending data  | 0.000009 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000004 | 
| Sending data  | 0.000007 | 
| executing   | 0.000003 | 
| Sending data  | 0.000007 | 
| executing   | 0.000003 | 
| Sending data  | 0.000007 | 
| executing   | 0.000004 | 
| Sending data  | 0.000007 | 
| executing   | 0.000003 | 
| Sending data  | 0.000008 | 
| executing   | 0.000004 | 
| Sending data  | 0.000009 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000003 | 
| Sending data  | 0.000008 | 
| executing   | 0.000003 | 
| Sending data  | 0.000007 | 
| executing   | 0.000004 | 
| Sending data  | 0.000007 | 
| executing   | 0.000003 | 
| Sending data  | 0.000007 | 
| executing   | 0.000004 | 
| Sending data  | 0.000007 | 
| executing   | 0.000003 | 
| Sending data  | 0.000008 | 
| executing   | 0.000003 | 
| Sending data  | 0.000009 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000004 | 
| Sending data  | 0.000008 | 
| executing   | 0.000004 | 
| Sending data  | 0.000007 | 
| executing   | 0.000004 | 
| Sending data  | 0.000007 | 
| executing   | 0.000003 | 
| Sending data  | 0.000007 | 
| executing   | 0.000004 | 
| Sending data  | 0.000007 | 
| executing   | 0.000004 | 
| Sending data  | 0.000007 | 
| executing   | 0.000003 | 
| Sending data  | 19.202793 | 
| end    | 0.000028 | 
| query end   | 0.004342 | 
| removing tmp table | 0.000062 | 
| query end   | 0.000009 | 
| closing tables  | 0.000028 | 
| freeing items  | 0.000049 | 
| cleaning up  | 0.000036 | 
+--------------------+-----------+ 

それはMySQLの設定だろうか?

答えて

0
You are applying cross join. 
    So if in member table records are like this 
    MemberId 
    1 
    In site table 
    SiteId 
    121 
    122 
    123 
    124 
    so output of cross join will be 
    MemberId |SiteId 
    1   121 
    1   122 
    1   123 
    1   124 
    Now you are selecting such element which are not exist in Member_multi_site 
    so it will check first record present or not if not it will insert . 
so data insertion is correct 
+0

はいこれはクエリの仕組みです。しかし、なぜたくさんのデータを送るのですか?それが私の質問です。 – Efekan

関連する問題