慢查询日志返回错误行检查

时间:2015-05-12 12:02:11

标签: mysql performance query-optimization mysql-slow-query-log

如果在我的数据库中只有20,000行,在给定的表中,返回的行数如此之多。请引导我进行“row_examination”。这是什么意思?

 CALL DB.sp_get_program(10, 0, '', '', '', '', 0, 0, 0, '', '', @_cnet_param_p_total);
 Time: 150425  8:07:22
 User@Host: DB[User] @  [172.31.12.190]  Id: 64619
 Query_time: 62.843783  Lock_time: 0.000000 Rows_sent: 0  Rows_examined: 26264470

SELECT  (SELECT CONCAT(au.first_name,' ',au.last_name) FROM  tbl5 au WHERE admin_user_id = tbl.schedule_added_by LIMIT 1) as schedule_user_name,
(SELECT CONCAT(au.first_name,' ',au.last_name) FROM  tbl5 au WHERE admin_user_id = tbl.image_added_by LIMIT 1) as image_user_name,
(SELECT CONCAT(au.first_name,' ',au.last_name) FROM  tbl5 au WHERE admin_user_id = tbl.description_added_by LIMIT 1) as description_user_name,tbl.*
FROM
(SELECT *, 
(SELECT image FROM tbl WHERE program_id = p.program_id AND entry_type_id = 2 LIMIT 1) AS image,
(SELECT short_description FROM tbl WHERE program_id = p.program_id  AND entry_type_id = 3 LIMIT 1) AS short_description,                        
(SELECT COUNT(*) FROM tbl WHERE program_id = p.program_id 
                         AND is_live = TRUE) AS live_count
                        from tbl2 p 
                        INNER JOIN tbl3 pc on p.program_id=pc.program_id
                        INNER JOIN tbl pu on p.program_id=pu.program_id
                        INNER JOIN tbl4 c on pc.channel_id=c.channel_id         
                        WHERE pu.from_admin = FALSE AND p.is_active = TRUE
                        GROUP BY pc.program_channel_id) tbl WHERE  tbl.live_count < 3 AND (is_schedule_live= FALSE OR is_image_live=FALSE OR is_description_live=FALSE)

1 个答案:

答案 0 :(得分:0)

闻起来像是偶然的&#34;交叉加入&#34;。检查您的代码,看看每个JOIN是否都有ON条款。

如果您需要更多帮助,

  • 提供存储程序的来源
  • 每个表
  • SHOW CREATE TABLE
  • 表的大小。