Test hardware description:
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.
TestCodeNote:
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.
Used to test MySQLProgram:
<? 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;
?>
Programs 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:
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, you should use MySQL as your database in Linux! This lightweight database gives you the best performance, manageability, and security.