我现在有条select一直处在sending data状态,以下是我explain的结果,请教如何解决。
+----+--------------+----------------+--------+---------------------------------------------+--------------------+---------+------------------------+------+-----------------------------------+
| id | select_type  | table          | type   | possible_keys                               | key                | key_len | ref                    | rows | Extra                             |
+----+--------------+----------------+--------+---------------------------------------------+--------------------+---------+------------------------+------+-----------------------------------+
|  1 | PRIMARY      | <derived2>     | system | NULL                                        | NULL               | NULL    | NULL                   |    0 | const row not found               |
|  2 | DERIVED      | <derived3>     | ALL    | NULL                                        | NULL               | NULL    | NULL                   |    7 |                                   |
|  2 | DERIVED      | a              | ref    | PRIMARY,id_ownerpidIndex,idx_ownerpid_flags | idx_ownerpid_flags | 5       | d.pid                  |    1 | Using where with pushed condition |
|  2 | DERIVED      | b              | ref    | pairKey,slotPairKey,tripleIndex,idx_pid     | pairKey            | 5       | sbqctest.a.id          |    1 | Using where                       |
|  2 | DERIVED      | c              | ref    | id                                          | id                 | 5       | sbqctest.b.pid         |    1 | Using where                       |
|  3 | DERIVED      | connectionurls | index  | NULL                                        | PairIndex          | 8       | NULL                   |    7 |                                   |
|  4 | UNION        | b              | ALL    | PRIMARY,id_ownerpidIndex                    | NULL               | NULL    | NULL                   |    2 | Using where with pushed condition |
|  4 | UNION        | a              | eq_ref | PRIMARY,id_ownerpidIndex,idx_ownerpid_flags | PRIMARY            | 4       | sbqctest.b.otherteamid |    1 | Using where with pushed condition |
|  4 | UNION        | c              | ref    | pairKey,slotPairKey,tripleIndex,idx_pid     | pairKey            | 5       | sbqctest.b.id          |    1 | Using where                       |
|  4 | UNION        | d              | ref    | id                                          | id                 | 5       | sbqctest.c.pid         |    1 | Using where                       |
|  4 | UNION        | <derived5>     | ALL    | NULL                                        | NULL               | NULL    | NULL                   |    7 | Using where; Using join buffer    |
|  5 | DERIVED      | connectionurls | index  | NULL                                        | PairIndex          | 8       | NULL                   |    7 |                                   |
| NULL | UNION RESULT | <union2,4>     | ALL    | NULL                                        | NULL               | NULL    | NULL                   | NULL |                                   |
+----+--------------+----------------+--------+---------------------------------------------+--------------------+---------+------------------------+------+-----------------------------------+
是不是需要修改query_cache_size和tmp_table_size这两个参数,谢谢。

解决方案 »

  1.   


    +----+--------------+----------------+--------+---------------------------------------------+--------------------+---------+------------------------+------+-----------------------------------+
    | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
    +----+--------------+----------------+--------+---------------------------------------------+--------------------+---------+------------------------+------+-----------------------------------+
    | 1 | PRIMARY | <derived2> | system | NULL | NULL | NULL | NULL | 0 | const row not found |
    | 2 | DERIVED | <derived3> | ALL | NULL | NULL | NULL | NULL | 7 | |
    | 2 | DERIVED | a | ref | PRIMARY,id_ownerpidIndex,idx_ownerpid_flags | idx_ownerpid_flags | 5 | d.pid | 1 | Using where with pushed condition |
    | 2 | DERIVED | b | ref | pairKey,slotPairKey,tripleIndex,idx_pid | pairKey | 5 | sbqctest.a.id | 1 | Using where |
    | 2 | DERIVED | c | ref | id | id | 5 | sbqctest.b.pid | 1 | Using where |
    | 3 | DERIVED | connectionurls | index | NULL | PairIndex | 8 | NULL | 7 | |
    | 4 | UNION | b | ALL | PRIMARY,id_ownerpidIndex | NULL | NULL | NULL | 2 | Using where with pushed condition |
    | 4 | UNION | a | eq_ref | PRIMARY,id_ownerpidIndex,idx_ownerpid_flags | PRIMARY | 4 | sbqctest.b.otherteamid | 1 | Using where with pushed condition |
    | 4 | UNION | c | ref | pairKey,slotPairKey,tripleIndex,idx_pid | pairKey | 5 | sbqctest.b.id | 1 | Using where |
    | 4 | UNION | d | ref | id | id | 5 | sbqctest.c.pid | 1 | Using where |
    | 4 | UNION | <derived5> | ALL | NULL | NULL | NULL | NULL | 7 | Using where; Using join buffer |
    | 5 | DERIVED | connectionurls | index | NULL | PairIndex | 8 | NULL | 7 | |
    | NULL | UNION RESULT | <union2,4> | ALL | NULL | NULL | NULL | NULL | NULL | |
    +----+--------------+----------------+--------+---------------------------------------------+--------------------+---------+------------------------+------+-----------------------------------+