Using MYSQL for computation and PHP for computation, which of the following are some useful functions. Whether to write the & nbsp; Operation directly in the & nbsp; SQL & nbsp; statement, or extract data from & nbsp; MYSQL & nbsp; and then use & nbsp; which of the following solutions is better for PHP & nbsp; function operations? Which of the following is the best choice for MYSQL and PHP?
MYSQL also has some practical functions.
Is it better to write the operation directly in an SQL statement, or use the PHP function to perform the operation after extracting data from MYSQL? which solution is better?
Please explain in detail. Based on your own experience.
------ Solution --------------------
Mysql is the most vulnerable to performance pressure improvement. therefore, try to reduce the pressure on mysql ~
Reference:
Manually reduce operations in SQL to improve performance
------ Solution --------------------
In some special cases, it is better to put the data in the db for calculation. for example, php needs to retrieve a large amount of data first, and then filter the data by 90%, leaving only 10%. In this case, if the database can be filtered, the bandwidth occupied by data transmission will be reduced.
However, from the perspective of server load balancer, the number of web servers is usually higher than that of db servers, and db servers also have master nodes, but the number of db servers is no larger than that of web servers.
Therefore, putting computing on the web server can better balance the performance consumption caused by these calculations. Db only reads and writes data and uses transactions to ensure data consistency.
Web1 web2 web3 webn...
\\//
Db1 (master) db2 (master)
The specific situation should be analyzed in detail. there is no absolute thing, but it is better to put it on the web side for computing in most cases.
------ Solution --------------------
Php is better.
Because php is easy to scale horizontally
Mysql is not necessarily