Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL: a special problem

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

-

This is a question asked by the developer.

-

# 1. Problem description

If a table has a federated index (ajournal b):

The index records are as follows:

Id1 id2

1 10

1 10

1 10

2 20

2 20

3 30

3 30

It means that the number of data filtered through an is the same as that filtered through an and b. Is it efficient to access data select * from table where id1=1 and select * from table where id1=1 and id2=10 through the index?

# II. Simple analysis

First of all, for data lookup, the first step is to locate the data in the innodb layer (that is, where to output the data to the MySQL layer), and then access it sequentially down after the positioning is completed, because innodb represents an index organization table.

-for the equivalence condition, the Innodb layer will access the next piece of data. If it does not meet the requirements, it means it is over, and a DB_RECORD_NOT_FOUND tag will be returned to the MySQL layer to indicate the end.

-for ranges such as > and

< 操作如果使用了索引,那么row_search_mvcc ->

Btr_pcur_open_with_no_init_func

-> btr_cur_search_to_nth_level

-> page_cur_search_with_match_bytes

-> cmp_dtuple_rec_with_match_bytes

`

This section of cmp_dtuple_rec_with_match_bytes is annotated as follows:

`

/ * Match fields in a loop; stop if we run out of fields in dtuple

Or find an externally stored field * /

While (cur_field < n_cmp) {

`

N_cmp is the number that needs to be compared.

Debug record:

`

A record

829 ut_ad (n_cmp

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report