Compare MySQL and Oracle database performance with PHP _php tutorial

Source: Internet
Author: User
Test Hardware Description:
The test is using my Love machine, configured as follows:
cpu:c433
Memory: 128M
HDD: Cool fish 2 generation 20G

Test Software Description:
WIN32 under Windows NT Server4,sp5,apache 1.3.12,php3.0.15 and Php4rc1,mysql 3.22.29,oracle 8.0.5
Linux under the 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, with only three fields, with the following structure:
MySQL table structure:
CREATE TABLE Board (
board_id smallint (6) not NULL auto_increment,
Board_name char (+) is not NULL,
Board_manager Char (20),
PRIMARY KEY (board_id)
);
Structure of Oracle:
CREATE TABLE php_oracle. " BOARD "
("board_id" FLOAT,
"Board_name" CHAR (+) is not NULL,
"Board_manager" CHAR (20));

We only tested the time that the insert operation took, and for select, it was not tested.
Because only PHP3 can connect to the Oracle database under Win32, only the performance of connecting to Oracle with PHP3 is tested. It is believed that the speed of connecting Oracle with PHP4 should be improved after the official version of PHP4.
And under Linux, because I didn't have Oracle installed, I only tested MySQL's performance. It is said that under Linux, Oracle has a good performance, but cannot be tested.
And we put all the code for the database connection and Oracle to parse the SQL statements out of the statistics code, so the time to test is just the time spent executing the SQL operation.

The program used to test MySQL:

$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 ...
";
echo "Begin Time:" $begin _time. "
";
echo "
End time: ". $end _time."
";
$total = $end _time-$begin _time;
echo "Total spent time:" $total;
?>

The program used to test Oracle:

$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 ...
";
echo "Begin Time:" $begin _time. "
";
echo "
End time: ". $end _time."
";
$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 performance is not very good, but compared with Oracle8, still much faster, especially I in the test program, and did not include the database connection statements, so this test result is only the time spent inserting data, and Oracle's connection, days, too slow! On my machine, connect once, for at least 1-2 seconds. And in Linux, MySQL performance relative to under the WIN32, there is a big leap. Reduced from 28 seconds to 10 seconds. So, if you do not need the support of the stored procedures, and the amount of database is not big so amazing, or Linux under the use of MySQL as your database it! This lightweight database can give you the best performance, manageability, and pretty good security.

http://www.bkjia.com/PHPjc/315105.html www.bkjia.com true http://www.bkjia.com/PHPjc/315105.html techarticle Test Hardware Description: The test is using my Love machine, configured as follows: cpu:c433 memory: 128M HDD: Cool fish 2 generation 20G test Software Description: WIN32 under Windows NT SERVER4,SP5,...

  • 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.