Solution for slow connection to database (sqlserver2000) after php4 is upgraded to 5
Source: Internet
Author: User
After upgrading php4 to 5, connect to the database (sqlserver2000) to slow down the system environment & nbsp; windows2000serversqlserver2000 (installed on another machine) apache1.3.X (changed to apache2.2) php5.2.8 (previously used 4. after the upgrade, it is found that the connection to the database is slow (more than 2 seconds). after the other code php4 is upgraded to 5, the connection to the database (sqlserver2000) is slow.
System environment
Windows2000 server
Sqlserver 2000 (mounted on another machine)
Apache 1.3.X (same for apache2.2)
Php 5.2.8 (very fast in the past when I used 4. X)
After the upgrade, it is found that the database connection time is slow (more than 2 seconds)
Other code is fast
Because it is a local LAN access, there is basically no latency, so these two seconds are very obvious.
============
Test Code
This will slow down (the database itself is no problem. if PHP4 is used, the latency will not be felt)
Echo "hello ";
$ Server = "12.34.56.78 ";
$ Username = "uu ";
$ Password = "pp ";
$ Cnn = mssql_connect ($ server, $ username, $ password );
Mssql_select_db ('mydb', $ cnn );
Echo "hello ";
Phpinfo ();
==========
If only
Echo "hello ";
Phpinfo ();
It was very fast, so I decided it would take longer to connect to the database.
------ Solution --------------------
Sqlserver2000 is very old, and php5.2.8 is much younger. Haha, there is something wrong with the combination. if you think it is slow, change the database version or PHP version.
Of course, if there are conditions, you can consider using the same PHP version and database version for testing on other machines to see if the same problem exists.
------ Solution --------------------
% ......
------ Solution --------------------
Reference the post of the poster carpenter01:
System environment
Windows2000 server
Sqlserver 2000 (mounted on another machine)
Apache 1.3.X (same for apache2.2)
Php 5.2.8 (very fast in the past when I used 4. X)
After the upgrade, it is found that the database connection time is slow (more than 2 seconds)
Other code is fast
Because it is a local LAN access, there is basically no latency, so these two seconds are very obvious.
============
Test Code
This will slow down (the database itself is no problem. if PHP4 is used, the latency will not be felt)
Echo "hello ";
$ Server = "12.34.56.78 ";
$ Username = "uu ";
$ P...
------ Solution --------------------
Discussion
Reference:
Database connection is time-consuming,
The zend Engine of PHP5 is significantly different from that of php4,
The code you connect to every request is not fast.
We recommend that you do not upgrade the server as needed. it is best to return to php4.x.
I don't quite understand. how can I reduce the number of times I connect to the database?
In addition, I tested the installation of php5 on other machines and it was not slow. I cannot find the reason.
------ Solution --------------------
Come in and share
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