How/when mysql compiles stored procedures?

前端 未结 2 1426
时光说笑
时光说笑 2021-01-12 18:01

We intend to use mysql stored procedures for handling all database work for one project. There are several applications(different languages) using same database and I am fai

2条回答
  •  醉梦人生
    2021-01-12 18:46

    No. Query and stored procedures are compiled on demand and then kept in a cache for a while. If you use a specific stored procedure repeatedly the version compiled in the cache will be used, but if it is no longer in cache it must be compiled first, just like any other query you send to a database.

    What MySQL certainly will not do is compile all x-hundred stored procedures at once - in case that was what you were afraid of.

    But all this is somewhat irrelevant The advantage of stored procedures is that you can make sure that multiple applications using the same database, use it in the same way. When your performance is such that you start looking at the compilation cache for speed, you are looking at the wrong place. Speed optimization is better done through either query or database redesign.

提交回复
热议问题