times ( old version ): Sorting is done using only the row pointer and the sort field so that the result of the order can be read to all data by a row pointer, because it is random io , io low efficiency. Single read data (new version): reads the required columns first and then sorts them according to the given column.two each has its merits and demerits, this discussion we put in Chapter 8The 5.6 version has been improved here , and when limit is used,MySQL
When the data volume is very large (the table capacity reaches GB or TB), if you still use the index method to optimize the query, due to the consumption of the index and the generation of a large number of index fragments, the query process will lead to a large number of random I/O generation. In this scenario, unless the index can be well overwritten, the data table must be queried Based on the index, the
large, the my.cnf key_buffer_size should be larger. Can calculate the cache failure rate with key_reads/key_read_requests
3. If the handler_read_rnd is too large, then many of the queries in the SQL statement you write are to scan the entire table without playing the role of the index key
4. If the threads_created is too large, it is necessary to increase the value of thread_cache_size in MY.CNF. You can use Threads_created/connections to calculate
MySQL Query performance optimizationThe optimization of MySQL query performance involves many aspects, including library table structure, establishing reasonable index and reasonable query. The library table structure includes how
Tags: scenario date Another content like common is the CTO solvesA Meaning of with ASThe with as phrase, also called the subquery section (subquery factoring), allows you to do many things, defining a SQL fragment that will be used by the entire SQL statement. Sometimes it is to make the SQL statement more readable, or it may be in different parts of union all as part of providing data.Especially useful for union all. Because each part of union all may be the same, but if each part goes through
Tags: style blog http io color ar using for SPExt.: http://wudataoge.blog.163.com/blog/static/80073886200961652022389/A Meaning of with ASThe with as phrase, also called the subquery section (subquery factoring), allows you to do many things, defining a SQL fragment that will be used by the entire SQL statement. Sometimes it is to make the SQL statement more readable, or it may be in different parts of union all as part of providing data.Especially useful for union all. Because each part of unio
of each month. When it is necessary to generate a report based on data from all 12 log tables, this means that multiple table queries need to be written and updated to reflect the information in those tables.
Instead of writing these queries that may have errors, instead of merging the tables with a single query and then deleting the Mer GE table without affecting the original data, deleting the merge
Label:Today, database operations are increasingly becoming a performance bottleneck for the entire application, which is especially noticeable for web applications. It's not just about the performance of the database that DBAs need to worry about, it's something that our programmers need to focus on. When we design the database table structure, we need to pay att
table, if the increase can also be separate head portrait for a separate table (such as Baidu separate picture server)
Read and write separation:
The Web program is slow, the first test object is the database, wrote a few years of program are aware. Now you want to track down the SQL statements in MySQL that drag server
; temporary_tables)
| Write_create_table_bin_log ()
Case sqlcom_drop_table:
| If (! Lex-> drop_temporary)
| Determine whether temporarytable is explicitly written in the statement
| Mysql_rm_table ()
| Mysql_rm_table_part2 ()
| For (Table-> next_local)
| Drop_temporary_table () // find and delete from Thr-> temporarylist
| Delete an object table
In summary, we can know that the temporary
[Switch] MySql modifies the table type and mysql modifies the table
Recently, I encountered a problem about modifying the mysql table type. Previously, when phpmyadmin managed the mysql
received select statement in string mode based on the preset hash algorithm, then, go to the Query Cache to check whether the data has been cached. That is to say, if the select request is already in the cache, the data will be directly returned, thus omitting all subsequent steps (such as SQL statement parsing, optimizer optimization and Data Request to the storage engine), greatly improving performance.
Of course, Query Cache also has a fatal defec
and the version with the Google patch installed, this option can be set in microseconds. this is a great feature, because once you have eliminated all queries whose query time exceeds 1 second, the adjustment is very successful, which helps you eliminate the problem SQL before the problem increases.
3. log_queries_not_using_indexes
Enabling this option is a good idea. it actually records the query that returns all rows.
Summary
We have introduced five categories of
Today, database operations are increasingly becoming a performance bottleneck for the entire application, especially for Web applications. As for the performance of the database, this is not just something that DBAs need to worry about, and that's what we programmers need to focus on.
When we design the database table structure, we need to pay attention to the
wait for the lock ). For example:
thread 1 does 1000 insertsthread 2, 3, and 4 does 1 insertthread 5 does 1000 inserts
If you do not use the lock, 2, 3, and 4 will be completed before 1 and 5. If you use locking, 2, 3, and 4 may not be completed before 1 or 5, but the overall time should be about 40% faster. Because INSERT, UPDATE, and DELETE operations are fast in MySQL, you will get better overall performance
easy. This is useful when you know that the rows of your main query are in a certain order. By using this option, you may get a higher performance after a large change to the table.
If you use ALTER table on a MyISAM table, all non unique indexes will be created in one batch (just like REPAIR). This may make ALTER
inaccurate (for example, if the write operation fails to complete step 2, the old attribute value may be affected ). To ensure that the preceding restrictions can be used to return correct entities, we use an index table to determine which entities to read, but do not trust the integrity of the index, to filter these entities using the query conditions:
1. obtain entity_id from the index table based on the
(do not disable mysqld ).
2. after a large number of update or delete operations, we recommend that you use optimize table to OPTIMIZE the TABLE. this reduces file fragments and the probability of TABLE corruption.
3. shut down mysqld before shutting down the server (close the service normally, do not use kill-9 to kill the process ).
4. use the ups power to avo
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.