SlideShare une entreprise Scribd logo
1  sur  25
Télécharger pour lire hors ligne
Secondary Index Search in MySQL
Mijin An
meeeeejin@gmail.com
8/23/16 1
Contents
8/23/16 2
• Secondary/Primary Key Record Format
• Secondary Index Search
• Proposal for Improvement
• Improved Secondary Index Search
Secondary Key Record Format
8/23/16 3
= Primary Key Value
Primary Key Record Format
8/23/16 4
Secondary Index Search
8/23/16 5
① Start a mini-transaction
② Searches an index tree, then positions a tree cursor(pcur)
on a record corresponding to the index
(btr_pcur_open_with_no_init())
③ Get the record that pcur indicates(rec)
④ Go to rec_loop:
row_search_for_mysql()
rec_loop:
8/23/16 6
a. Get the record that pcur indicates(rec)
b. If record is infimum or supremum, go to next_rec:
Look for matching records in a loop
next_rec:
8/23/16 7
a. Stores current position of pcur
b. Commit mini-transaction
c. If record is infimum è move pcur to the next record
Else if record is supremum è move pcur to the first
record of next page
Else è move pcur according to the search direction
d. If we may need to process the record the cursor is now
on, go to rec_loop:
Move cursor to the next record, then search again
rec_loop:
8/23/16 8
a. Get the record that pcur indicates(rec)
b. If record is infimum or supremum, go to next_rec:
c. Caculates the offsets to each field in the record (offsets)
d. If select_lock_type == LOCK_S or LOCK_X,
- try to place a lock on the index record
e. Go to locks_ok:
If index != clust_index && need_to_access_clustered,
- go to requires_clust_rec:
Look for matching records in a loop
requires_clust_rec:
8/23/16 9
a. Retrieves the clustered record(clust_rec) corresponding
to a record in a secondary index (row_sel_get_clust_rec_for_mysql())
Get clustered record using secondary index
row_sel_get_clust_rec_for_mysql()
8/23/16 10
a. Get the clust_index from sec_index
b. Searches an index tree, then positions a tree cursor
(clust_pcur) on a record corresponding to the index
(btr_pcur_open_with_no_init())
c. Get the record that clust_pcur indicates (clust_rec)
d. Caculate the offsets to each field in the record (offsets)
e. If select_lock_type == LOCK_S or LOCK_X,
- try to place a lock on the index record
Get clustered record using secondary index
row_sel_get_clust_rec_for_mysql()
8/23/16 11
f. Go to func_exit:
g. In func_exit:, store the current clust_pcur position if
select_lock_type is LOCK_S or LOCK_X
Get clustered record using secondary index
requires_clust_rec:
8/23/16 12
a. Retrieves the clustered record(clust_rec) corresponding
to a record in a secondary index (row_sel_get_clust_rec_for_mysql())
b. If clust_rec is delete marked, skip it è next_rec:
c. Store clust_rec into the result_rec
d. Go to normal_return:
Get clustered record using secondary index
Secondary Index Search
8/23/16 13
⑤ Commit mini-transaction
⑥ Go to func_exit:
⑦ In func_exit:, frees the space occupied by a memory
heap then exit
row_search_for_mysql() è normal_return: è func_exit:
Data records
Secondary Index Search
8/23/16 14
Primary key
Secondary index tree Primary index tree
Primary index tree
Data records
Data records
Secondary Index Search
8/23/16 15
Primary key
Secondary index tree Primary index tree
Primary index tree
Data records
Data records
Secondary Index Search
8/23/16 16
Primary key
Secondary index tree Primary index tree
Primary index tree
Data records
Data records
Proposal: Prefetching in MySQL
8/23/16 17
Primary key
Secondary index tree Primary index tree
P1
Primary key list(unsorted)
Data records
8/23/16 18
Primary key
Secondary index tree Primary index tree
P1 P2
Primary key list(unsorted)
Proposal: Prefetching in MySQL
Data records
8/23/16 19
Primary key
Secondary index tree Primary index tree
P1 P2 P3
Primary key list(unsorted)
Proposal: Prefetching in MySQL
P2
P3
Data records
8/23/16 20
Primary key
Secondary index tree Primary index tree
P1 P2 P3
Primary key list(unsorted)
Primary key list(sorted)
Proposal: Prefetching in MySQL
P2
P3
Data records
8/23/16 21
Secondary index tree Primary index tree
P1
Primary key list(sorted)
Primary index tree
Primary index tree
Data records
Data records
Proposal: Prefetching in MySQL
P2
P3
Data records
Proposal: Prefetching in MySQL
8/23/16 22
Secondary index tree Primary index tree
P1
Primary key list(sorted)
Primary index tree
Primary index tree
Data records
Data records
P2
P3
Data records
Proposal: Prefetching in MySQL
8/23/16 23
Secondary index tree Primary index tree
P1
Primary key list(sorted)
Primary index tree
Primary index tree
Data records
Data records
Improved Secondary Index Search
8/23/16 24
① Search a data record using secondary index
② Get primary key and insert it into primary key list, then
repeat ①~② process until there is no record to search
using secondary index
③ Sort the primary key list
④ Search primary index tree sequentially using sorted
primary key list
⑤ Access data record sequentially
Reference
8/23/16 25
[1] “MySQL 5.6 Reference Manual”, MySQL, https://dev.mysql.com/doc/refman/5.6/en/
[2] Jeremy Cole, “InnoDB”, https://blog.jcole.us/innodb/

Contenu connexe

Tendances

Postgresql Database Administration Basic - Day1
Postgresql  Database Administration Basic  - Day1Postgresql  Database Administration Basic  - Day1
Postgresql Database Administration Basic - Day1PoguttuezhiniVP
 
MySQL Space Management
MySQL Space ManagementMySQL Space Management
MySQL Space ManagementMIJIN AN
 
InnoDB Internal
InnoDB InternalInnoDB Internal
InnoDB Internalmysqlops
 
Built in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat GulecBuilt in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat GulecFIRAT GULEC
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL AdministrationEDB
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바NeoClova
 
Oracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aasOracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aasKyle Hailey
 
Apache Hudi: The Path Forward
Apache Hudi: The Path ForwardApache Hudi: The Path Forward
Apache Hudi: The Path ForwardAlluxio, Inc.
 
How the Postgres Query Optimizer Works
How the Postgres Query Optimizer WorksHow the Postgres Query Optimizer Works
How the Postgres Query Optimizer WorksEDB
 
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1ScyllaDB
 
RocksDB Performance and Reliability Practices
RocksDB Performance and Reliability PracticesRocksDB Performance and Reliability Practices
RocksDB Performance and Reliability PracticesYoshinori Matsunobu
 
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...Flink Forward
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Kyle Hailey
 
A Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQLA Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQLDatabricks
 
Understanding and tuning WiredTiger, the new high performance database engine...
Understanding and tuning WiredTiger, the new high performance database engine...Understanding and tuning WiredTiger, the new high performance database engine...
Understanding and tuning WiredTiger, the new high performance database engine...Ontico
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바NeoClova
 
Memory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelMemory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelAdrian Huang
 
Mvcc (oracle, innodb, postgres)
Mvcc (oracle, innodb, postgres)Mvcc (oracle, innodb, postgres)
Mvcc (oracle, innodb, postgres)frogd
 
Transparent Hugepages in RHEL 6
Transparent Hugepages in RHEL 6 Transparent Hugepages in RHEL 6
Transparent Hugepages in RHEL 6 Raghu Udiyar
 
ORC File and Vectorization - Hadoop Summit 2013
ORC File and Vectorization - Hadoop Summit 2013ORC File and Vectorization - Hadoop Summit 2013
ORC File and Vectorization - Hadoop Summit 2013Owen O'Malley
 

Tendances (20)

Postgresql Database Administration Basic - Day1
Postgresql  Database Administration Basic  - Day1Postgresql  Database Administration Basic  - Day1
Postgresql Database Administration Basic - Day1
 
MySQL Space Management
MySQL Space ManagementMySQL Space Management
MySQL Space Management
 
InnoDB Internal
InnoDB InternalInnoDB Internal
InnoDB Internal
 
Built in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat GulecBuilt in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat Gulec
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바MySQL Advanced Administrator 2021 - 네오클로바
MySQL Advanced Administrator 2021 - 네오클로바
 
Oracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aasOracle 10g Performance: chapter 02 aas
Oracle 10g Performance: chapter 02 aas
 
Apache Hudi: The Path Forward
Apache Hudi: The Path ForwardApache Hudi: The Path Forward
Apache Hudi: The Path Forward
 
How the Postgres Query Optimizer Works
How the Postgres Query Optimizer WorksHow the Postgres Query Optimizer Works
How the Postgres Query Optimizer Works
 
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
 
RocksDB Performance and Reliability Practices
RocksDB Performance and Reliability PracticesRocksDB Performance and Reliability Practices
RocksDB Performance and Reliability Practices
 
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
 
Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle
 
A Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQLA Deep Dive into Query Execution Engine of Spark SQL
A Deep Dive into Query Execution Engine of Spark SQL
 
Understanding and tuning WiredTiger, the new high performance database engine...
Understanding and tuning WiredTiger, the new high performance database engine...Understanding and tuning WiredTiger, the new high performance database engine...
Understanding and tuning WiredTiger, the new high performance database engine...
 
MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바MySQL Administrator 2021 - 네오클로바
MySQL Administrator 2021 - 네오클로바
 
Memory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelMemory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux Kernel
 
Mvcc (oracle, innodb, postgres)
Mvcc (oracle, innodb, postgres)Mvcc (oracle, innodb, postgres)
Mvcc (oracle, innodb, postgres)
 
Transparent Hugepages in RHEL 6
Transparent Hugepages in RHEL 6 Transparent Hugepages in RHEL 6
Transparent Hugepages in RHEL 6
 
ORC File and Vectorization - Hadoop Summit 2013
ORC File and Vectorization - Hadoop Summit 2013ORC File and Vectorization - Hadoop Summit 2013
ORC File and Vectorization - Hadoop Summit 2013
 

Similaire à Secondary Index Search in InnoDB

Database management system chapter13
Database management system chapter13Database management system chapter13
Database management system chapter13Pranab Dasgupta
 
Postgresql Database Administration Basic - Day2
Postgresql  Database Administration Basic  - Day2Postgresql  Database Administration Basic  - Day2
Postgresql Database Administration Basic - Day2PoguttuezhiniVP
 
CS8391-DATA-STRUCTURES.pdf
CS8391-DATA-STRUCTURES.pdfCS8391-DATA-STRUCTURES.pdf
CS8391-DATA-STRUCTURES.pdfraji175286
 
Lecture4a dynamic data_structure
Lecture4a dynamic data_structureLecture4a dynamic data_structure
Lecture4a dynamic data_structurembadhi barnabas
 
2.02.Data_structures_and_algorithms (1).pptx
2.02.Data_structures_and_algorithms (1).pptx2.02.Data_structures_and_algorithms (1).pptx
2.02.Data_structures_and_algorithms (1).pptxDrBashirMSaad
 
Presentation on Elementary data structures
Presentation on Elementary data structuresPresentation on Elementary data structures
Presentation on Elementary data structuresKuber Chandra
 
Modeling with Document Database: 5 Key Patterns
Modeling with Document Database: 5 Key PatternsModeling with Document Database: 5 Key Patterns
Modeling with Document Database: 5 Key PatternsDan Sullivan, Ph.D.
 
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPatrick Allaert
 
Impetus White Paper- Handling Data Corruption in Elasticsearch
Impetus White Paper- Handling  Data Corruption  in ElasticsearchImpetus White Paper- Handling  Data Corruption  in Elasticsearch
Impetus White Paper- Handling Data Corruption in ElasticsearchImpetus Technologies
 
Everything You Always Wanted to Know About Memory in Python But Were Afraid t...
Everything You Always Wanted to Know About Memory in Python But Were Afraid t...Everything You Always Wanted to Know About Memory in Python But Were Afraid t...
Everything You Always Wanted to Know About Memory in Python But Were Afraid t...Piotr Przymus
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13ecomputernotes
 
How Instacart’s Catalog Flourished While Hyper-Growing (ANT328-S) - AWS re:In...
How Instacart’s Catalog Flourished While Hyper-Growing (ANT328-S) - AWS re:In...How Instacart’s Catalog Flourished While Hyper-Growing (ANT328-S) - AWS re:In...
How Instacart’s Catalog Flourished While Hyper-Growing (ANT328-S) - AWS re:In...Amazon Web Services
 
How to Implement Distributed Data Store
How to Implement Distributed Data Store How to Implement Distributed Data Store
How to Implement Distributed Data Store Philip Zhong
 
Algorithm ch13.ppt
Algorithm ch13.pptAlgorithm ch13.ppt
Algorithm ch13.pptDreamless2
 
Korth_Query_processing.pptx
Korth_Query_processing.pptxKorth_Query_processing.pptx
Korth_Query_processing.pptxDrSonuMittal
 
Mapreduce Algorithms
Mapreduce AlgorithmsMapreduce Algorithms
Mapreduce AlgorithmsAmund Tveit
 

Similaire à Secondary Index Search in InnoDB (20)

Database management system chapter13
Database management system chapter13Database management system chapter13
Database management system chapter13
 
Postgresql Database Administration Basic - Day2
Postgresql  Database Administration Basic  - Day2Postgresql  Database Administration Basic  - Day2
Postgresql Database Administration Basic - Day2
 
CS8391-DATA-STRUCTURES.pdf
CS8391-DATA-STRUCTURES.pdfCS8391-DATA-STRUCTURES.pdf
CS8391-DATA-STRUCTURES.pdf
 
Rac nonrac clone
Rac nonrac cloneRac nonrac clone
Rac nonrac clone
 
linkedLists.ppt
linkedLists.pptlinkedLists.ppt
linkedLists.ppt
 
Lecture4a dynamic data_structure
Lecture4a dynamic data_structureLecture4a dynamic data_structure
Lecture4a dynamic data_structure
 
L3
L3L3
L3
 
2.02.Data_structures_and_algorithms (1).pptx
2.02.Data_structures_and_algorithms (1).pptx2.02.Data_structures_and_algorithms (1).pptx
2.02.Data_structures_and_algorithms (1).pptx
 
Presentation on Elementary data structures
Presentation on Elementary data structuresPresentation on Elementary data structures
Presentation on Elementary data structures
 
ch12.ppt
ch12.pptch12.ppt
ch12.ppt
 
Modeling with Document Database: 5 Key Patterns
Modeling with Document Database: 5 Key PatternsModeling with Document Database: 5 Key Patterns
Modeling with Document Database: 5 Key Patterns
 
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
 
Impetus White Paper- Handling Data Corruption in Elasticsearch
Impetus White Paper- Handling  Data Corruption  in ElasticsearchImpetus White Paper- Handling  Data Corruption  in Elasticsearch
Impetus White Paper- Handling Data Corruption in Elasticsearch
 
Everything You Always Wanted to Know About Memory in Python But Were Afraid t...
Everything You Always Wanted to Know About Memory in Python But Were Afraid t...Everything You Always Wanted to Know About Memory in Python But Were Afraid t...
Everything You Always Wanted to Know About Memory in Python But Were Afraid t...
 
computer notes - Data Structures - 13
computer notes - Data Structures - 13computer notes - Data Structures - 13
computer notes - Data Structures - 13
 
How Instacart’s Catalog Flourished While Hyper-Growing (ANT328-S) - AWS re:In...
How Instacart’s Catalog Flourished While Hyper-Growing (ANT328-S) - AWS re:In...How Instacart’s Catalog Flourished While Hyper-Growing (ANT328-S) - AWS re:In...
How Instacart’s Catalog Flourished While Hyper-Growing (ANT328-S) - AWS re:In...
 
How to Implement Distributed Data Store
How to Implement Distributed Data Store How to Implement Distributed Data Store
How to Implement Distributed Data Store
 
Algorithm ch13.ppt
Algorithm ch13.pptAlgorithm ch13.ppt
Algorithm ch13.ppt
 
Korth_Query_processing.pptx
Korth_Query_processing.pptxKorth_Query_processing.pptx
Korth_Query_processing.pptx
 
Mapreduce Algorithms
Mapreduce AlgorithmsMapreduce Algorithms
Mapreduce Algorithms
 

Dernier

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROmotivationalword821
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 

Dernier (20)

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 

Secondary Index Search in InnoDB

  • 1. Secondary Index Search in MySQL Mijin An meeeeejin@gmail.com 8/23/16 1
  • 2. Contents 8/23/16 2 • Secondary/Primary Key Record Format • Secondary Index Search • Proposal for Improvement • Improved Secondary Index Search
  • 3. Secondary Key Record Format 8/23/16 3 = Primary Key Value
  • 4. Primary Key Record Format 8/23/16 4
  • 5. Secondary Index Search 8/23/16 5 ① Start a mini-transaction ② Searches an index tree, then positions a tree cursor(pcur) on a record corresponding to the index (btr_pcur_open_with_no_init()) ③ Get the record that pcur indicates(rec) ④ Go to rec_loop: row_search_for_mysql()
  • 6. rec_loop: 8/23/16 6 a. Get the record that pcur indicates(rec) b. If record is infimum or supremum, go to next_rec: Look for matching records in a loop
  • 7. next_rec: 8/23/16 7 a. Stores current position of pcur b. Commit mini-transaction c. If record is infimum è move pcur to the next record Else if record is supremum è move pcur to the first record of next page Else è move pcur according to the search direction d. If we may need to process the record the cursor is now on, go to rec_loop: Move cursor to the next record, then search again
  • 8. rec_loop: 8/23/16 8 a. Get the record that pcur indicates(rec) b. If record is infimum or supremum, go to next_rec: c. Caculates the offsets to each field in the record (offsets) d. If select_lock_type == LOCK_S or LOCK_X, - try to place a lock on the index record e. Go to locks_ok: If index != clust_index && need_to_access_clustered, - go to requires_clust_rec: Look for matching records in a loop
  • 9. requires_clust_rec: 8/23/16 9 a. Retrieves the clustered record(clust_rec) corresponding to a record in a secondary index (row_sel_get_clust_rec_for_mysql()) Get clustered record using secondary index
  • 10. row_sel_get_clust_rec_for_mysql() 8/23/16 10 a. Get the clust_index from sec_index b. Searches an index tree, then positions a tree cursor (clust_pcur) on a record corresponding to the index (btr_pcur_open_with_no_init()) c. Get the record that clust_pcur indicates (clust_rec) d. Caculate the offsets to each field in the record (offsets) e. If select_lock_type == LOCK_S or LOCK_X, - try to place a lock on the index record Get clustered record using secondary index
  • 11. row_sel_get_clust_rec_for_mysql() 8/23/16 11 f. Go to func_exit: g. In func_exit:, store the current clust_pcur position if select_lock_type is LOCK_S or LOCK_X Get clustered record using secondary index
  • 12. requires_clust_rec: 8/23/16 12 a. Retrieves the clustered record(clust_rec) corresponding to a record in a secondary index (row_sel_get_clust_rec_for_mysql()) b. If clust_rec is delete marked, skip it è next_rec: c. Store clust_rec into the result_rec d. Go to normal_return: Get clustered record using secondary index
  • 13. Secondary Index Search 8/23/16 13 ⑤ Commit mini-transaction ⑥ Go to func_exit: ⑦ In func_exit:, frees the space occupied by a memory heap then exit row_search_for_mysql() è normal_return: è func_exit:
  • 14. Data records Secondary Index Search 8/23/16 14 Primary key Secondary index tree Primary index tree Primary index tree Data records
  • 15. Data records Secondary Index Search 8/23/16 15 Primary key Secondary index tree Primary index tree Primary index tree Data records
  • 16. Data records Secondary Index Search 8/23/16 16 Primary key Secondary index tree Primary index tree Primary index tree Data records
  • 17. Data records Proposal: Prefetching in MySQL 8/23/16 17 Primary key Secondary index tree Primary index tree P1 Primary key list(unsorted)
  • 18. Data records 8/23/16 18 Primary key Secondary index tree Primary index tree P1 P2 Primary key list(unsorted) Proposal: Prefetching in MySQL
  • 19. Data records 8/23/16 19 Primary key Secondary index tree Primary index tree P1 P2 P3 Primary key list(unsorted) Proposal: Prefetching in MySQL
  • 20. P2 P3 Data records 8/23/16 20 Primary key Secondary index tree Primary index tree P1 P2 P3 Primary key list(unsorted) Primary key list(sorted) Proposal: Prefetching in MySQL
  • 21. P2 P3 Data records 8/23/16 21 Secondary index tree Primary index tree P1 Primary key list(sorted) Primary index tree Primary index tree Data records Data records Proposal: Prefetching in MySQL
  • 22. P2 P3 Data records Proposal: Prefetching in MySQL 8/23/16 22 Secondary index tree Primary index tree P1 Primary key list(sorted) Primary index tree Primary index tree Data records Data records
  • 23. P2 P3 Data records Proposal: Prefetching in MySQL 8/23/16 23 Secondary index tree Primary index tree P1 Primary key list(sorted) Primary index tree Primary index tree Data records Data records
  • 24. Improved Secondary Index Search 8/23/16 24 ① Search a data record using secondary index ② Get primary key and insert it into primary key list, then repeat ①~② process until there is no record to search using secondary index ③ Sort the primary key list ④ Search primary index tree sequentially using sorted primary key list ⑤ Access data record sequentially
  • 25. Reference 8/23/16 25 [1] “MySQL 5.6 Reference Manual”, MySQL, https://dev.mysql.com/doc/refman/5.6/en/ [2] Jeremy Cole, “InnoDB”, https://blog.jcole.us/innodb/