SlideShare a Scribd company logo
Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 1
Why Isn't My Query Using an Index?
An introduction to SQL performance
Chris Saxon, Oracle Developer Advocate for SQL
chris.saxon@oracle.com
@chrisrsaxon & @sqldaily
blogs.oracle.com/sql
www.youtube.com/c/TheMagicofSQL
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Why isn’t Oracle using my
#@!%
index?!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2015, 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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
What’s this got to do with
?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
M&M => a row
Document => an index
A bag => a block
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Method #1 => TABLE ACCESS FULL
Method #2 => INDEX RANGE SCAN
Multiblock reads
Single block reads
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Source: Pixabay
Which is faster?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
FULL TABLE SCAN
Visit each bag once
INDEX RANGE SCAN
Visit each bag ~10 times
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
What if there’s a
Promotion?
silver sweets in 1% of bags
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
FULL TABLE SCAN
Visit each bag once
INDEX RANGE SCAN
One bag visit
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
The
Cost Based Optimizer
estimates these calculations
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
DEMO
Copyright © 2015, 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
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 30
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 10
Clustering factor
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
clustering factor = 10 (good)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
clustering factor = 120 (bad)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
DEMO
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
How do I
Improve
the clustering factor?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Tannin Heap Simon A. Eugster CC-BY-3.0
By default
tables are
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Organized
Part ition ed
Clusters
How do I ensure
consistent
clustering?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
There can be only 1!
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Colour
Weight
Copyright © 2015, 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
Rows
“Toy Blocks (6831034024)” welcometolearn CC BY 2.0
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
developer.oracle.com
#MakeDataGreatAgain
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

Img.kgn shortpres.2014
Img.kgn shortpres.2014Img.kgn shortpres.2014
Img.kgn shortpres.2014
imgprocurement
 
1.3 session by klanarong cassava as a biofuel-bioenergy crop ghana
1.3 session by klanarong   cassava as a biofuel-bioenergy crop ghana1.3 session by klanarong   cassava as a biofuel-bioenergy crop ghana
1.3 session by klanarong cassava as a biofuel-bioenergy crop ghana
IFAD International Fund for Agricultural Development
 
The top ten producers of pistachios and turkey's ranking among them
The top ten producers of pistachios and turkey's ranking among themThe top ten producers of pistachios and turkey's ranking among them
The top ten producers of pistachios and turkey's ranking among them
ALADDIN PERTANIAN INTERNASIONAL
 
Every Product Every Cycle in Production
Every Product Every Cycle in ProductionEvery Product Every Cycle in Production
Every Product Every Cycle in Production
Lean Enterprise Academy
 
The top ten producers of strawberries and turkey's ranking among them
The top ten producers of strawberries and turkey's ranking among themThe top ten producers of strawberries and turkey's ranking among them
The top ten producers of strawberries and turkey's ranking among them
ALADDIN PERTANIAN INTERNASIONAL
 
iScreen OFD Oral Fluid Drug Screen Procedures
iScreen OFD Oral Fluid Drug Screen ProceduresiScreen OFD Oral Fluid Drug Screen Procedures
iScreen OFD Oral Fluid Drug Screen Procedures
Michael Zures
 
iScreen OFD Procedures
iScreen OFD ProceduresiScreen OFD Procedures
iScreen OFD Procedures
Jeremy Janke
 
The top ten producers of grapes and turkey's ranking among them
The top ten producers of grapes and turkey's ranking among themThe top ten producers of grapes and turkey's ranking among them
The top ten producers of grapes and turkey's ranking among them
ALADDIN PERTANIAN INTERNASIONAL
 
Karennita RS - Probation Presentation.pptx
Karennita RS - Probation Presentation.pptxKarennita RS - Probation Presentation.pptx
Karennita RS - Probation Presentation.pptx
arfian9
 
neostigmine.pptxhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
neostigmine.pptxhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhneostigmine.pptxhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
neostigmine.pptxhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
MagdielaCristancho
 
Ferdinand · SlidesCarnival.pptx
Ferdinand · SlidesCarnival.pptxFerdinand · SlidesCarnival.pptx
Ferdinand · SlidesCarnival.pptx
FelisbertoAguiarMuan
 
modelo edgar.pptx
modelo edgar.pptxmodelo edgar.pptx
modelo edgar.pptx
SantiagoApaza7
 
The top ten producers of oranges and turkey's ranking among them
The top ten producers of oranges and turkey's ranking among themThe top ten producers of oranges and turkey's ranking among them
The top ten producers of oranges and turkey's ranking among them
ALADDIN PERTANIAN INTERNASIONAL
 
Brabantio · SlidesCarnival.pptx
Brabantio · SlidesCarnival.pptxBrabantio · SlidesCarnival.pptx
Brabantio · SlidesCarnival.pptx
TiffanyMeneses1
 
Brabantio · SlidesCarnival.pptx
Brabantio · SlidesCarnival.pptxBrabantio · SlidesCarnival.pptx
Brabantio · SlidesCarnival.pptx
asman25
 
The top ten producers of walnuts and turkey's ranking among them
The top ten producers of walnuts and turkey's ranking among themThe top ten producers of walnuts and turkey's ranking among them
The top ten producers of walnuts and turkey's ranking among them
ALADDIN PERTANIAN INTERNASIONAL
 
The top ten producers of almonds and turkey's ranking among them
The top ten producers of almonds and turkey's ranking among themThe top ten producers of almonds and turkey's ranking among them
The top ten producers of almonds and turkey's ranking among them
ALADDIN PERTANIAN INTERNASIONAL
 
Curio · SlidesCarnival.pptx
Curio · SlidesCarnival.pptxCurio · SlidesCarnival.pptx
Curio · SlidesCarnival.pptx
harshit373077
 
Curio · SlidesCarnival.pptx
Curio · SlidesCarnival.pptxCurio · SlidesCarnival.pptx
Curio · SlidesCarnival.pptx
KhaledShukran
 
SMP.pptx
SMP.pptxSMP.pptx
SMP.pptx
GyandeepKumar9
 

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

Img.kgn shortpres.2014
Img.kgn shortpres.2014Img.kgn shortpres.2014
Img.kgn shortpres.2014
 
1.3 session by klanarong cassava as a biofuel-bioenergy crop ghana
1.3 session by klanarong   cassava as a biofuel-bioenergy crop ghana1.3 session by klanarong   cassava as a biofuel-bioenergy crop ghana
1.3 session by klanarong cassava as a biofuel-bioenergy crop ghana
 
The top ten producers of pistachios and turkey's ranking among them
The top ten producers of pistachios and turkey's ranking among themThe top ten producers of pistachios and turkey's ranking among them
The top ten producers of pistachios and turkey's ranking among them
 
Every Product Every Cycle in Production
Every Product Every Cycle in ProductionEvery Product Every Cycle in Production
Every Product Every Cycle in Production
 
The top ten producers of strawberries and turkey's ranking among them
The top ten producers of strawberries and turkey's ranking among themThe top ten producers of strawberries and turkey's ranking among them
The top ten producers of strawberries and turkey's ranking among them
 
iScreen OFD Oral Fluid Drug Screen Procedures
iScreen OFD Oral Fluid Drug Screen ProceduresiScreen OFD Oral Fluid Drug Screen Procedures
iScreen OFD Oral Fluid Drug Screen Procedures
 
iScreen OFD Procedures
iScreen OFD ProceduresiScreen OFD Procedures
iScreen OFD Procedures
 
The top ten producers of grapes and turkey's ranking among them
The top ten producers of grapes and turkey's ranking among themThe top ten producers of grapes and turkey's ranking among them
The top ten producers of grapes and turkey's ranking among them
 
Karennita RS - Probation Presentation.pptx
Karennita RS - Probation Presentation.pptxKarennita RS - Probation Presentation.pptx
Karennita RS - Probation Presentation.pptx
 
neostigmine.pptxhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
neostigmine.pptxhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhneostigmine.pptxhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
neostigmine.pptxhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
 
Ferdinand · SlidesCarnival.pptx
Ferdinand · SlidesCarnival.pptxFerdinand · SlidesCarnival.pptx
Ferdinand · SlidesCarnival.pptx
 
modelo edgar.pptx
modelo edgar.pptxmodelo edgar.pptx
modelo edgar.pptx
 
The top ten producers of oranges and turkey's ranking among them
The top ten producers of oranges and turkey's ranking among themThe top ten producers of oranges and turkey's ranking among them
The top ten producers of oranges and turkey's ranking among them
 
Brabantio · SlidesCarnival.pptx
Brabantio · SlidesCarnival.pptxBrabantio · SlidesCarnival.pptx
Brabantio · SlidesCarnival.pptx
 
Brabantio · SlidesCarnival.pptx
Brabantio · SlidesCarnival.pptxBrabantio · SlidesCarnival.pptx
Brabantio · SlidesCarnival.pptx
 
The top ten producers of walnuts and turkey's ranking among them
The top ten producers of walnuts and turkey's ranking among themThe top ten producers of walnuts and turkey's ranking among them
The top ten producers of walnuts and turkey's ranking among them
 
The top ten producers of almonds and turkey's ranking among them
The top ten producers of almonds and turkey's ranking among themThe top ten producers of almonds and turkey's ranking among them
The top ten producers of almonds and turkey's ranking among them
 
Curio · SlidesCarnival.pptx
Curio · SlidesCarnival.pptxCurio · SlidesCarnival.pptx
Curio · SlidesCarnival.pptx
 
Curio · SlidesCarnival.pptx
Curio · SlidesCarnival.pptxCurio · SlidesCarnival.pptx
Curio · SlidesCarnival.pptx
 
SMP.pptx
SMP.pptxSMP.pptx
SMP.pptx
 

More from TechExeter

Exeter Science Centre, by Natalie Whitehead
Exeter Science Centre, by Natalie WhiteheadExeter Science Centre, by Natalie Whitehead
Exeter Science Centre, by Natalie Whitehead
TechExeter
 
South West InternetOfThings Network by Wo King
South West InternetOfThings Network by Wo KingSouth West InternetOfThings Network by Wo King
South West InternetOfThings Network by Wo King
TechExeter
 
Generative Adversarial Networks by Tariq Rashid
Generative Adversarial Networks by Tariq RashidGenerative Adversarial Networks by Tariq Rashid
Generative Adversarial Networks by Tariq Rashid
TechExeter
 
Conf 2019 - Workshop: Liam Glanfield - know your threat actor
Conf 2019 - Workshop: Liam Glanfield - know your threat actorConf 2019 - Workshop: Liam Glanfield - know your threat actor
Conf 2019 - Workshop: Liam Glanfield - know your threat actor
TechExeter
 
Conf 2018 Track 1 - Unicorns aren't real
Conf 2018 Track 1 - Unicorns aren't realConf 2018 Track 1 - Unicorns aren't real
Conf 2018 Track 1 - Unicorns aren't real
TechExeter
 
Conf 2018 Track 1 - Aerospace Innovation
Conf 2018 Track 1 - Aerospace InnovationConf 2018 Track 1 - Aerospace Innovation
Conf 2018 Track 1 - Aerospace Innovation
TechExeter
 
Conf 2018 Track 2 - Try Elm
Conf 2018 Track 2 - Try ElmConf 2018 Track 2 - Try Elm
Conf 2018 Track 2 - Try Elm
TechExeter
 
Conf 2018 Track 3 - Creating marine geospatial services
Conf 2018 Track 3 - Creating marine geospatial servicesConf 2018 Track 3 - Creating marine geospatial services
Conf 2018 Track 3 - Creating marine geospatial services
TechExeter
 
Conf 2018 Track 2 - Machine Learning with TensorFlow
Conf 2018 Track 2 - Machine Learning with TensorFlowConf 2018 Track 2 - Machine Learning with TensorFlow
Conf 2018 Track 2 - Machine Learning with TensorFlow
TechExeter
 
Conf 2018 Track 2 - Custom Web Elements with Stencil
Conf 2018 Track 2 - Custom Web Elements with StencilConf 2018 Track 2 - Custom Web Elements with Stencil
Conf 2018 Track 2 - Custom Web Elements with Stencil
TechExeter
 
Conf 2018 Track 1 - Tessl / revolutionising the house moving process
Conf 2018 Track 1 - Tessl / revolutionising the house moving processConf 2018 Track 1 - Tessl / revolutionising the house moving process
Conf 2018 Track 1 - Tessl / revolutionising the house moving process
TechExeter
 
Conf 2018 Keynote - Andy Stanford-Clark, CTO IBM UK
Conf 2018 Keynote - Andy Stanford-Clark, CTO IBM UKConf 2018 Keynote - Andy Stanford-Clark, CTO IBM UK
Conf 2018 Keynote - Andy Stanford-Clark, CTO IBM UK
TechExeter
 
Conf 2018 Track 3 - Microservices - What I've learned after a year building s...
Conf 2018 Track 3 - Microservices - What I've learned after a year building s...Conf 2018 Track 3 - Microservices - What I've learned after a year building s...
Conf 2018 Track 3 - Microservices - What I've learned after a year building s...
TechExeter
 
Gps behaving badly - Guy Busenel
Gps behaving badly - Guy BusenelGps behaving badly - Guy Busenel
Gps behaving badly - Guy Busenel
TechExeter
 
Turning Developers into Testers
Turning Developers into TestersTurning Developers into Testers
Turning Developers into Testers
TechExeter
 
Remote working
Remote workingRemote working
Remote working
TechExeter
 
Developing an Agile Mindset
Developing an Agile Mindset Developing an Agile Mindset
Developing an Agile Mindset
TechExeter
 
Think like a gardener
Think like a gardenerThink like a gardener
Think like a gardener
TechExeter
 
The trials and tribulations of providing engineering infrastructure
 The trials and tribulations of providing engineering infrastructure  The trials and tribulations of providing engineering infrastructure
The trials and tribulations of providing engineering infrastructure
TechExeter
 
Scaling clusters to thousands of servers in the cloud
Scaling clusters to thousands of servers in the cloudScaling clusters to thousands of servers in the cloud
Scaling clusters to thousands of servers in the cloud
TechExeter
 

More from TechExeter (20)

Exeter Science Centre, by Natalie Whitehead
Exeter Science Centre, by Natalie WhiteheadExeter Science Centre, by Natalie Whitehead
Exeter Science Centre, by Natalie Whitehead
 
South West InternetOfThings Network by Wo King
South West InternetOfThings Network by Wo KingSouth West InternetOfThings Network by Wo King
South West InternetOfThings Network by Wo King
 
Generative Adversarial Networks by Tariq Rashid
Generative Adversarial Networks by Tariq RashidGenerative Adversarial Networks by Tariq Rashid
Generative Adversarial Networks by Tariq Rashid
 
Conf 2019 - Workshop: Liam Glanfield - know your threat actor
Conf 2019 - Workshop: Liam Glanfield - know your threat actorConf 2019 - Workshop: Liam Glanfield - know your threat actor
Conf 2019 - Workshop: Liam Glanfield - know your threat actor
 
Conf 2018 Track 1 - Unicorns aren't real
Conf 2018 Track 1 - Unicorns aren't realConf 2018 Track 1 - Unicorns aren't real
Conf 2018 Track 1 - Unicorns aren't real
 
Conf 2018 Track 1 - Aerospace Innovation
Conf 2018 Track 1 - Aerospace InnovationConf 2018 Track 1 - Aerospace Innovation
Conf 2018 Track 1 - Aerospace Innovation
 
Conf 2018 Track 2 - Try Elm
Conf 2018 Track 2 - Try ElmConf 2018 Track 2 - Try Elm
Conf 2018 Track 2 - Try Elm
 
Conf 2018 Track 3 - Creating marine geospatial services
Conf 2018 Track 3 - Creating marine geospatial servicesConf 2018 Track 3 - Creating marine geospatial services
Conf 2018 Track 3 - Creating marine geospatial services
 
Conf 2018 Track 2 - Machine Learning with TensorFlow
Conf 2018 Track 2 - Machine Learning with TensorFlowConf 2018 Track 2 - Machine Learning with TensorFlow
Conf 2018 Track 2 - Machine Learning with TensorFlow
 
Conf 2018 Track 2 - Custom Web Elements with Stencil
Conf 2018 Track 2 - Custom Web Elements with StencilConf 2018 Track 2 - Custom Web Elements with Stencil
Conf 2018 Track 2 - Custom Web Elements with Stencil
 
Conf 2018 Track 1 - Tessl / revolutionising the house moving process
Conf 2018 Track 1 - Tessl / revolutionising the house moving processConf 2018 Track 1 - Tessl / revolutionising the house moving process
Conf 2018 Track 1 - Tessl / revolutionising the house moving process
 
Conf 2018 Keynote - Andy Stanford-Clark, CTO IBM UK
Conf 2018 Keynote - Andy Stanford-Clark, CTO IBM UKConf 2018 Keynote - Andy Stanford-Clark, CTO IBM UK
Conf 2018 Keynote - Andy Stanford-Clark, CTO IBM UK
 
Conf 2018 Track 3 - Microservices - What I've learned after a year building s...
Conf 2018 Track 3 - Microservices - What I've learned after a year building s...Conf 2018 Track 3 - Microservices - What I've learned after a year building s...
Conf 2018 Track 3 - Microservices - What I've learned after a year building s...
 
Gps behaving badly - Guy Busenel
Gps behaving badly - Guy BusenelGps behaving badly - Guy Busenel
Gps behaving badly - Guy Busenel
 
Turning Developers into Testers
Turning Developers into TestersTurning Developers into Testers
Turning Developers into Testers
 
Remote working
Remote workingRemote working
Remote working
 
Developing an Agile Mindset
Developing an Agile Mindset Developing an Agile Mindset
Developing an Agile Mindset
 
Think like a gardener
Think like a gardenerThink like a gardener
Think like a gardener
 
The trials and tribulations of providing engineering infrastructure
 The trials and tribulations of providing engineering infrastructure  The trials and tribulations of providing engineering infrastructure
The trials and tribulations of providing engineering infrastructure
 
Scaling clusters to thousands of servers in the cloud
Scaling clusters to thousands of servers in the cloudScaling clusters to thousands of servers in the cloud
Scaling clusters to thousands of servers in the cloud
 

Recently uploaded

TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
CAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on BlockchainCAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on Blockchain
Claudio Di Ciccio
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdfAI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
Techgropse Pvt.Ltd.
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 

Recently uploaded (20)

TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
CAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on BlockchainCAKE: Sharing Slices of Confidential Data on Blockchain
CAKE: Sharing Slices of Confidential Data on Blockchain
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdfAI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 

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

  • 1. Copyright © 2015 Oracle and/or its affiliates. All rights reserved. | 1 Why Isn't My Query Using an Index? An introduction to SQL performance Chris Saxon, Oracle Developer Advocate for SQL chris.saxon@oracle.com @chrisrsaxon & @sqldaily blogs.oracle.com/sql www.youtube.com/c/TheMagicofSQL
  • 2. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Why isn’t Oracle using my #@!% index?!
  • 3. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
  • 4. Copyright © 2015, 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
  • 6. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | What’s this got to do with ?
  • 7. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | M&M => a row Document => an index A bag => a block
  • 8. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Method #1 => TABLE ACCESS FULL Method #2 => INDEX RANGE SCAN Multiblock reads Single block reads
  • 9. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Source: Pixabay Which is faster?
  • 10. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FULL TABLE SCAN Visit each bag once INDEX RANGE SCAN Visit each bag ~10 times
  • 11. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | What if there’s a Promotion? silver sweets in 1% of bags
  • 12. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | FULL TABLE SCAN Visit each bag once INDEX RANGE SCAN One bag visit
  • 13. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | The Cost Based Optimizer estimates these calculations
  • 14. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | DEMO
  • 15. Copyright © 2015, 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
  • 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 30
  • 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 10
  • 19. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | clustering factor = 10 (good)
  • 20. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | clustering factor = 120 (bad)
  • 21. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | DEMO
  • 22. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | How do I Improve the clustering factor?
  • 23. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Tannin Heap Simon A. Eugster CC-BY-3.0 By default tables are
  • 24. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Organized Part ition ed Clusters How do I ensure consistent clustering?
  • 25. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | There can be only 1!
  • 26. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Colour Weight
  • 27. Copyright © 2015, 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
  • 28. Rows “Toy Blocks (6831034024)” welcometolearn CC BY 2.0
  • 29. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | developer.oracle.com #MakeDataGreatAgain