Go and PHP compare the insert speed of MySQL

Source: Internet
Author: User
Tags php compare yii

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

Related Article

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.