Mysql查询不好,但DESCRIBE看起来不错

时间:2013-03-26 02:36:43

标签: mysql sql

我有一个MySql 5.5查询需要6-20秒才能执行。

SELECT TE.memb_priority, E.event_id, IFNULL(TE.user_show_as, E.show_time_as), 
       TE.email_id, TE.memb_color, TE.memb_inv_id, TE.invite_type, TE.is_confirmed, TE.invite_alias, IFNULL(TE.reminder, E.reminder_mins),
       COALESCE(TE.delete_dt, IORG.rm_from_invite_dt), 
       GREATEST(E.last_update_time, IFNULL(TE.greatest_time, 0)), IORG.required_attendee, 0
  FROM INVITED_ORG IORG, PERM_USER_EVENT_MEMB TE, USER_EVENT E
 WHERE TE.memb_inv_id       = IORG.org_id_FK
   AND IORG.event_id_FK     = E.event_id     
   AND ((E.event_owner      = IORG.org_id_FK
   AND   E.exclude_owner    = 0)
    OR E.event_owner       != IORG.org_id_FK)  
   AND (E.gmt_end_date > '2013-02-17 00:00:00.0'
    OR (E.recurrence IS NOT NULL
   AND  '2013-02-17 00:00:00.0' <= E.recurrence_end_dt)); 

DESCRIBE显示:

id,select_type,table,type,possible_keys,key,key_len,ref,rows,Extra
-------------------------------------------------------------------
1,SIMPLE,TE,ALL,idx_id,NULL,NULL,NULL,61,
1,SIMPLE,IORG,ref,"PRIMARY,idx_oid,idx_eid",idx_oid,4,GLOCAL.TE.memb_inv_id,343,
1,SIMPLE,E,eq_ref,PRIMARY,PRIMARY,252,GLOCAL.IORG.event_id_FK,1,"Using where"

如您所见,DESCRIBE看起来不错。还有什么可以检查以使此查询更有效?

1 个答案:

答案 0 :(得分:0)

如果结果集不适合innodb_buffer_pool_size查询,则由于I / O分页将花费特别长的时间。