mysql存储过程会不会有缓存,MySQL-存储过程不使用查询缓存

I have just converted a SQL select statement into a stored procedure

The SQL Statement use select statement takes

0.4784s to run the first time and 0.0003s after that

The Stored procedure takes 0.4784s to run every time.

I assume the query cache is not been used

How can I rectify this?

A simplified version of the code

SELECT * FROM Venues WHERE VenueName = :TheVenue

=======

CREATE PROCEDURE GetVenues

(

TheVenue VarChar(22)

)

BEGIN

SELECT * FROM Venues WHERE VenueName = TheVenue

END;

解决方案

Welcome to MySQL... it is really difficult to get anything within a stored procedure to take advantage of the query cache. The dev article A Practical Look at the MySQL Query Cache discusses this in some detail. The limitations are also mentioned in the reference documentation here and on the MySQL Performance Blog.

Basically, don't depend on caching of queries executed inside of stored procedures. It is near impossible to get it to work though the first reference does claim that it is possible. This usually isn't a problem if you are using stored procedures to encapsulate complicated logic. Most of the problems that I have seen were caused by using stored procedures for very simple queries where a VIEW would have sufficed.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值