[Discussion] Advantages and disadvantages of using stored procedures in php + mysql

Source: Internet
Author: User
[Discussion] let's talk about the advantages and disadvantages of using stored procedures in php + mysql. I have never seen some open-source systems in projects, and I have never used stored procedures as SQL & nbsp; is it necessary to use the stored procedure in the php project; this reduces the pressure on web servers. For more information, see the advantages and disadvantages of using stored procedures in php and mysql.
Never used in projects
I have read some open-source systems and have never used stored procedures.
SQL statement execution
Is it necessary to use stored procedures in php projects?
Using Stored procedures should increase the speed and reduce the pressure on web servers
But it also increases the load on database servers.
For more experienced students
Let's discuss it together.
------ Solution --------------------
It is not very useful. Since this function is available, use it. The only explanation is to avoid repeated SQL statements.
------ Solution --------------------
I have read some open-source systems and have never used stored procedures. they all run SQL statements one by one.

Not all databases support stored procedures, such as mysql4.
In addition, the syntax for stored procedures varies with different databases.


Is it necessary to use stored procedures in php projects?

Stored procedures can greatly improve the efficiency of algorithms. if possible, use them.

Using Stored procedures should increase the speed and reduce the pressure on web servers

This is inevitable

But it also increases the load on database servers.

This understanding is wrong. do SQL statements executed in one line require no database server overhead?



------ Solution --------------------
The project has been using the stored procedure,

Relatively easy to maintain
------ Solution --------------------
With memcache and static pages, the stored procedure becomes a weakness,

The storage process is not bad, it is difficult to modify, especially the dynamic script. it is easy to change and import the database,

Otherwise, now everyone writes the stored procedure and does not write SQL query statements.
------ Solution --------------------
Reference:
I have read some open-source systems and have never used stored procedures. they all run SQL statements one by one.

Not all databases support stored procedures, such as mysql4.
In addition, the syntax for stored procedures varies with different databases.


Is it necessary to use stored procedures in php projects?

Stored procedures can greatly improve the efficiency of algorithms. if possible, use them.

Using Stored procedures should increase the speed and reduce the pressure on web servers

This is inevitable

But at the same time, the number is increased ......



They all have overhead, but they are different:


Functions are better than php built-in functions, which are different from external functions,
The usage is better than the difference between the compilation language and the interpretation language.


Especially in the Agile development era, in order to improve performance,
If you modify the compilation once and modify the compilation once, you don't know where to start with these overhead.





------ Solution --------------------
First, check whether the operations on your project database are complex, and whether developers are familiar with database programming.

The stored procedure itself improves performance, but it is small for simple projects.

In addition, you can use the advantages of stored procedures to encapsulate transactions. of course, it is based on complicated operations.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.