Using PHP with MySQL and Oracle database performance Comparison _php Foundation

Source: Internet
Author: User
Test hardware Instructions:
The test used is my love machine, configured as follows:
cpu:c433
Memory: 128M
Hard drive: Cool fish 2 generation 20G

Test Software Description:
WIN32 is under Windows NT Server4,sp5,apache 1.3.12,php3.0.15 and Php4rc1,mysql 3.22.29,oracle 8.0.5
Linux is Bluepoint linux1.0, Apache 1.3.12, Php4rc1,mysql 3.22.32

Test Code Description:
Using a very simple table, MySQL and Oracle use the same table structure, there are only three fields, the structure is as follows:
MySQL table structure:
CREATE TABLE Board (
board_id smallint (6) not NULL auto_increment,
Board_name char (not NULL),
Board_manager Char (20),
PRIMARY KEY (board_id)
);
Structure of Oracle:
CREATE TABLE php_oracle. " BOARD "
("board_id" FLOAT,
' Board_name ' CHAR (not NULL),
"Board_manager" CHAR (20));

We only tested the time it took for the insert operation and did not test for select.
Because only PHP3 can connect to Oracle databases under Win32, the performance of connecting Oracle with PHP3 is only tested. It is believed that when the official version of PHP4 comes out, the speed of connecting Oracle with PHP4 should be improved.
But under Linux, because I did not install Oracle, I only tested MySQL performance. Oracle is said to perform well under Linux, but it is impossible to test.
And we put all the code for the database connection and Oracle parsing SQL statements out of the statistical code, so the test time is just the time it takes to execute the SQL operation.

The program used to test MySQL:

<?php
$dblink =mysql_connect ("localhost", "root", "shh123");
mysql_select_db ("BBS");
$counter = 1;
Set_time_limit (300);
$query = "INSERT INTO board (Board_name,board_manager) VALUES (' Test ', ' Test ')";
$begin _time=time ();
For ($i =1 $i <=10000; $i + +) {
Mysql_db_query ("BBS", $query);
$counter + +;
}
$end _time=time ();
Mysql_close ($dblink);
echo "Test db speed...<br>";
echo "Begin Time:". $begin _time. " <BR> ";
echo "<br>end time:". $end _time. " <BR> ";
$total = $end _time-$begin _time;
echo "Total spent time:". $total;
?>

The program used to test Oracle:

<?php
$handle =ocilogon ("Php_oracle", "php_oracle");

$counter = 1;
Set_time_limit (300);
$query = "INSERT INTO board (Board_id,board_name,board_manager) VALUES (: board_id, ' Test ', ' Test ')";
$state =ociparse ($handle, $query);
Ocibindbyname ($state, ": board_id", & $i, 32);
$begin _time=time ();
For ($i =1 $i <=10000; $i + +) {
Ociexecute ($state);
}
$end _time=time ();
Ocifreestatement ($state);
Ocilogoff ($handle);
echo "Test db speed...<br>";
echo "Begin Time:". $begin _time. " <BR> ";
echo "<br>end time:". $end _time. " <BR> ";
$total = $end _time-$begin _time;
echo "Total spent time:". $total;
?>

Test results:

Environment: Win32+apache+php4+mysql
Result: 28 seconds

Environment: Win32+apache+php3+mysql
Result: 34 seconds

Environment: win32+apache+php3+oracle8.0.5 (OCI function)
Result: 46 seconds

Environment: Linux+apache+php4+mysql
Result: 10 seconds

Conclusion:
Under WIN32, MySQL's performance is not very good, but it's a lot quicker than oracle8, especially when I'm in a test program and don't include a database connection, so this test result is just the time it takes to insert the data, and Oracle's connection, days, too slow! On my machine, connect once, at least 1-2 seconds. And in Linux, MySQL performance compared to the WIN32, and has a big leap. Reduced from 28 seconds to 10 seconds. So, if you don't need the support of stored procedures, and the database is not large enough to be so amazing, or use MySQL under Linux as your database! This lightweight database gives you the best performance, manageability, and pretty good security.
Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.