MySQL Optimization-query and mysql Optimization
Reprinted please indicate the source: http://blog.csdn.net/l1028386804/article/details/46580589
Basic select syntax in MySQL
Select attribute list from Table Name and View list [where condition expression] [group by attribute name [having condition expression] [order by attribute name [asc | desc] [limit
Note:
Wh
Summary of the practical methods for optimizing SQL query statements, and the practical use of SQL query statements
Optimization of query statements is a way to optimize SQL efficiency.
SQL statement and database optimization, SQL statement database Optimization1. Unified SQL statement writing
For the following two SQL statements, the programmer thinks they are the same and the database query optimizer thinks the
server, then check the schema of the query, SQL and index structure, determine if there are too many queries scanned, whether to do a lot of extra sort or use a temporary table, whether the use of random I /o accesses the data, or too many tables query the operations of the columns that are not in the index.Query designWhen the
SQL statement Optimization principles, SQL statement optimization
Ways to improve query speed with data above millions:
1. Try to avoid using the! = or 2. To optimize the query, avoid full-table scanning as far as possible, and
Tags: HTML count Implementation principle Ora query own Group BY column SQL optimizationReprint: http://wulijun.github.io/2012/08/24/mysql-sql-optimization.html
Optimize your Goals
Reducing IO times IO is always the most vulnerable to the database, which is determined by the responsibility of the database, most of the database operations m
waiting lock time, the total number of result rows, and the total number of rows scanned. Count, the number of executions of SQL and the percentage of total slow log count. Time, execution times, including total time, average time, minimum, maximum time, and percentage of total slow SQL time. 95% of time, removing the fastest and slowest SQL, coverage accounted
Reducing the number of subqueriesReducing the number of subqueries can reduce unnecessary performance consumption. Take a look at the following simple examples here.Select name from the employee WHERE (salary, age) = (select Max (Salary), MAX (age) from employee_details) and dept = ' Electr Onics 'Replace the following statementSelect name from Employeewhere salary = (select Max (Salary) from employee_details) and age = (select Max (age) from Employe e_details) and emp_dept = ' Electronics 'Fre
Tags: NTS Code association private ASC try Cal except slaveOrder Paged Query: The old code executes the query data sequentially and calculates the total number of records, but if the conditions are complex (such as the associated child table), the time to query is more than 20s Public StaticPagedlistQuery (itemplateservice service, Identity tenantId, Iden
MySQL Query Optimization: connection query sorting limit (join, orderby, limit statement) introduces bitsCN.com. I don't know if anyone has encountered such a disgusting problem: two tables are connected for query and limit, SQL efficiency is very high, but after order by is
Several Methods for SQL optimization and SQL Optimization
Database three paradigm
A general understanding of the three paradigms is of great benefit to database design. In database design, in order to better apply the three paradigms, the three paradigms must be understood in a general sense (the general understanding
MySQL Query Optimization: Use a subquery instead of a non-primary key to connect to the query instance to introduce bitsCN.com one-to-many two tables. Generally, the foreign key of one table is associated with the primary key of another table. However, there are also some unusual situations, that is, two tables are not joined by the primary key of one of the tabl
MySQL Query Optimization: connection query sorting
This is the case: there are two tables, team table and people Table. each people belongs to a team and there is a field team_id in people.
The following table creation statement is provided:
Create table t_team(Id int primary key,Tname varchar (100));
Create table t_people(Id int primary key,Pname varchiar (100 )
IO volume of the two will be significantly different.4.order by must have a sort operationWe know that the index data is actually orderly, and if the data we need is consistent with the order of an index, and our query is executed by this index, then the database will generally omit the sort operation and return the data directly, because the database knows that the data has already met our sorting requirements.In fact, using indexes to optimize
following is the optimization of the SQL statement in fact, SQL is not complex, but the data of these tables are slightly larger, but also nested inside more complex business logic, history after several rounds of "master" in the index of the whole side of the optimization, can also run normally but over time, the amo
member table and one distributed partitioned view on each server. The location of the data is transparent to the application.11. Rebuild the index DBCC REINDEX, DBCC INDEXDEFRAG, shrink data and log DBCC SHRINKDB,DBCC shrinkfile. Sets the auto-shrink log. For large databases do not set the database autogrow, it will degrade the performance of the server. There's a lot of emphasis on T-SQL, and here's a list of common points: first, the DBMS processes
MySQL Query Optimization: LIMIT1 avoids full table scan to improve query efficiency bitsCN.com. in some cases, if only one query result is found, using LIMIT 1 in SQL statements will improve query efficiency.
For example, the foll
MySQL index principle overview and slow query optimization practices MySQL has become the preferred relational database for most Internet companies thanks to its outstanding performance, low cost, and rich resources. Although the performance is outstanding, the so-called "good horse with good saddle", how to better use it, has become a required course for development engineers, we often see requirements fro
SQL optimization series (2) _ SQL optimization sorting 1. SQL query optimization (1 ). table name order (only valid in rule-based Optimizer): The Parser for www.2cto.com ORACLE processe
Query optimization Technology of databaseQuery optimization Technology of databaseDatabase system is the core of MIS, and online transaction processing (OLTP) and online analytical Processing (OLAP) based on database is one of the most important computer applications in banks, enterprises and government departments. From the application examples of most systems,
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.