In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what are the advantages of sorting in PHP". In daily operations, I believe that many people have doubts about the advantages of sorting in PHP. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "what are the advantages of sorting in PHP?" Next, please follow the editor to study!
What are the advantages of PHP over MySQL
1. Considering the scalability and overall performance of the whole website, sorting in the application layer (PHP) will obviously reduce the load of the database, thus improving the scalability of the whole website. In fact, the cost of database sorting is very high, which consumes memory and CPU. If there are a lot of concurrent sorting, DB can easily reach the bottleneck.
2. If there is still a data intermediate layer between the application layer (PHP) and MYSQL, PHP will have better benefits if it is used reasonably.
3. The in-memory data structure of PHP is specially designed for specific applications, which is more concise and efficient than the database.
4. PHP does not need to consider the problem of data disaster recovery, so it can reduce the operation loss in this part.
5. There is no table locking problem in PHP.
6. Sorting, request and result return in MySQL also need to be carried out through a network connection, while sorting in PHP can be returned directly, reducing the network IO.
As for execution speed, the difference should not be great, unless there is something wrong with the application design, resulting in a large number of unnecessary network IO. In addition, the application layer should pay attention to the Cache setting of PHP. If the error is exceeded, an internal error will be reported. At this time, the application should be evaluated or the Cache should be adjusted. The specific choice will depend on the specific application.
List some instances that must be sorted in MySQL:
1. This sorted index already exists in MySQL
2. The amount of data in MySQL is large, and the result set needs a very small subset; for example, take 1000000 rows of data, take TOP10
3. In the case of one sort and multiple calls, such as statistical aggregation, which can be provided to different services, sorting is preferred in MySQL. In addition, for deep data mining, the usual method is to finish sorting and other complex operations in the application layer, and store the results in MySQL, which is convenient for multiple uses.
4. No matter where the data source comes from, when the amount of data is large to a certain scale, it is no longer suitable for sorting in PHP because of memory / Cache. At this time, copying, importing or storing MySQL and optimizing it with INDEX is better than PHP. However, it is better to use Java or even C++ to handle such operations. Some data like big data aggregates or aggregates, but the loss outweighs the gain in client-side sorting. Of course, there are similar search engine ideas to solve similar applications.
From the overall consideration of the website, manpower and cost must be taken into consideration. If the size and load of the website is small, and the manpower is limited (the number and capacity may be limited), sorting at the application layer (PHP) requires a lot of development and debugging work, which takes time and outweighs the loss; it is better to deal with it in DB, which is simple and fast. For large-scale websites, the cost of power and server is very high, and careful calculation in the system architecture can save a lot of costs, which is necessary for the sustainable development of the company; at this time, if you can sort at the application layer (PHP) and meet the business needs, try to do it at the application layer.
What are the advantages of performing sorting in PHP
1. The data source is not in MySQL, and there are hard drives, memory or requests from the network.
2. The data is stored in MySQL, the amount is small, and there is no corresponding index, so it is faster to sort the data with PHP.
3. The data source comes from multiple MySQL servers, so it is faster to extract data from multiple MySQL and sort it in PHP.
4. In addition to MySQL, there are other data sources, such as hard disk, memory or requests from the network, so it is not appropriate to store these data in MySQL and then sort them.
At this point, the study on "what are the advantages of sorting in PHP" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.