0

小さなデータセットで実行するのに数分かかるクエリがありますが、何が問題なのですか? 説明の出力は次のとおりです。

id  select_type table           type    possible_keys               key                 key_len   ref             rows  Extra

1   SIMPLE      BT_CALL_CLASS.. const   PRIMARY                     PRIMARY             4         const           1     Using index; Using temporary; Using filesort
1   SIMPLE      BT_FLAGS_FLAGS  const   PRIMARY                     PRIMARY             4         const           1     Using index
1   SIMPLE      BT_DIRECTORY... range   PRIMARY                     PRIMARY             4         NULL            308   Using where; Using index
1   SIMPLE      BT_CALL_FLAGS.. ref     PRIMARY,FKDF68A2ED9F150002  FKDF68A2ED9F150002  4         const           49    Using where; Using index
1   SIMPLE      BT_DEPARTMENT.. index   PRIMARY                     FK1F3A276188DDBD3   5         NULL            27    Using where; Using index; Using join buffer
1   SIMPLE      BT_USERS_USER.. index   PRIMARY                     FK6A68E086C27A155   5         NULL            233   Using where; Using index; Using join buffer
1   SIMPLE      BT_FCT_CALLS..  eq_ref  PRIMARY,FKDF68A2ED4F28..    PRIMARY             8         ...call_id      1     Using where

クエリ

 desc SELECT DISTINCT 
      BT_FCT_CALLS_FCT_CALLS.start_time AS COL0
     ,BT_FCT_CALLS_FCT_CALLS.calling_number AS COL1
     ,BT_FCT_CALLS_FCT_CALLS.called_number AS COL2
     ,BT_FCT_CALLS_FCT_CALLS.response AS COL3

 FROM departments BT_DEPARTMENTS_DEPARTMENTS_3 LEFT OUTER JOIN 
 ( 
  directory_numbers BT_DIRECTORY_NUMBERS_DIRECTORY_NUMBERS LEFT OUTER JOIN 
  ( 
   users BT_USERS_USERS_2 JOIN 
   ( 
    call_classification_dim BT_CALL_CLASSIFICATION_DIM_CALL_CLASSIFICATION_DIM JOIN 
    ( 
     flags BT_FLAGS_FLAGS JOIN 
     ( 
      fct_calls BT_FCT_CALLS_FCT_CALLS JOIN call_flags BT_CALL_FLAGS_CALL_FLAGS
      ON ( BT_FCT_CALLS_FCT_CALLS.id = BT_CALL_FLAGS_CALL_FLAGS.call_id )
     ) 
     ON ( BT_CALL_FLAGS_CALL_FLAGS.flag = BT_FLAGS_FLAGS.id AND (  BT_FLAGS_FLAGS.id  = 1 )  )
    ) 
    ON ( BT_FCT_CALLS_FCT_CALLS.call_direction_id = BT_CALL_CLASSIFICATION_DIM_CALL_CLASSIFICATION_DIM.id AND (  BT_CALL_CLASSIFICATION_DIM_CALL_CLASSIFICATION_DIM.id  = 2 )  )
   ) 
   ON ( (( BT_FCT_CALLS_FCT_CALLS.on_network_called_user_id  =  BT_USERS_USERS_2.id ) OR ( BT_FCT_CALLS_FCT_CALLS.on_network_calling_user_id  =  BT_USERS_USERS_2.id )) AND TRUE   )
  ) 
  ON ( (( BT_FCT_CALLS_FCT_CALLS.on_network_called_ext_id  =  BT_DIRECTORY_NUMBERS_DIRECTORY_NUMBERS.id ) OR ( BT_FCT_CALLS_FCT_CALLS.on_network_calling_ext_id  =  BT_DIRECTORY_NUMBERS_DIRECTORY_NUMBERS.id )) AND TRUE )
 ) 
 ON ( (( BT_FCT_CALLS_FCT_CALLS.on_network_called_department_id  =  BT_DEPARTMENTS_DEPARTMENTS_3.id ) OR ( BT_FCT_CALLS_FCT_CALLS.on_network_calling_department_id  =  BT_DEPARTMENTS_DEPARTMENTS_3.id )) AND TRUE )

  WHERE 
    (
      (
          NOT( BT_DEPARTMENTS_DEPARTMENTS_3.id  IN ( 1 ) )
      )
  AND (
          NOT( BT_DIRECTORY_NUMBERS_DIRECTORY_NUMBERS.id  IN ( 1 ) )
      )

  AND (
          NOT( BT_USERS_USERS_2.id  IN ( 1 ) )
      )
    )
ORDER BY 
      COL0
4

3 に答える 3

0

コメントで言ったように、クエリは自動生成され、mysql 5.6.14 へのアップグレード後はあまり変更できず、クエリ自体に何も変更を加えることなく、パフォーマンスは正常になりました (比較して同様の複雑さを持つ他のクエリに)!

于 2013-11-17T14:41:32.907 に答える