Essential SQL query optimization techniques to speed up Website access and SQL access
In this article, I will introduce how to identify queries that cause performance problems, how to locate their problems, and how to quickly fix these problems and other methods to speed up the query.
You must know that a website with quick access can be liked by users, help web
ArticleDirectory
Create highly selective Indexes
Create multi-column Indexes
Avoid creating indexes for small tables
Use indexes with filter clauses
Create an index for the order-by/group-by/distinct column to shorten the response time
Use Outer Join for restrictions
Optimize Indexes
Creating useful indexes is one of the most important ways to improve query performance. Useful indexes can help reduce the disk I/O
words, it is "No ACCESS database is faster ", this recognition is sufficient to prevent users from using your developed system.
I have analyzed this. The crux of this problem is so simple, but so important: the sorting field is not a clustered index!
The title of this article is "query optimization and paging algorithm solution ". The author does not put together the topics of "
tool.Mysqldumpslow-s r-t 10/var/lib/mysql/localhost-slow.log | More, return the result as shown.3.1.3 Pt-query-digest ToolsMore information than the Mysqldumpslow feedback.Pg-query-digest--help View Help to view the use command.Pg-query-digest/var/lib/mysql/localhost-slow.log, the query results are as follows.The firs
meaning of the expression "specific optimizations" in the table above
Q Contrast S8 and S9, can be seen, toprowdb to S9 did not provide optimization, and PostgreSQL, MySQL can optimize, this toprowdb need to work hard
Q contrast S11, toprowdb and MySQL are stronger than PostgreSQL
In the first part of the subquery optimization, we found that MySQL's in subquery opti
Label:From: SQL Server Query performance optimization-heap table, fragmentation, and index (i) SQL Server Query performance optimization-heap table, fragmentation, and index (ii) SQL Server Query performance optimization-overwrite
) for user in user_list: print(user["username"], user["nickname"], user["job"]) return render(request,'index.html')
To run the program, print the information in the server backend:
SELECT "app01_userinfo"."username", "app01_userinfo"."nickname", "app01_userinfo"."job_id" FROM "app01_userinfo"
As you can see, the result of the query is still a user_list QuerySet , but inside this object collection is a dictionary.
A
The following articles mainly describe five useful methods for MySQL query optimization. Anyone familiar with SQL statements knows that if you want to operate a task, SQL statements can be written in many ways, but the query performance varies with different writing methods.
This article lists five MySQL query
Label:First, why the query slowNetwork, CPU calculation, generated statistics, execution technology, lock wait, io wait, etc.Second, slow query optimization access to inefficient query processing methods:
Confirm that you have accessed too many rows, or too many columns
Have you analyzed a large amount of
In-depth analysis of explain for MySQL Query optimization MySQLexplain
BitsCN.com
When analyzing query performance, it is also useful to consider the EXPLAIN keyword. The EXPLAIN keyword is generally placed before the SELECT query statement to describe how MySQL performs the query
The MySQL Query optimization program [group chart] analyzes a selection row query to see if it can be optimized to make it run faster. This article will study how the query optimization program works. For more information, see "Getting Maximum Performance from MySQL" in MySQ
[Slow query optimization] use MySQL subqueries with caution, especially when you see the DEPENDENTSUBQUERY tag bitsCN.com case study:
Preface:
I have repeatedly stressed the importance of explain in slow query optimization 1 and 2, but sometimes I cannot see how the explain results Guide
MySQL query optimization: profile function
MySQL query optimization: profile function. Note that you need to install the profile module.
1. The version is later than 5.0.37. (Show profiles and show profile were added in MySQL 5.0.37 .)
SELECT @ profiling;To check whether the profile has been enabled. If the profilng va
storing the time with a string, and storing the IP address with an integer data type. (3) Try to avoid null: The column should be specified as NOT NULL unless you want to store null. In MySQL. Columns that contain null values are very difficult to query optimization. Because they make indexes, index statistics, and comparison operations more complex. You should replace the null value with 0, a special valu
This paper summarizes and analyzes the techniques of MySQL query optimization. Share to everyone for your reference, specific as follows:
People who are familiar with SQL statements know that if you want to operate on a task, the SQL statement can have a lot of relevant writing, but different ways of writing query performance may be a great difference.
This art
Anyone familiar with SQL in MySQL's five query optimization methods knows that SQL may write a variety of statements to complete the same task, but the query performance of different statements may be quite different, this article lists five query optimization methods. of co
the operation, all of which provide favorable evidence for optimizing the query. 1th, the 3 diagram IO overhead is relatively large, the 2nd graph estimates the number of rows is larger, and then according to other information, the first thought should be to build the index, not the words to change the query.Let's take a look at what optimization information the Database Engine Tuning Advisor can give us,
Query optimization on SQL statements.
The foreground application works on the database server, and ultimately relies on the SQL statements in the application. According to incomplete statistics, SQL statements consume about 80% of the database server's resources. Therefore, how to improve the execution efficiency of SQL statements is a problem that must be considered in database
, MySQL will not log slow query How to turn on slow query: 1. Close the current MySQL service: net stop MySQL 2, start through Safe mode will write log. 3. Turn off MySQL with Safe mode activated 4, set the time of the slow query to 0.5 seconds, set long_query_time=0.5 5. Select * FROM table where xx= ' 00 '; 6, go to the slow
This article describes how to optimize MySQL database queries in three ways. We all know that during the actual MySQL query optimization process, database applications, such as MySQL (the best combination with PHP), mean the operation and use of the tool.
Using indexes, using EXPLAIN to analyze queries, and adjusting the internal configuration of MySQL (the best combination with PHP) can optimize queries.
A
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.