Stored Procedures – Advantages/Disadvantages

Stored Procedures Advantages

  • Stored procedure increases performance of application. Once created, stored procedure is compiled and stored in the database catalog. It runs faster than uncompiled SQL commands which are sent from application.
  • Stored procedure reduced the traffic between application and database server because instead of sending multiple uncompiled lengthy SQL commands statements, application only has to send the stored procedure name and get the data back to manipulate it futher.
  • Stored procedure is reusable and transparent to any application which wants to use it. Storedprocedure exposes the database interface to all applications so developers don’t have to program the functions which are already supported in stored procedure in all externalapplications.
  • Stored procedure is secured. Database administrator can grant the access right toapplication which wants to access stored procedures in database catalog without granting any permission on the underlying database tables.

Beside those advantages, stored procedure still has its own disadvantages which are below:

Stored Procedures Disadvantages

  • Stored procedures make the database server high load in both memory for and processors. Instead of being focused on the storing and retrieving data, you could be asking the database server to perform a number of logical operations or a complex of business logic which is not the well designed in database server.
  • Stored procedure only contains declarative SQL so it is very difficult to write a procedure with complexity of business logic like other languages in application layer such as Java, C#, C++…
  • You cannot debug stored procedure in almost RDMBSs and in MySQL also. There are some workarounds on this problem but it still not good enough to do so.
  • Writing and maintaining stored procedure usually required specialized skill set that not all developers possess. This introduced the problem in both application development and maintain phase.

Stored procedure has it own advantages and disadvantages as mentioned above. Therefore when developing application, you should balance between them to choose whether to use storedprocedure or not. The following tutorial we will guide you how to leverage stored procedure in your database programming tasks with a couple of practical examples.