PHP and MSSQL - Speed
Posted: Tue Mar 23, 2010 1:14 pm
I've recently taken to creating a C# application which acts as a basic proxy server. It takes input from a client and then inputs it into the database, based on a variety of parameters.
In order to test how much latency this placed on the activities, I proposed a basic test. One of the simplest (yet most used) activities this system will be doing is registering new accounts. There is a stored procedure in the database which carries out this task. The C# application uses this stored procedure to make accounts based off the input from the socket.
The test was simple.
I created a PHP script that took in the required fields, and then created an mssql connection. I then bound the relevant fields to the parameters in the stored procedure, and executed it, thereby testing the speed of registration on a direct PHP to Database connection.
I then used the same fields, and sent them through sockets (in PHP) to the backend system, which dealt with the database connection and query.
The C# backend was .3 of a second quicker. This was pretty much the opposite of what I was expecting. The backend deals with several overheads PHP does not have to do (checking the packet is structured correctly, splitting it into individual fields, etc), yet it still finished quicker than the PHP to Database direct connection.
Am I correct in thinking that this is because the library C# uses to connect/execute MSSQL statements is more efficient than the one used in PHP/because C# is designed to use MSSQL better than PHP is? Would this simple test therefore yield different results should I use MySQL? Is there any other miscellaneous information I should know about what causes it?
Thanks for the help ^_^
In order to test how much latency this placed on the activities, I proposed a basic test. One of the simplest (yet most used) activities this system will be doing is registering new accounts. There is a stored procedure in the database which carries out this task. The C# application uses this stored procedure to make accounts based off the input from the socket.
The test was simple.
I created a PHP script that took in the required fields, and then created an mssql connection. I then bound the relevant fields to the parameters in the stored procedure, and executed it, thereby testing the speed of registration on a direct PHP to Database connection.
I then used the same fields, and sent them through sockets (in PHP) to the backend system, which dealt with the database connection and query.
The C# backend was .3 of a second quicker. This was pretty much the opposite of what I was expecting. The backend deals with several overheads PHP does not have to do (checking the packet is structured correctly, splitting it into individual fields, etc), yet it still finished quicker than the PHP to Database direct connection.
Am I correct in thinking that this is because the library C# uses to connect/execute MSSQL statements is more efficient than the one used in PHP/because C# is designed to use MSSQL better than PHP is? Would this simple test therefore yield different results should I use MySQL? Is there any other miscellaneous information I should know about what causes it?
Thanks for the help ^_^