Home >Backend Development >PHP Tutorial >Comparison of performance of connecting mysql and oracle databases using PHP_PHP tutorial

Comparison of performance of connecting mysql and oracle databases using PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:07:22743browse

Test hardware description:
The test uses my favorite machine, the configuration is as follows:
CPU: C433
Memory: 128M
Hard drive: Barracuda 2nd generation 20G

Test software description :
Windows nt server4, sp5, apache 1.3.12, php3.0.15 and php4rc1, mysql 3.22.29, oracle 8.0.5 are used under WIN32.
Bluepoint linux1.0, apache 1.3 is used under linux. .12, php4rc1, mysql 3.22.32

Test code description:
Use a very simple table. The table structure used by mysql and oracle is the same, with 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 time spent on the INSERT operation, and did not test the select.
Because only PHP3 can connect to the Oracle database under win32, we only tested the performance of using PHP3 to connect to Oracle. I believe that after the official version of PHP4 comes out, the speed of using PHP4 to connect to Oracle should be improved.
Under LINUX, because I did not install Oracle, I only tested the performance of mysql. It is said that under LINUX, Oracle's performance is good, but it cannot be tested.
And we put all the code used for database connection and Oracle to analyze SQL statements outside the statistical code, so the time measured in the test is only the time spent executing SQL operations.

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

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 result:

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, although the performance of mysql is not very good, it is still much faster than oracle8, especially in the test program, I did not The database connection statements are included, so this test result is only the time it takes to insert data, and Oracle's connection, my God, is too slow! On my machine, it takes at least 1-2 seconds to connect once. Under LINUX, the performance of mysql has made a big leap compared to that under WIN32. Sharply reduced from 28 seconds to 10 seconds. Therefore, if you do not need the support of stored procedures, and the database size is not so large, it is better to use mysql as your database under LINUX! This lightweight database gives you the best performance, manageability, and pretty good security.​

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315105.htmlTechArticleTest hardware description: The test uses my favorite machine, the configuration is as follows: CPU: C433 Memory: 128M Hard drive: Baruyu 2nd generation 20G test software description: Windows nt server4, sp5,...
are used under WIN32
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn