This article analyzes the reasons for the slow speed of opening a PHP + MySQL website. if you have any need, you can refer to it to improve the speed of website access. 1,Unreasonable database table structureWhen creating a mysql database table, you can set the fields that are frequently used as query conditions as indexes, which improves the data query speed and the website opening speed. 2,The database query statement is unreasonable.PHP + MySQL **, which is often used for database select operations. When using the select operation, do not use select * from tablename easily because the query speed is slow and takes up a large amount of memory, which affects the overall running speed of the PHP program, this affects the website opening speed. We recommend that you use a select query statement for specific fields, such as select fieldname from tablename. This query method reduces MySQL execution time and improves efficiency. 3,PHP program redundancyWhen you build a PHP + MySQL website, you will find that some programs have a lot of redundancy, which prolongs the program execution time. For example, repeated SQL query operations and repeated variable assignments. In this case, it is best to ask a professional to help you optimize the program and improve the overall running time of the program. 4,PHP program reads and writes a large number of disksThe PHP + MySQL website program will perform a large number of disk read and write operations, especially disk write operations, will occupy a large number of disk IO, resulting in slow program running. In severe cases, the server will crash. In this case, you should minimize unnecessary disk write operations and optimize the disks, such as disk arrangement, to improve the overall operating efficiency of the disks. 5,Try to use static pagesWhen using PHP + MySQL to build a website, try to use open-source programs that can generate static pages, such as DEDECMS. The time for opening a static page is much less than the time for opening a dynamic page, because the static page does not have the four reasons mentioned above. However, it will consume a lot of disk space, because the generated static page will occupy a lot of disk space. 6,A large number of images or flash files exist on the webpage.When a large number of images or flash files exist on the webpage, the website opening speed may also be affected. Reduce the size of images or flash files on the webpage, or reduce the size of images to increase the speed of opening the webpage. 7,Server softwareI met a friend who installed several firewalls on the VPS. the VPS server is secure, but the webpage is very slow. Do not install unnecessary software on VPS or independent servers as much as possible to prevent slow server running and slow website opening. 8,There are a lot of JS code on the webpageA large amount of JS code is also an important cause of slow website opening. in particular, some unknown alliance advertisement codes have a significant impact on the website opening speed. 9,Too many references to other website contentThis includes referencing images and video files from other websites. if you reference other websites directly on the page, but the website is slow to open, or the website does not exist, the open speed will be very slow. That's all. you can analyze your own programs to see what causes the website to slow down. |