Question : Slow ODBC connection from PHP through IIS to Sql Sever 2005

I am having some difficulty locating the cause of php webpages loading slowly through IIS. The php code uses several select statements with no joins. I think I have isolated the problem to communication with sql server from the php odbc connection. It seems some others have had similar issues so I have tried the following: changing the output buffering in php to On (it was previously on, but at 4096), and trying to pass odbc_connect different pointer types(this did show a small speed improvement, but nothing significant).

We have tried 2 different sql servers, and both remain at 50% cpu utilization for 20 to 30 minutes while the webpage loads. It does eventually load, but it seems to be taking quite a lot of time. The IIS server never goes about 5%, so this leads me to believe that the sql server is not responding as fast as I would like.

I would like to avoid changing from odbc to some other connection method since I have written all of my php using odbc functions. Below is the connection string I use to connect to sql from php(I used tried SQL_CUR_USE_ODBC but this caused some problems with the odbc_fetch_row() function )

An additional piece of information (I am using port 5050 on IIS, instead of 80(we currently have another website running on 80), but I can see no reason why this should effect the connection to sql)

Thanks in advance for the help.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
function connect(){
 
$connection_string = 'DRIVER={SQL Server};SERVER=[server name];DATABASE=[database name]'; 
 
$user = 'xxx'; 
$pass = 'xxxxx'; 
 
$connection = odbc_connect( $connection_string, $user, $pass,SQL_CUR_USE_DRIVER );
 
return $connection;
 
}

Answer : Slow ODBC connection from PHP through IIS to Sql Sever 2005

I think it's not really a problem, you are using SQL server from MS, which allows and supports the use of subqueries.

SELECT Card_number,Program_name ,
(SELECT sum(amount) as t_amount FROM transactions WHERE card_number LIKE Cardholders_table.number) AS Due_amount
FROM Cardholders_table

You can mimic the if then else with CASE and END CASE in SQL. It should be doable.
Random Solutions  
 
programming4us programming4us