Get the App
SLTechnology News&Howtos  ›  Database  › 

How does MySQL query the first few rows of specified data

Shulou Source: shulou.com Published: 2022-05-31 18:00:11 10月02日 Update

This article mainly explains "MySQL how to query the first few lines of specified data", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "MySQL how to query the first few lines of specified data" bar!

When there is a large amount of data in the data table, and only the values of some of these fields are needed for verification, you don't need all the data, you only need to check a few rows, use limit at this time

Such as:

1.select * from tags limit 4; just take four rows of data to see what the value of id or other required fields is.

The query result is: id=102 or., use id=102 below

It is effective for 2.explain select * from tags where id=102; to check whether the id or other fields in the table are indexed.

+-- +

| | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |

+-- +

| | 102 | SIMPLE | tags | ALL | NULL | NULL | NULL | NULL | 6226057 |

+-- +

You can see that the id index is not used here [the index built for id is usually PRIMARY]

Thank you for your reading, the above is the content of "how MySQL queries the first few rows of specified data". After the study of this article, I believe you have a deeper understanding of how MySQL queries the first few rows of specified data, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Data queries fields indexes learning content that is validation validity ideas situations datasheets articles more knowledge knowledge points articles results follow questions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Technology Docker Microsoft Shulou Tech Info