like ' a% '", one is built index, one is no index, performance is about 4 times times worse.In addition, you should also need to know what kind of search is not able to use the normal index. For example, when you need to search for a word in a large article, such as: "WHERE post_content like '%apple% '", the index may be meaningless. You may need to use a MySQL full-text index or make an index yourself (sa
restriction, that is, the commodity item_id in the big table is only part of all item_id. If the commodity item_id in the big table almost evenly covers all the item_id, then the run time is almost the same regardless of which table index is used for the join. This was overlooked when the experiment was done and the problem was discovered when we tried again. I hereby Add. Summary: Here are two questions, one is to add the index when you need to thi
complex one with multi-table join) and add the keyword "EXPLAIN" to the front. You can use phpmyadmin to do this. Then, you will see a table. In the following example, we forget to add the group_id index and have table join: ww.phperz.com
After adding an index to the group_id field:
We can see that the previous result shows that 7883 rows are searched, and the last one only searches 9 and 16 rows of two ta
data tables are searched and sorted ...... And so on.
SELECT one of your SELECT statements (we recommend that you SELECT the most complex one with multi-table join) and add the keyword "EXPLAIN" to the front. You can use phpmyadmin to do this. Then, you will see a table. In the following example, we forget to add the group_id index and have table join:
After adding an index to the group_id field:
We can se
may find that MyISAM is faster than InnoDB because MyISAM only caches indexes, while InnoDB caches data and indexes. MyISAM does not support transactions. However, if you use innodb_flush_log_at_trx_commit = 2, you can achieve close read performance (a hundred times different ).1.1 How to convert an existing MyISAM database to InnoDB:
mysql -u [USER_NAME] -p -e "SHOW TABLES IN [DATABASE_NAME];" | tail -n +
Tags: simple range description File value Temp ONS Group Select1. Performance analysis of profiling
MySQL5. Version 0.37 supports the profiling– official manual. This tool can be used to query how much time SQL executes, how much timeSystem lock and table lock spend, and so on, whichis important for locating i/o consumption and CPU consumption of a statement.View profiling;SELECT @ @profiling;
Start profiling:
set @ @profiling=1
off profiling:
set
data tables are searched and sorted ...... And so on.
SELECT one of your SELECT statements (we recommend that you SELECT the most complex one with multi-table join) and add the keyword "EXPLAIN" to the front. You can use phpmyadmin to do this. Then, you will see a table. In the following example, we forget to add the group_id index and have table join:
After adding an index to the group_id field:
We can s
work for this function. Therefore, SQL functions such as now () and RAND () or whatever, do not turn on the query cache because the return of these functions is variable. So all you need to do is use a variable instead of the MySQL function to turn on the cache. 2. EXPLAIN your SELECT query Use the EXPLAIN keyword to let you know how MySQL handles your SQL statements. This can help you analyze the
IntroductionMySQL is currently one of the most widely used relational database, if used properly, can support enterprise-class high concurrency, high-reliability services, improper use and even a slightly higher level of personal sites are difficult to support;Even with the use of cache, a large number of database access is still unavoidable, even if the long cache expiration date, and the cache hit ratio is ideal, but 缓存的创建 and 过期后的重建 all need to access the database;This article mainly from the
database.
2. Use a connection (join) to replace a subquery (sub-queries)MySQL supports SQL subquery starting with 4.1. This technique can use a SELECT statement to create a single column of query results, and then use the result as a filter condition in another query. For example, to delete a customer with no orders
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 attention to the
OracleSQL performance optimization (1) select the most efficient table name sequence (only valid in the rule-based optimizer ): the ORACLE parser processes the table names in the FROM clause in the order FROM right to left. The table written in the FROM clause (basic table drivingtable) will be optimized by Oracle SQL performance.
(1)Select the most efficient table name sequence (valid only in the rule-base
1. IntroductionIn the Web application architecture, the data persistence layer (usually a relational database) is a key core part that has a very important impact on the performance of the system. MySQL is currently the most used open source database, but the MySQL database default settings performance is very poor, ju
; set global log_queries_not_using_indexes=on;Query OK, 0 rows Affected (0.00 sec)SQL that executes longer than n seconds is loggedMysql> Show variables like '%long_query% ';+-----------------+-----------+| variable_name | Value |+-----------------+-----------+| Long_query_time | 10.000000 |+-----------------+-----------+1 row in Set (0.00 sec)mysql> set global long_query_time=1;Query OK, 0 rows Affected (0.00 sec)GROUP BY Statement optimizationBefore
) Equal delivery. Large in table causes slower optimizations (5) Parallel execution. Cannot execute a query in multiple CPUs in parallel (6) For the same table select and update Write an efficient queryReasons for low query efficiency: (1) The application gets more data than needed (2) MySQL server analyzes more rows than needed How to refactor the query: (1) The tradeoff between complex queries and multiple queries. It is sometimes wrong to do as muc
| Value |+---------------+-----------+| Select_scan | 116037811 |+---------------+-----------+1 row in Set (0.00 sec)Select_scan represents the number of connections scanned for the first table, and if each row in the first table participates in the join, the result is not a problem; If you don't want to return all rows but don't use the index to find the rows you want, the count is awful.14 Slow QueryMysql> show global status like ' Slow_queries ';+
frequent opening or closing of the descriptor (performance impact, default: 2000) read_buffer_size = 512 K # size of the Mysql read buffer. A read buffer is allocated for requests that perform sequential scans on the table. Mysql allocates a buffer to the table. The default value is 128 kb, this parameter is allocated per Thread) read_rnd_buffer_size = 512 K # l
MySQL uses multithreading to improve query performance. The crux of the problem is that it can only be executed in a single thread. This solution provides a Multi-thread-query engine for MySQL to use
MySQL uses multithreading to improve query performance. The crux of the pro
Tags: inner strong BSP SQL performance Col span mysq from1.in and not in sub-query optimizations Not in is not a hit index, so the following subquery performance is low. If it is a deterministic and limited collection , you can use it. such as in (0,1,2). Replace with exists or notexists select * test1 where exists (select * from test2 "where id2 = I
Mysql Performance Optimization tutorial bitsCN.com: understanding why data Indexing improves efficiency
The storage of data indexes is ordered.
In order, you do not need to traverse index records when querying a data through an index.
In extreme cases, the query efficiency of data indexes is the binary query efficiency, which is close to that of log2 (N)How to understand the data index structure
By default,
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.