Shivanand L.C Shivanand L.C - 2 years ago 77
MySQL Question

Are stored procedures faster/better then simple queries?

I'm using stored procedures to retrieve data for a few requirements which I think cannot be achieved using simple queries.
But in general, are stored procedures better, faster and efficient than simple queries?

Answer Source

Its a long debate but generally they are faster.

The reason why they are faster is

The Cache, it benefits in a way that the first time the stored procedure is executed, database server creates an execution plan, which is cached for reuse.

Pre-parsed SQL, no need to parse it every time.

Pre-generated query execution plan

Reduced network traffic

Ability to edit without recompiling

SQL injection attacks

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download