Performance Comparison of mysql and oracle databases connected with PHP

Source: Internet
Author: User
Performance Comparison between mysql and oracle databases using PHP:
The test uses my machine. the configuration is as follows:
CPU: C433
Memory: 128 MB
Hard disk: Cool 2 generation 20G

Test Software description:
Windows nt server4, sp5, apache 1.3.12, php3.0.15, php4rc1, mysql 3.22.29, and oracle 8.0.5 are used in WIN32.
In linux, bluepoint linux1.0, apache 1.3.12, php4rc1, and mysql 3.22.32 are used.

Test Code description:
A simple table is used. mysql and oracle use the same table structure and have 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 (16) not null,
Board_manager char (20 ),
Primary key (board_id)
);
Oracle structure:
Create table PHP_ORACLE. "BOARD"
("BOARD_ID" FLOAT,
"BOARD_NAME" CHAR (16) not null,
"BOARD_MANAGER" CHAR (20 ));

We only tested the INSERT operation time. for select, no tests were conducted.
In win32, only PHP3 can connect to the oracle Database. Therefore, only the performance of connecting oracle with PHP3 is tested. It is believed that after the official version of PHP4 is released, the speed of connecting oracle with PHP4 should be improved.
In LINUX, I only tested the performance of mysql because I didn't install oracle. It is said that in LINUX, oracle has good performance but cannot be tested.
In addition, we put all the code used for database connection and oracle to analyze SQL statements out of the statistical code. Therefore, the test only takes time to execute SQL operations.

Programs 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;
?>

Programs 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:
In WIN32, although mysql performance is not very good, it is much faster than oracle8. especially in the test program, I did not include the database connection statements, therefore, this test result only takes time to insert data, while the oracle connection is too slow! On my machine, connect once, at least 1-2 seconds. In LINUX, mysql has a great leap over WIN32. Decreases from 28 seconds to 10 seconds. Therefore, if you do not need the support of stored procedures and the database volume is not as large as that, use mysql as your database in LINUX! This lightweight database gives you the best performance, manageability, and security.

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.