The following are brief descriptions of the advantages and disadvantages of the stored procedures by point:
Introduction to Stored Procedures
A stored procedure is a set of SQL statements that are compiled and stored in a database in order to accomplish a specific function. The user executes it by specifying the name of the stored procedure and giving the parameter (if the stored procedure has parameters).
Stored procedures can be executed by the application through a call, and the user is allowed to declare variables. At the same time, a stored procedure can receive and output parameters, return a state value that executes a stored procedure, or nest calls.
Advantages:
1. Reduce the amount of network traffic. Calling a stored procedure with a low number of rows may not be very different from the network traffic that calls the SQL statement directly, but if the stored procedure contains hundreds of rows of SQL statements, the performance is definitely much higher than a single call to the SQL statement.
2, the execution speed is faster. When the stored procedure is created, the database has been parsed and optimized once. Second, once the stored procedure is executed, a copy of the stored procedure is kept in memory so that the next time the same stored procedure is executed, it can be read directly from memory.
3, stronger security. Stored procedures provide access to specific data and improve code security, such as preventing SQL injection, by granting permissions to users, rather than table-based.
Disadvantages:
1, portability: When migrating from one database to another, many of the stored procedures are written to be partially modified.
2, stored procedures need to spend a certain amount of study time to learn
Stored procedures for MySQL