Home > Backend Development > PHP Tutorial > PHP connection performance comparison between mysql and oracle database_PHP tutorial

PHP connection performance comparison between mysql and oracle database_PHP tutorial

WBOY
Release: 2016-07-20 11:06:24
Original
899 people have browsed it

Use a very simple table. The table structure used by mysql and oracle is the same. Both 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 test The time spent on the INSERT operation was measured, and the select was not tested.
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, the performance of oracle
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 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, although the performance of mysql is not very good, it is still much faster than oracle8, especially in my
test program, I did not include the database connection statement. Come in, so this test result is only the time it takes to insert data, and the oracle 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. Dropped from 28 seconds to 10 seconds.
So, if you don’t need the support of stored procedures, and the database size is not that huge, you should use mysql as your database under LINUX
! This lightweight database gives you optimal performance, manageability, and
pretty good security.


http://www.bkjia.com/PHPjc/445031.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445031.htmlTechArticleUse 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)...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template