SlideShare a Scribd company logo
developer.oracle.com/code
Why Isn't My Query Using an Index?
Chris Saxon, Oracle Developer Advocate for SQL
chris.saxon@oracle.com
@chrisrsaxon & @sqldaily
blogs.oracle.com/sql
www.youtube.com/c/TheMagicofSQL
An introduction to SQL performance
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Why isn’t Oracle using my
#@!%
index?!
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Colour BAG Colour BAG Colour BAG Colour BAG Colour BAG
Blue 73 Brown 56 Green 11 Orange 19 Red 2
Blue 31 Brown 40 Green 31 Orange 19 Red 41
Blue 1 Brown 41 Green 70 Orange 85 Red 21
Blue 64 Brown 65 Green 4 Red 42 Red 32
Blue 69 Brown 23 Green 80 Red 100 Red 12
Blue 85 Brown 21 Green 28 Red 70 Red 83
Blue 84 Brown 73 Green 44 Red 38 Yellow 29
Blue 40 Brown 97 Green 99 Red 33 Yellow 31
Blue 41 Brown 57 Green 32 Red 63 Yellow 51
Blue 88 Brown 63 Orange 85 Red 22 Yellow 33
Blue 100 Brown 100 Orange 21 Red 80 Yellow 4
Blue 6 Brown 80 Orange 76 Red 80 Yellow 9
Blue 64 Brown 75 Orange 32 Red 40 Yellow 27
Blue 90 Green 20 Orange 93 Red 68 Yellow 48
Blue 24 Green 50 Orange 70 Red 54 Yellow 56
Brown 88 Green 85 Orange 2 Red 93 Yellow 15
Brown 50 Green 17 Orange 15 Red 93 Yellow 81
Brown 69 Green 27 Orange 5 Red 20 Yellow 83
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
What’s this got to do with
?
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
M&M => a row
Document => an index
Bag => a block
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Method #1 => TABLE ACCESS FULL
Method #2 => INDEX RANGE SCAN
Multiblock reads
Single block reads
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Source: Pixabay
Which is faster?
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
FULL TABLE SCAN
Visit each bag once
INDEX RANGE SCAN
Visit each bag ~10 times
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
What if there’s a
Promotion?
silver sweets in 1% of bags
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
FULL TABLE SCAN
Visit each bag once
INDEX RANGE SCAN
One bag visit
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
The
Cost Based Optimizer
estimates these calculations
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
DEMO
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
"M & Ms (3685102458)" by Greg Willis from Denver, CO, usa Uploaded by russavia. CC BY-SA 2.0
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Colour BAG Colour BAG Colour BAG Colour BAG Colour BAG
Blue 1 Brown 7 Green 13 Orange 19 Red 25
Blue 1 Brown 7 Green 13 Orange 19 Red 25
Blue 1 Brown 7 Green 13 Orange 19 Red 25
Blue 2 Brown 8 Green 14 Red 20 Red 26
Blue 2 Brown 8 Green 14 Red 20 Red 26
Blue 2 Brown 8 Green 14 Red 20 Red 26
Blue 3 Brown 9 Green 15 Red 21 Yellow 27
Blue 3 Brown 9 Green 15 Red 21 Yellow 27
Blue 3 Brown 9 Green 15 Red 21 Yellow 27
Blue 4 Brown 10 Orange 16 Red 22 Yellow 28
Blue 4 Brown 10 Orange 16 Red 22 Yellow 28
Blue 4 Brown 10 Orange 16 Red 22 Yellow 28
Blue 5 Brown 10 Orange 17 Red 23 Yellow 29
Blue 5 Green 11 Orange 17 Red 23 Yellow 29
Blue 5 Green 11 Orange 17 Red 23 Yellow 29
Brown 6 Green 11 Orange 18 Red 24 Yellow 30
Brown 6 Green 12 Orange 18 Red 24 Yellow 30
Brown 6 Green 12 Orange 18 Red 24 Yellow 30blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Colour BAG Colour BAG Colour BAG Colour BAG Colour BAG
Blue 1 Brown 3 Green 4 Orange 7 Red 9
Blue 1 Brown 4 Green 4 Orange 8 Red 9
Blue 2 Brown 5 Green 5 Orange 9 Red 9
Blue 2 Brown 5 Green 6 Red 1 Red 9
Blue 3 Brown 5 Green 6 Red 2 Red 10
Blue 4 Brown 6 Green 7 Red 2 Red 10
Blue 6 Brown 7 Green 8 Red 3 Yellow 1
Blue 7 Brown 8 Green 8 Red 3 Yellow 1
Blue 7 Brown 8 Green 10 Red 4 Yellow 2
Blue 8 Brown 9 Orange 1 Red 4 Yellow 2
Blue 9 Brown 9 Orange 2 Red 5 Yellow 3
Blue 9 Brown 10 Orange 3 Red 6 Yellow 5
Blue 10 Brown 10 Orange 3 Red 6 Yellow 5
Blue 10 Green 1 Orange 4 Red 7 Yellow 6
Blue 10 Green 2 Orange 4 Red 7 Yellow 7
Brown 2 Green 3 Orange 5 Red 8 Yellow 8
Brown 2 Green 3 Orange 6 Red 8 Yellow 9
Brown 2 Green 3 Orange 6 Red 8 Yellow 10blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Clustering factor
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
clustering factor = 10 (good)
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
clustering factor = 120 (bad)
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
DEMO
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
How do I
Improve
the clustering factor?
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Tannin Heap Simon A. Eugster CC-BY-3.0
By default
tables are
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Organized
Part ition ed
Clusters
How do I
force
the clustering?
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
There can be only 1!
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Colour
Weight
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
inter d attr clust
leave ibute ering
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Cost
Rows
Full Table Scan
Index Range Scan 1
Index Range Scan 2
Index Range Scan 3
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Rows
“Toy Blocks (6831034024)” welcometolearn CC BY 2.0
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
www.youtube.com/c/TheMagicofSQL
#MakeDataGreatAgain
Gratisography
blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
Why Isn't My Query Using an Index? An Introduction to SQL Performance

More Related Content

Similar to Why Isn't My Query Using an Index? An Introduction to SQL Performance

Flashback features in Oracle - UKOUG 2017
Flashback features in Oracle - UKOUG 2017Flashback features in Oracle - UKOUG 2017
Flashback features in Oracle - UKOUG 2017
Connor McDonald
 
MySQL Document Store - when SQL & NoSQL live together... in peace!
MySQL Document Store - when SQL & NoSQL live together... in peace!MySQL Document Store - when SQL & NoSQL live together... in peace!
MySQL Document Store - when SQL & NoSQL live together... in peace!
Frederic Descamps
 
ConSPIC 2016 presentation_DATTA_KORAK_2016_09_24_for PDF
ConSPIC 2016 presentation_DATTA_KORAK_2016_09_24_for PDFConSPIC 2016 presentation_DATTA_KORAK_2016_09_24_for PDF
ConSPIC 2016 presentation_DATTA_KORAK_2016_09_24_for PDF
Korak Datta
 
Building a Solid Foundation with the Boolean Black Belt I Talent Connect Lond...
Building a Solid Foundation with the Boolean Black Belt I Talent Connect Lond...Building a Solid Foundation with the Boolean Black Belt I Talent Connect Lond...
Building a Solid Foundation with the Boolean Black Belt I Talent Connect Lond...
LinkedIn Talent Solutions
 
PGQL: A Language for Graphs
PGQL: A Language for GraphsPGQL: A Language for Graphs
PGQL: A Language for Graphs
Jean Ihm
 
Openlaw - A Project of Alphalaw
Openlaw - A Project of AlphalawOpenlaw - A Project of Alphalaw
Openlaw - A Project of Alphalaw
Sunghyun Kim
 
Melbourne Groundbreakers Tour - Hints and Tips
Melbourne Groundbreakers Tour - Hints and TipsMelbourne Groundbreakers Tour - Hints and Tips
Melbourne Groundbreakers Tour - Hints and Tips
Connor McDonald
 
APEX Connect 2019 - SQL Tuning 101
APEX Connect 2019 - SQL Tuning 101APEX Connect 2019 - SQL Tuning 101
APEX Connect 2019 - SQL Tuning 101
Connor McDonald
 
Intro to Elasticsearch and Kibana.pdf
Intro to Elasticsearch and Kibana.pdfIntro to Elasticsearch and Kibana.pdf
Intro to Elasticsearch and Kibana.pdf
ssuser65fa31
 
Gluecon 2013 Keynote Ravello Systems
Gluecon 2013 Keynote Ravello SystemsGluecon 2013 Keynote Ravello Systems
Gluecon 2013 Keynote Ravello Systems
navinthadani
 
8th TUC Meeting – Yinglong Xia (Huawei), Big Graph Analytics Engine
8th TUC Meeting – Yinglong Xia (Huawei), Big Graph Analytics Engine8th TUC Meeting – Yinglong Xia (Huawei), Big Graph Analytics Engine
8th TUC Meeting – Yinglong Xia (Huawei), Big Graph Analytics Engine
LDBC council
 
What can Bioinformaticians learn from YouTube?
What can Bioinformaticians learn from YouTube?What can Bioinformaticians learn from YouTube?
What can Bioinformaticians learn from YouTube?
Matt Wood
 
Should a Graph Database Be in Your Next Data Warehouse Stack?
Should a Graph Database Be in Your Next Data Warehouse Stack?Should a Graph Database Be in Your Next Data Warehouse Stack?
Should a Graph Database Be in Your Next Data Warehouse Stack?
Cambridge Semantics
 
JoomlaDay Conference_September 2023 PDF.pdf
JoomlaDay Conference_September 2023 PDF.pdfJoomlaDay Conference_September 2023 PDF.pdf
JoomlaDay Conference_September 2023 PDF.pdf
Oliver Brett
 
AUSOUG Analytics Update - Nov 14 2018
AUSOUG Analytics Update - Nov 14 2018AUSOUG Analytics Update - Nov 14 2018
AUSOUG Analytics Update - Nov 14 2018
Jason Lowe
 
CAS SciFinder Discovery Platform Quick Reference Guide_2023(EN)
CAS SciFinder Discovery Platform Quick Reference Guide_2023(EN)CAS SciFinder Discovery Platform Quick Reference Guide_2023(EN)
CAS SciFinder Discovery Platform Quick Reference Guide_2023(EN)
POSTECH Library
 
Fuzzing - A Tale of Two Cultures
Fuzzing - A Tale of Two CulturesFuzzing - A Tale of Two Cultures
Fuzzing - A Tale of Two Cultures
CISPA Helmholtz Center for Information Security
 
Painful Success - Lessons Learned while Scaling Up
Painful Success - Lessons Learned while Scaling UpPainful Success - Lessons Learned while Scaling Up
Painful Success - Lessons Learned while Scaling Up
C4Media
 
SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP
Dave Stokes
 
Reproducible Workflow with Cytoscape and Jupyter Notebook
Reproducible Workflow with Cytoscape and Jupyter NotebookReproducible Workflow with Cytoscape and Jupyter Notebook
Reproducible Workflow with Cytoscape and Jupyter Notebook
Keiichiro Ono
 

Similar to Why Isn't My Query Using an Index? An Introduction to SQL Performance (20)

Flashback features in Oracle - UKOUG 2017
Flashback features in Oracle - UKOUG 2017Flashback features in Oracle - UKOUG 2017
Flashback features in Oracle - UKOUG 2017
 
MySQL Document Store - when SQL & NoSQL live together... in peace!
MySQL Document Store - when SQL & NoSQL live together... in peace!MySQL Document Store - when SQL & NoSQL live together... in peace!
MySQL Document Store - when SQL & NoSQL live together... in peace!
 
ConSPIC 2016 presentation_DATTA_KORAK_2016_09_24_for PDF
ConSPIC 2016 presentation_DATTA_KORAK_2016_09_24_for PDFConSPIC 2016 presentation_DATTA_KORAK_2016_09_24_for PDF
ConSPIC 2016 presentation_DATTA_KORAK_2016_09_24_for PDF
 
Building a Solid Foundation with the Boolean Black Belt I Talent Connect Lond...
Building a Solid Foundation with the Boolean Black Belt I Talent Connect Lond...Building a Solid Foundation with the Boolean Black Belt I Talent Connect Lond...
Building a Solid Foundation with the Boolean Black Belt I Talent Connect Lond...
 
PGQL: A Language for Graphs
PGQL: A Language for GraphsPGQL: A Language for Graphs
PGQL: A Language for Graphs
 
Openlaw - A Project of Alphalaw
Openlaw - A Project of AlphalawOpenlaw - A Project of Alphalaw
Openlaw - A Project of Alphalaw
 
Melbourne Groundbreakers Tour - Hints and Tips
Melbourne Groundbreakers Tour - Hints and TipsMelbourne Groundbreakers Tour - Hints and Tips
Melbourne Groundbreakers Tour - Hints and Tips
 
APEX Connect 2019 - SQL Tuning 101
APEX Connect 2019 - SQL Tuning 101APEX Connect 2019 - SQL Tuning 101
APEX Connect 2019 - SQL Tuning 101
 
Intro to Elasticsearch and Kibana.pdf
Intro to Elasticsearch and Kibana.pdfIntro to Elasticsearch and Kibana.pdf
Intro to Elasticsearch and Kibana.pdf
 
Gluecon 2013 Keynote Ravello Systems
Gluecon 2013 Keynote Ravello SystemsGluecon 2013 Keynote Ravello Systems
Gluecon 2013 Keynote Ravello Systems
 
8th TUC Meeting – Yinglong Xia (Huawei), Big Graph Analytics Engine
8th TUC Meeting – Yinglong Xia (Huawei), Big Graph Analytics Engine8th TUC Meeting – Yinglong Xia (Huawei), Big Graph Analytics Engine
8th TUC Meeting – Yinglong Xia (Huawei), Big Graph Analytics Engine
 
What can Bioinformaticians learn from YouTube?
What can Bioinformaticians learn from YouTube?What can Bioinformaticians learn from YouTube?
What can Bioinformaticians learn from YouTube?
 
Should a Graph Database Be in Your Next Data Warehouse Stack?
Should a Graph Database Be in Your Next Data Warehouse Stack?Should a Graph Database Be in Your Next Data Warehouse Stack?
Should a Graph Database Be in Your Next Data Warehouse Stack?
 
JoomlaDay Conference_September 2023 PDF.pdf
JoomlaDay Conference_September 2023 PDF.pdfJoomlaDay Conference_September 2023 PDF.pdf
JoomlaDay Conference_September 2023 PDF.pdf
 
AUSOUG Analytics Update - Nov 14 2018
AUSOUG Analytics Update - Nov 14 2018AUSOUG Analytics Update - Nov 14 2018
AUSOUG Analytics Update - Nov 14 2018
 
CAS SciFinder Discovery Platform Quick Reference Guide_2023(EN)
CAS SciFinder Discovery Platform Quick Reference Guide_2023(EN)CAS SciFinder Discovery Platform Quick Reference Guide_2023(EN)
CAS SciFinder Discovery Platform Quick Reference Guide_2023(EN)
 
Fuzzing - A Tale of Two Cultures
Fuzzing - A Tale of Two CulturesFuzzing - A Tale of Two Cultures
Fuzzing - A Tale of Two Cultures
 
Painful Success - Lessons Learned while Scaling Up
Painful Success - Lessons Learned while Scaling UpPainful Success - Lessons Learned while Scaling Up
Painful Success - Lessons Learned while Scaling Up
 
SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP SkiPHP -- Database Basics for PHP
SkiPHP -- Database Basics for PHP
 
Reproducible Workflow with Cytoscape and Jupyter Notebook
Reproducible Workflow with Cytoscape and Jupyter NotebookReproducible Workflow with Cytoscape and Jupyter Notebook
Reproducible Workflow with Cytoscape and Jupyter Notebook
 

Recently uploaded

一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
osoyvvf
 
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdfreading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
perranet1
 
Sample Devops SRE Product Companies .pdf
Sample Devops SRE  Product Companies .pdfSample Devops SRE  Product Companies .pdf
Sample Devops SRE Product Companies .pdf
Vineet
 
Sid Sigma educational and problem solving power point- Six Sigma.ppt
Sid Sigma educational and problem solving power point- Six Sigma.pptSid Sigma educational and problem solving power point- Six Sigma.ppt
Sid Sigma educational and problem solving power point- Six Sigma.ppt
ArshadAyub49
 
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdfOverview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
nhutnguyen355078
 
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
agdhot
 
Build applications with generative AI on Google Cloud
Build applications with generative AI on Google CloudBuild applications with generative AI on Google Cloud
Build applications with generative AI on Google Cloud
Márton Kodok
 
一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理
keesa2
 
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Marlon Dumas
 
Template xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptxTemplate xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptx
TeukuEriSyahputra
 
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative ClassifiersML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
MastanaihnaiduYasam
 
Drownings spike from May to August in children
Drownings spike from May to August in childrenDrownings spike from May to August in children
Drownings spike from May to August in children
Bisnar Chase Personal Injury Attorneys
 
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理 原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
tzu5xla
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
uevausa
 
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
lzdvtmy8
 
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
Timothy Spann
 
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
ywqeos
 
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdfNamma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
22ad0301
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
ihavuls
 
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
eudsoh
 

Recently uploaded (20)

一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
一比一原版(uom毕业证书)曼彻斯特大学毕业证如何办理
 
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdfreading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
reading_sample_sap_press_operational_data_provisioning_with_sap_bw4hana (1).pdf
 
Sample Devops SRE Product Companies .pdf
Sample Devops SRE  Product Companies .pdfSample Devops SRE  Product Companies .pdf
Sample Devops SRE Product Companies .pdf
 
Sid Sigma educational and problem solving power point- Six Sigma.ppt
Sid Sigma educational and problem solving power point- Six Sigma.pptSid Sigma educational and problem solving power point- Six Sigma.ppt
Sid Sigma educational and problem solving power point- Six Sigma.ppt
 
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdfOverview IFM June 2024 Consumer Confidence INDEX Report.pdf
Overview IFM June 2024 Consumer Confidence INDEX Report.pdf
 
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
一比一原版加拿大麦吉尔大学毕业证(mcgill毕业证书)如何办理
 
Build applications with generative AI on Google Cloud
Build applications with generative AI on Google CloudBuild applications with generative AI on Google Cloud
Build applications with generative AI on Google Cloud
 
一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理一比一原版悉尼大学毕业证如何办理
一比一原版悉尼大学毕业证如何办理
 
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
Discovering Digital Process Twins for What-if Analysis: a Process Mining Appr...
 
Template xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptxTemplate xxxxxxxx ssssssssssss Sertifikat.pptx
Template xxxxxxxx ssssssssssss Sertifikat.pptx
 
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative ClassifiersML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
ML-PPT-UNIT-2 Generative Classifiers Discriminative Classifiers
 
Drownings spike from May to August in children
Drownings spike from May to August in childrenDrownings spike from May to August in children
Drownings spike from May to August in children
 
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理 原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
原版一比一爱尔兰都柏林大学毕业证(UCD毕业证书)如何办理
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
 
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
一比一原版格里菲斯大学毕业证(Griffith毕业证书)学历如何办理
 
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
06-20-2024-AI Camp Meetup-Unstructured Data and Vector Databases
 
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
一比一原版(lbs毕业证书)伦敦商学院毕业证如何办理
 
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdfNamma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
Namma-Kalvi-11th-Physics-Study-Material-Unit-1-EM-221086.pdf
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
一比一原版马来西亚博特拉大学毕业证(upm毕业证)如何办理
 

Why Isn't My Query Using an Index? An Introduction to SQL Performance

  • 1. developer.oracle.com/code Why Isn't My Query Using an Index? Chris Saxon, Oracle Developer Advocate for SQL chris.saxon@oracle.com @chrisrsaxon & @sqldaily blogs.oracle.com/sql www.youtube.com/c/TheMagicofSQL An introduction to SQL performance
  • 2. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Why isn’t Oracle using my #@!% index?! blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 3. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 4. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
  • 5. Colour BAG Colour BAG Colour BAG Colour BAG Colour BAG Blue 73 Brown 56 Green 11 Orange 19 Red 2 Blue 31 Brown 40 Green 31 Orange 19 Red 41 Blue 1 Brown 41 Green 70 Orange 85 Red 21 Blue 64 Brown 65 Green 4 Red 42 Red 32 Blue 69 Brown 23 Green 80 Red 100 Red 12 Blue 85 Brown 21 Green 28 Red 70 Red 83 Blue 84 Brown 73 Green 44 Red 38 Yellow 29 Blue 40 Brown 97 Green 99 Red 33 Yellow 31 Blue 41 Brown 57 Green 32 Red 63 Yellow 51 Blue 88 Brown 63 Orange 85 Red 22 Yellow 33 Blue 100 Brown 100 Orange 21 Red 80 Yellow 4 Blue 6 Brown 80 Orange 76 Red 80 Yellow 9 Blue 64 Brown 75 Orange 32 Red 40 Yellow 27 Blue 90 Green 20 Orange 93 Red 68 Yellow 48 Blue 24 Green 50 Orange 70 Red 54 Yellow 56 Brown 88 Green 85 Orange 2 Red 93 Yellow 15 Brown 50 Green 17 Orange 15 Red 93 Yellow 81 Brown 69 Green 27 Orange 5 Red 20 Yellow 83 blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 6. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | What’s this got to do with ? blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 7. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | M&M => a row Document => an index Bag => a block blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 8. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Method #1 => TABLE ACCESS FULL Method #2 => INDEX RANGE SCAN Multiblock reads Single block reads blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 9. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Source: Pixabay Which is faster? blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 10. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | FULL TABLE SCAN Visit each bag once INDEX RANGE SCAN Visit each bag ~10 times blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 11. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | What if there’s a Promotion? silver sweets in 1% of bags blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 12. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | FULL TABLE SCAN Visit each bag once INDEX RANGE SCAN One bag visit blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 13. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | The Cost Based Optimizer estimates these calculations blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 14. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | DEMO blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 15. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | "M & Ms (3685102458)" by Greg Willis from Denver, CO, usa Uploaded by russavia. CC BY-SA 2.0 blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 16. Colour BAG Colour BAG Colour BAG Colour BAG Colour BAG Blue 1 Brown 7 Green 13 Orange 19 Red 25 Blue 1 Brown 7 Green 13 Orange 19 Red 25 Blue 1 Brown 7 Green 13 Orange 19 Red 25 Blue 2 Brown 8 Green 14 Red 20 Red 26 Blue 2 Brown 8 Green 14 Red 20 Red 26 Blue 2 Brown 8 Green 14 Red 20 Red 26 Blue 3 Brown 9 Green 15 Red 21 Yellow 27 Blue 3 Brown 9 Green 15 Red 21 Yellow 27 Blue 3 Brown 9 Green 15 Red 21 Yellow 27 Blue 4 Brown 10 Orange 16 Red 22 Yellow 28 Blue 4 Brown 10 Orange 16 Red 22 Yellow 28 Blue 4 Brown 10 Orange 16 Red 22 Yellow 28 Blue 5 Brown 10 Orange 17 Red 23 Yellow 29 Blue 5 Green 11 Orange 17 Red 23 Yellow 29 Blue 5 Green 11 Orange 17 Red 23 Yellow 29 Brown 6 Green 11 Orange 18 Red 24 Yellow 30 Brown 6 Green 12 Orange 18 Red 24 Yellow 30 Brown 6 Green 12 Orange 18 Red 24 Yellow 30blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 17. Colour BAG Colour BAG Colour BAG Colour BAG Colour BAG Blue 1 Brown 3 Green 4 Orange 7 Red 9 Blue 1 Brown 4 Green 4 Orange 8 Red 9 Blue 2 Brown 5 Green 5 Orange 9 Red 9 Blue 2 Brown 5 Green 6 Red 1 Red 9 Blue 3 Brown 5 Green 6 Red 2 Red 10 Blue 4 Brown 6 Green 7 Red 2 Red 10 Blue 6 Brown 7 Green 8 Red 3 Yellow 1 Blue 7 Brown 8 Green 8 Red 3 Yellow 1 Blue 7 Brown 8 Green 10 Red 4 Yellow 2 Blue 8 Brown 9 Orange 1 Red 4 Yellow 2 Blue 9 Brown 9 Orange 2 Red 5 Yellow 3 Blue 9 Brown 10 Orange 3 Red 6 Yellow 5 Blue 10 Brown 10 Orange 3 Red 6 Yellow 5 Blue 10 Green 1 Orange 4 Red 7 Yellow 6 Blue 10 Green 2 Orange 4 Red 7 Yellow 7 Brown 2 Green 3 Orange 5 Red 8 Yellow 8 Brown 2 Green 3 Orange 6 Red 8 Yellow 9 Brown 2 Green 3 Orange 6 Red 8 Yellow 10blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 19. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | clustering factor = 10 (good) blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 20. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | clustering factor = 120 (bad) blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 21. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | DEMO blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 22. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | How do I Improve the clustering factor? blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 23. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Tannin Heap Simon A. Eugster CC-BY-3.0 By default tables are blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 24. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Organized Part ition ed Clusters How do I force the clustering? blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 25. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | There can be only 1! blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 26. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Colour Weight blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 27. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | inter d attr clust leave ibute ering blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 28. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Cost Rows Full Table Scan Index Range Scan 1 Index Range Scan 2 Index Range Scan 3 blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 29. Rows “Toy Blocks (6831034024)” welcometolearn CC BY 2.0 blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon
  • 30. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | www.youtube.com/c/TheMagicofSQL #MakeDataGreatAgain Gratisography blogs.oracle.com/sql www.youtube.com/c/TheMagicOfSQL @ChrisRSaxon