SlideShare a Scribd company logo
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/

More Related Content

What's hot

Apache Iceberg - A Table Format for Hige Analytic Datasets
Apache Iceberg - A Table Format for Hige Analytic DatasetsApache Iceberg - A Table Format for Hige Analytic Datasets
Apache Iceberg - A Table Format for Hige Analytic DatasetsAlluxio, Inc.
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performancePostgreSQL-Consulting
 
MySQL innoDB split and merge pages
MySQL innoDB split and merge pagesMySQL innoDB split and merge pages
MySQL innoDB split and merge pagesMarco Tusa
 
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오PgDay.Seoul
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL AdministrationEDB
 
The columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache ArrowThe columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache ArrowDataWorks Summit
 
InnoDB Internal
InnoDB InternalInnoDB Internal
InnoDB Internalmysqlops
 
Building robust CDC pipeline with Apache Hudi and Debezium
Building robust CDC pipeline with Apache Hudi and DebeziumBuilding robust CDC pipeline with Apache Hudi and Debezium
Building robust CDC pipeline with Apache Hudi and DebeziumTathastu.ai
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep InternalEXEM
 
Instana - ClickHouse presentation
Instana - ClickHouse presentationInstana - ClickHouse presentation
Instana - ClickHouse presentationMiel Donkers
 
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Mydbops
 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Traceoysteing
 
More mastering the art of indexing
More mastering the art of indexingMore mastering the art of indexing
More mastering the art of indexingYoshinori Matsunobu
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Alexey Lesovsky
 
High Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniHigh Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniZalando Technology
 
M|18 Deep Dive: InnoDB Transactions and Write Paths
M|18 Deep Dive: InnoDB Transactions and Write PathsM|18 Deep Dive: InnoDB Transactions and Write Paths
M|18 Deep Dive: InnoDB Transactions and Write PathsMariaDB plc
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 MinutesSveta Smirnova
 

What's hot (20)

Apache Iceberg - A Table Format for Hige Analytic Datasets
Apache Iceberg - A Table Format for Hige Analytic DatasetsApache Iceberg - A Table Format for Hige Analytic Datasets
Apache Iceberg - A Table Format for Hige Analytic Datasets
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
MySQL innoDB split and merge pages
MySQL innoDB split and merge pagesMySQL innoDB split and merge pages
MySQL innoDB split and merge pages
 
PostgreSQL: Advanced indexing
PostgreSQL: Advanced indexingPostgreSQL: Advanced indexing
PostgreSQL: Advanced indexing
 
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
The columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache ArrowThe columnar roadmap: Apache Parquet and Apache Arrow
The columnar roadmap: Apache Parquet and Apache Arrow
 
InnoDB Internal
InnoDB InternalInnoDB Internal
InnoDB Internal
 
Building robust CDC pipeline with Apache Hudi and Debezium
Building robust CDC pipeline with Apache Hudi and DebeziumBuilding robust CDC pipeline with Apache Hudi and Debezium
Building robust CDC pipeline with Apache Hudi and Debezium
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep Internal
 
Instana - ClickHouse presentation
Instana - ClickHouse presentationInstana - ClickHouse presentation
Instana - ClickHouse presentation
 
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera ) Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
Wars of MySQL Cluster ( InnoDB Cluster VS Galera )
 
The MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer TraceThe MySQL Query Optimizer Explained Through Optimizer Trace
The MySQL Query Optimizer Explained Through Optimizer Trace
 
More mastering the art of indexing
More mastering the art of indexingMore mastering the art of indexing
More mastering the art of indexing
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
High Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniHigh Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando Patroni
 
M|18 Deep Dive: InnoDB Transactions and Write Paths
M|18 Deep Dive: InnoDB Transactions and Write PathsM|18 Deep Dive: InnoDB Transactions and Write Paths
M|18 Deep Dive: InnoDB Transactions and Write Paths
 
MySQL Performance Schema in 20 Minutes
 MySQL Performance Schema in 20 Minutes MySQL Performance Schema in 20 Minutes
MySQL Performance Schema in 20 Minutes
 

Similar to 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
 
Notes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testsNotes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testspriyanshukumar97908
 
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
 

Similar to 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
 
Notes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testsNotes of bca Question paper for exams and tests
Notes of bca Question paper for exams and tests
 
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
 

Recently uploaded

Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfOrtus Solutions, Corp
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisNeo4j
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyanic lab
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILNatan Silnitsky
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareinfo611746
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion Clinic
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfMeon Technology
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandIES VE
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...Alluxio, Inc.
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Krakówbim.edu.pl
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
 

Recently uploaded (20)

Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 

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/