使用EXPLAIN进行MYSQL存储过程调用

[英]using EXPLAIN for MYSQL stored procedure calls


How do analyse and use EXPLAIN for my stored procedure calls ? I need to optimize the query time, however seems like there is no where i can do a EXPLAIN call proc_name() ?

如何分析和使用EXPLAIN进行存储过程调用?我需要优化查询时间,但似乎没有我可以做EXPLAIN调用proc_name()的地方?

3 个解决方案

#1


16  

You can try

你可以试试

set profiling=1;
call proc_name();
show profiles;

#2


9  

at present you can't explain stored procedures in mysql - but you could do something like this:

目前你无法解释mysql中的存储过程 - 但你可以这样做:

drop procedure if exists get_user;
delimiter #
create procedure get_user
(
in p_user_id int unsigned,
in p_explain tinyint unsigned
)
begin
  if (p_explain) then
    explain select * from users where user_id = p_user_id;
  end if;
  select * from users where user_id = p_user_id;
end#

delimiter ;

call get_user(1,1);

#3


4  

EXPLAIN works only on SELECT statements, except when you use EXPLAIN tablename which is an alias of DESCRIBE tablename

EXPLAIN仅适用于SELECT语句,除非使用EXPLAIN tablename,它是DESCRIBE tablename的别名


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2011/03/22/e1a3368c4cf791ee417ea4c5dad42cc.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号