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

前端 未结 4 1392
遥遥无期
遥遥无期 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条回答
  •  温柔的废话
    2020-12-30 00:32

    Short answer would be if you want code to be portable, don't use stored procedures because if you will want at some point change database for example from MySQL to PostgreSQL you will have to update/port all stored procedures you have written.

    On the other hand, sometimes you can achieve better performance results using stored procedures because all that code will run by database engine. You also can make situation worse if stored procedures will be used improperly.

    I dont think that selecting country is very expensive operation. So I guess you don't have to use stored procedures for this case.

提交回复
热议问题