MySQL performance test (index)

Source: Internet
Author: User

First, use Talend to randomly generate 10 million data:

There are now 10 million + data in the database table:

Mysql> Select Count(*) fromZhangchao;+----------+| Count(*)|+----------+| 10040005 |+----------+1Rowinch Set(2.50Sec

The time to query a record is 3.02s without indexing

Mysql> Select *  fromZhangchaowhereX="bq2i2t";+--------+--------+|X|Y|+--------+--------+|bq2i2t|Drt5mx|+--------+--------+1Rowinch Set(3.02sec) MySQL>ShowCreate TableZhangchao;+-----------+------------------------------------------------------------------------------------------------ ------------------------------------+| Table     | Create Table                                                                                                                       |+-----------+------------------------------------------------------------------------------------------------- -----------------------------------+|Zhangchao| CREATE TABLE' Zhangchao ' (' x 'varchar( -)DEFAULT NULL, ' y 'varchar( -)DEFAULT NULL) ENGINE=InnoDBDEFAULTCHARSET=Latin1|+-----------+------------------------------------------------------------------------------------------------- -----------------------------------+1Rowinch Set(0.00Sec

Creating an index for the X column of table Zhangchao takes 45.43s:

Mysql> Alter TableZhangchaoAdd Index(x); Query OK,0Rows Affected (45.43sec) Records:0Duplicates:0Warnings:0MySQL>ShowCreate TableZhangchao;+-----------+------------------------------------------------------------------------------------------------- ----------------------------------------------------+| Table     | Create Table                                                                                                                                        |+-----------+------------------------------------------------------------------------------------------------- ----------------------------------------------------+|Zhangchao| CREATE TABLE' Zhangchao ' (' x 'varchar( -)DEFAULT NULL, ' y 'varchar( -)DEFAULT NULL,  KEY' x ' (' X ')) ENGINE=InnoDBDEFAULTCHARSET=Latin1|+-----------+------------------------------------------------------------------------------------------------- ----------------------------------------------------+1Rowinch Set(0.00Sec

In executing the same query, the time is 0.09s:

Mysql> Select *  fromZhangchaowhereX="bq2i2t";+--------+--------+|X|Y|+--------+--------+|bq2i2t|Drt5mx|+--------+--------+1Rowinch Set(0.09Sec

and non-indexed performance differences: 3.02/0.09 = 33.555 times times

MySQL performance test (index)

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.