View table-related commands- 查看表结构 desc 表名- 查看生成表的SQL show create table 表名- 查看索引 show index from 表名Using indexes and not using indexes由于索引是专门用于加速搜索而生,所以加上索引之后,查询效率会快到飞起来。# 有索引Mysql>Select* fromTb1whereName ='Zhangqiye';+-----+-------------+---
There is a tens of millions of-record table on MySQL 5.0.x, which now reads about 1 billion of the records. Common methods, followed by loops:
1
The code is as follows
Copy Code
SELECT * FROM mytable where index_col =
SQL query optimizes the where condition sorting fields and the mysteries of using the index by limit. Strange slow SQL
Let's take a look at two SQL statements.Article 1:
Select * from acct_trans_log WHERE acct_id = 1000000000009000757 order by
SQL limit to implement TENS data volume paging
SELECT * FROM Table LIMIT 5, 10; #返回第6-15 rows of dataSELECT * FROM table LIMIT 5; #返回前5行SELECT * FROM table LIMIT 0, 5; #返回前5行
Performance optimization:
Based on the high performance of limit in
Cause Analysis and Solution of slow SQL query speed, and cause analysis of slow SQL query speed
Cause Analysis and Solution for slow SQL query speed
There are many reasons for slow query speed. The following are common causes: 1. No index or no
Continue to consult the mysql Query statement: multi-table joint query, how to limit the right table if there is a corresponding record, then add a specific where limit or limit, otherwise there is no limit, as shown in the question
6 Table join
Users use email as a user name landing, you need to check out an email corresponding to a record. Each user's email is unique.SELECT * from T_user WHERE email=?;The above statement implements a query email corresponding to a user information, but
First, the practical, the misunderstanding of the use of the indexThe purpose of the theory is to apply. Although we have just listed when clustered or nonclustered indexes should be used, in practice the above rules are easily overlooked or cannot
Continue to consult the mysql Query statement: multi-table joint query, how to limit the specific where limit or limit if the table on the right has a corresponding record, otherwise, no restrictions are imposed, such as table 6 joint queries.
Today to see a Bo Friends of the article, feel good, reprint, hope to help you, more articles, please visit: http://blog.haoitsoft.com1, no index or no index (this is the most common problem of slow query, is the defect of program design)2, I/O
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.