Home >Backend Development >PHP Tutorial >How to record the use of mysql performance query process_PHP tutorial
It all started from an experiment, please see the example below:
Table:
I inserted 300,000 data into two tables (the performance difference during insertion is that InnoDB is slower than MyISAM)
One query can make so much difference! ! InnoDB and MyISAM, quickly analyze why.
First use explain to view
Make sure that no index is used on both sides. The rows queried in the second query, and the query rows of MyISAM are much less than those of InnoDB. On the contrary, the query is slower than InnoDB! ! This Y is a bit strange.
No problem, there is another awesome tool profile
For specific usage, please refer to: http://dev.mysql.com/doc/refman/5.0/en/show-profile.html
How to use it in simple terms:
http://dev.mysql.com/doc/refman/5.0/en/general-thread-states.html
Sending data
The thread is reading and processing rows for a SELECT statement, and sending data to the client. Because operations occurring during this this state tend to perform large amounts of disk access (reads), it is often the longest-running state over the lifetime of a given query.
Sending data is to read the result of the selection from the disk, and then return the result to the client. This process will involve a large number of IO operations. You can use show profile cpu for query XX; to check and find that MyISAM's CPU_system is much larger than InnnoDB. At this point it can be concluded that MyISAM is slower than InnoDB for table queries (different from queries that can be completed using only indexes).