如何减少MySQL查询的执行时间

时间:2017-07-13 01:41:33

标签: mysql sql join query-optimization

我从未学会优化我的JOINS,并且这些表中至少有一行有超过200,000行,我想知道是否有人可以推荐任何改进以减少执行时间,SQL的建议以及如何优化表,如索引。任何想法都将不胜感激。

SELECT 
  t.entry_id as entry_id, 
  status, 
  entry_date, 
  child_entry_id as skill_id, 
  parent_id as cat_parent,
  field_id_4 as tunnel, 
  field_id_140 as log_instructor, 
  field_id_2 as log_time, 
  field_id_17 as log_video, 
  field_id_18 as log_comments, 
  field_id_86 as log_instructor_comment, 
  field_id_93 as logbook_denial_explanation, 
  field_id_119 as log_instructor_comment_add
FROM 
  exp_playa_relationships r, 
  exp_channel_titles t, 
  exp_channel_data d, 
  exp_category_posts p, 
  exp_categories c
WHERE 
  d.channel_id = 7
  AND d.entry_id = t.entry_id
  AND t.status != 'Delete'
  AND author_id = '1'
  AND t.entry_id = r.parent_entry_id
  AND r.parent_field_id = 19
  AND child_entry_id = p.entry_id
  AND p.cat_id = c.cat_id
  AND c.parent_id IN(37,38,39,40,41)
  ORDER BY entry_id DESC

0 个答案:

没有答案