What are the benefits of creating Stored Procedures in SQL and MySQL?

前端 未结 4 1406
遥遥无期
遥遥无期 2020-12-29 23:52

I have a theoretical question.

I can\'t see any difference between declaring a function within a PHP file and creating a stored procedure in a dat

4条回答
  •  猫巷女王i
    2020-12-30 00:28

    ok, this may be a little oversimplified (and possibly incomplete):

    With a stored procedure:

    1. you do not need to transmit the query to the database
    2. the DBMS does not need to validate the query every time (validate in a sense of syntax, etc)
    3. the DBMS does not need to optimize the query every time (remember, SQL is declarative, therefore, the DBMS has to generate an optimized query execution plan)

提交回复
热议问题