Table "CREATE TABLE ' goods ' (
' id ' int (one) not NULL auto_increment,
' Name ' varchar (not NULL COMMENT '?? '),
' Dateline ' int (ten) is not NULL,
PRIMARY KEY (' id ')
) Engine=myisam auto_increment=2451249 DEFAULT Charset=utf8
Test the environment on the same server.
Golang:beego Frame
Php:yii Frame
Golang:
Stmtins,err: = db. Prepare ("INSERT into goods values (?,?,?)") For I: = 0;i<=1000000;i++ { _,err = stmtins.exec (Nil, "ddd", time. Now (). Unix ()) if err! = Nil { panic (err). Error ()) } }
Php:
for ($i= 0; $i<=1000000; $i+ +) {$ttime() ; $sql = "INSERT into goods values (NULL, ' dddd ',$t)"; if (Yii::app ()->db_test->createcommand ($sql)->query ()) Echo "1"; }
Each 100,000-wheel insert table is recorded separately (ID is the table self-increment ID).
Go beego:
8.800196552s id:1-100000
11.11174997s id:200001-300000
14.917775043s
14.736186824s
15.600297382s
18.168707698s id1000000-1100000
PHP Yii
18s id:100001-200000
17s id:300001-400000
16s id:1100000-1200000
First go faster than PHP 9s, the back of PHP faster than the 2s look.
Insert 1 million time overhead separately from the empty table:
Go
1m26.883778465s First time 100W bar
1m27.344121961s Secondary 100W ID 100w-200w
Php:
2m78.8433s First time 100W bar
2m70.77s id200w-300w
The go language takes more time and PHP spends less time on why data is being appended. Why?!
Go and PHP compare the insert speed of MySQL