SlideShare a Scribd company logo
Indexes: Structure, Splits and Free 
Space Management Internals 
OakTable World, 29 September 2014 
Christian Antognini 
BASEL BERN BRUGG LAUSANNE ZUERICH DUESSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MUNICH STUTTGART VIENNA 
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
1
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
2 
@ChrisAntognini 
 Senior principal consultant, trainer and partner 
at Trivadis in Zurich (CH) 
 christian.antognini@trivadis.com 
 http://antognini.ch 
 Focus: get the most out of Oracle Database 
 Logical and physical database design 
 Query optimizer 
 Application performance management 
 Author of Troubleshooting Oracle Performance 
Apress, 2008/2014 
 OakTable Network, Oracle ACE Director
AGENDA 
1. Concepts 
2. Index Keys 
3. Splits 
4. Free Space 
5. Reorganizations 
6. Bitmap 
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
3
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
Concepts 
4
Structure of a B-Tree 
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
5 
24 51 
12 29 42 86 
2 ROWID 
8 ROWID 
10 ROWID 
11 ROWID 
12 ROWID 
18 ROWID 
20 ROWID 
24 ROWID 
26 ROWID 
29 ROWID 
34 ROWID 
38 ROWID 
42 ROWID 51 ROWID 
55 ROWID 
73 ROWID 
branch 
blocks 
86 ROWID 
99 ROWID 
left<24 
right≥24 
leaf blocks 
root block
2014 © Trivadis 
Nulls 
 NULL values are stored in the index only when at least one of the 
indexed columns is not NULL 
 Exception: bitmap indexes always store indexed data 
 For unique indexes the uniqueness is guaranteed only if at least one of 
the indexed columns is not NULL 
 NULL values are stored after not NULL values in the index 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
6
2014 © Trivadis 
Myths 
 Oracle B-tree indexes can become “unbalanced” over time and need to 
be rebuilt 
 Deleted space in an index is “deadwood” and over time requires the 
index to be rebuilt 
 If an index reaches “x” number of levels, it becomes inefficient and 
requires the index to be rebuilt 
 If an index has a poor clustering factor, the index needs to be rebuilt 
 To improve performance, indexes need to be regularly rebuilt 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
7 
Source: Oracle B-Tree Index Internals: Rebuilding The Truth, Richard Foote
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
Index Keys 
8
Internal Key 
 Internally a unique key is needed to sort the indexed columns 
 For unique indexes the internal key is the same as the index key 
 For non-unique indexes the ROWID of the indexed row is added to the 
index key to make it unique 
 For global indexes an extended ROWID is used, otherwise a restricted 
ROWID is enough 
2014 © Trivadis 
 Therefore 
 The index entries are sorted in a consistent way 
 Even for non-unique indexed the order of the index entries changes only 
when the indexed table is reorganized (i.e. not if the index is rebuilt!) 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
9
Branch Block Key 
 In branch blocks the internal key is truncated after the first byte that 
differs from the last key of the left leaf block 
 All keys are preceded by a length field 
 1 byte for data up to 127 bytes 
 Otherwise 2 bytes 
- The high bit of the first byte is set (0x80) 
- The remaining bits of the first byte and the second byte contain the length 
 Partially stored keys are terminated by 0xFE 
 Nulls have a column length of 0xFF, trailing nulls are stored 
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
10 
RDBA 
Len 
Key 1 
Data 
Key 1 
Len 
Key X 
Data 
Key X
Leaf Block Key 
 All keys are preceded by a length field 
 1 byte for data up to 127 bytes 
 Otherwise 2 bytes 
- The high bit of the first byte is set (0x80) 
- The remaining bits of the first byte and the second byte contain the length 
 Nulls have a column length of 0xFF, trailing nulls are stored 
 For global indexes an extended ROWID is used, otherwise a restricted 
ROWID is enough 
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
11 
Flag Lock 
Len 
Key 1 
Data 
Key 1 
Len 
ROWID 
ROWID 
(optional)
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
Splits 
12
2014 © Trivadis 
Splits 
 Two split methods are implemented 
 50:50 split 
 The keys are evenly distributed over two blocks 
 Based on size, not number of keys 
 99:1 split (a.k.a. 90:10) 
 The new key is the right-most of the index 
 A new leaf block containing only the new key is added 
 Useful for increasing values like sequences and timestamps 
 A change in the structure of an index (like a split) is not rollbacked if the 
transaction that caused it is rollbacked 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
13
2014 © Trivadis 
Splits 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
14 
#1
2014 © Trivadis 
Splits 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
15 
#1 
#2 #3
2014 © Trivadis 
Splits 
#2 #4 #3 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
16 
#1 
#2 #3
2014 © Trivadis 
Splits 
#1 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
17 
#1 
#2 #4 #3 #5 
#2 #4 #3
2014 © Trivadis 
Splits 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
18
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
Free Space 
19
Reminder 
 PCTFREE is only used when the index is created (or rebuilt) 
 An update is implemented as a delete followed by an insert 
 The free space in leaf blocks is strongly dependent on the type of split (50:50 
2014 © Trivadis 
or 99:1) 
 PCTUSED cannot be used for indexes 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
20
Free Space 
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
21 
#1 
#2 #3 #4
Free Space 
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
22 
#1 
#2 #4 #3
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
Reorganizations 
23
Reorganizations 
 If the free space is not automatically reused, it should be manually 
reclaimed 
 This is unusual, therefore such an operation should only be performed if it is 
really necessary 
 To manually reclaim free space two possibilities exists 
 Rebuild: the index is recreated 
 Coalesce: free space in contiguous blocks is merged and, therefore, some 
blocks are unchained 
 Unnecessary rebuild/coalesce may lead to sub-optimal data density in 
leaf blocks 
 Too much free space, i.e. too low density 
 Too much block splits, i.e. too high density 
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
24
Rebuild vs. Coalesce 
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
25 
Pro Cons 
Rebuild 
 Doesn’t lock table 
(online rebuilds only) 
 Reclaim all the free 
space 
 Locks table during rebuild 
(offline rebuilds only) 
 Doubles space usage 
temporarily 
 The index is completely 
recreated (to do so large 
sorts may be performed) 
Coalesce 
 Doesn’t lock table 
 Current index structure is 
reused 
 Doesn’t reclaim all the free 
space 
 Can generate lot of redo
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
Bitmap 
26
2014 © Trivadis 
Bitmap 
 A bitmap index is a regular B-tree, only the internal key differs from the 
non-bitmap index! 
 The key is composed by 
 Indexed column(s) 
 Start/End ROWID 
 Bitmap representing the rows that have the key 
- To save space it is “compressed” 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
27
Summary 
2014 © Trivadis 
 B-tree indexes cannot become 
“unbalanced” 
 Deleted space in an index can 
be reused 
 Indexes do not need to be 
regularly rebuilt 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
28
Questions and answers ... 
Christian Antognini 
Senior Principal Consultant 
christian.antognini@trivadis.com 
BASEL BERN BRUGG LAUSANNE ZUERICH DUESSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MUNICH STUTTGART VIENNA 
2014 © Trivadis 
Indexes: Structure, Splits and Free Space Management Internals 
29 September 2014 
29

More Related Content

PDF
Oracle Database In-Memory and the Query Optimizer
PPTX
Adaptive Query Optimization
PDF
Oracle Database 12.1.0.2 New Performance Features
PDF
12c In Memory Management - Saurabh Gupta
PDF
Query optimizer vivek sharma
PDF
Online Statistics Gathering for ETL
PDF
Database and application performance vivek sharma
PDF
Indexing Strategies for Oracle Databases - Beyond the Create Index Statement
Oracle Database In-Memory and the Query Optimizer
Adaptive Query Optimization
Oracle Database 12.1.0.2 New Performance Features
12c In Memory Management - Saurabh Gupta
Query optimizer vivek sharma
Online Statistics Gathering for ETL
Database and application performance vivek sharma
Indexing Strategies for Oracle Databases - Beyond the Create Index Statement

What's hot (20)

PDF
Properly Use Parallel DML for ETL
PDF
How should I monitor my idaa
PDF
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
PPTX
Adaptive Query Optimization in 12c
PDF
The Top 12 Features new to Oracle 12c
PDF
Adaptive Query Optimization
PDF
DB2 LUW Access Plan Stability
PPTX
Understanding DB2 Optimizer
PDF
Db2 analytics accelerator technical update
PPTX
Dan Hotka's Top 10 Oracle 12c New Features
PPTX
Oracle sql high performance tuning
PDF
Db2 for z os trends
PPTX
Sql and PL/SQL Best Practices I
PDF
Developers' mDay 2017. - Bogdan Kecman Oracle
PPTX
Indexing in Exadata
PDF
PostgreSQL 9.6 Performance-Scalability Improvements
PPTX
Part2 Best Practices for Managing Optimizer Statistics
PDF
Best Practices for Oracle Exadata and the Oracle Optimizer
PPTX
Top 10 tips for Oracle performance
PPTX
Part1 of SQL Tuning Workshop - Understanding the Optimizer
Properly Use Parallel DML for ETL
How should I monitor my idaa
Perfect trio : temporal tables, transparent archiving in db2 for z_os and idaa
Adaptive Query Optimization in 12c
The Top 12 Features new to Oracle 12c
Adaptive Query Optimization
DB2 LUW Access Plan Stability
Understanding DB2 Optimizer
Db2 analytics accelerator technical update
Dan Hotka's Top 10 Oracle 12c New Features
Oracle sql high performance tuning
Db2 for z os trends
Sql and PL/SQL Best Practices I
Developers' mDay 2017. - Bogdan Kecman Oracle
Indexing in Exadata
PostgreSQL 9.6 Performance-Scalability Improvements
Part2 Best Practices for Managing Optimizer Statistics
Best Practices for Oracle Exadata and the Oracle Optimizer
Top 10 tips for Oracle performance
Part1 of SQL Tuning Workshop - Understanding the Optimizer
Ad

Viewers also liked (20)

PDF
Profiling the logwriter and database writer
PPTX
Christo kutrovsky oracle, memory & linux
PDF
DevOps and its impact
PDF
Free Load Testing Tools for Oracle Database – Which One Do I Use?
PDF
Dan Norris: Exadata security
PPTX
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
PPTX
OakTable World Sep14 clonedb
PPT
Free space managment46
PDF
Oaktable World 2014 Kevin Closson: SLOB – For More Than I/O!
PPTX
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
PPT
Intro to ASH
PPT
Ash masters : advanced ash analytics on Oracle
PDF
How to find and fix your Oracle application performance problem
PPT
Oracle Open World Thursday 230 ashmasters
PDF
AWR Ambiguity: Performance reasoning when the numbers don't add up
PPTX
Data control
PDF
Oracle Database on ACFS: a perfect marriage?
PDF
Oaktable World 2014 Toon Koppelaars: database constraints polite excuse
PDF
Worst Practices in Data Warehouse Design
PPSX
Introducing the eDB360 Tool
Profiling the logwriter and database writer
Christo kutrovsky oracle, memory & linux
DevOps and its impact
Free Load Testing Tools for Oracle Database – Which One Do I Use?
Dan Norris: Exadata security
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
OakTable World Sep14 clonedb
Free space managment46
Oaktable World 2014 Kevin Closson: SLOB – For More Than I/O!
OakTable World 2015 - Using XMLType content with the Oracle In-Memory Column...
Intro to ASH
Ash masters : advanced ash analytics on Oracle
How to find and fix your Oracle application performance problem
Oracle Open World Thursday 230 ashmasters
AWR Ambiguity: Performance reasoning when the numbers don't add up
Data control
Oracle Database on ACFS: a perfect marriage?
Oaktable World 2014 Toon Koppelaars: database constraints polite excuse
Worst Practices in Data Warehouse Design
Introducing the eDB360 Tool
Ad

Similar to Indexes: Structure, Splits and Free Space Management Internals (20)

PPTX
Partitioning your Oracle Data Warehouse - Just a simple task?
PPTX
Data Warehousing and Bitmap Indexes - More than just some bits
PDF
Indexes overview
PDF
Steam Learn: Introduction to RDBMS indexes
PPTX
Vertex BD. Development of 2014 version.
PPT
Software System Engineering - Chapter 15
PPTX
Management productivity tools1
PPTX
Management productivity tools1
PPT
Module08
PPT
Module08
PPT
Software Engineering Lec 8-design-
PPTX
Top 10 Interview Questions for Solidworks
PPT
Revised CHAPTER-SEVEN.pptggggggggggggggg
PPTX
Five Tips to Get the Most Out of Your Indexing
PDF
Object Oriented Design
PDF
Top 35-interview-questions-on-sap-abap
PPT
Filtered Indexes In Sql 2008
PDF
CREO / PROE QUESTIONS
PPTX
Tableau interview questions www.bigclasses.com
PPTX
Optimizing Application Performance - 2022.pptx
Partitioning your Oracle Data Warehouse - Just a simple task?
Data Warehousing and Bitmap Indexes - More than just some bits
Indexes overview
Steam Learn: Introduction to RDBMS indexes
Vertex BD. Development of 2014 version.
Software System Engineering - Chapter 15
Management productivity tools1
Management productivity tools1
Module08
Module08
Software Engineering Lec 8-design-
Top 10 Interview Questions for Solidworks
Revised CHAPTER-SEVEN.pptggggggggggggggg
Five Tips to Get the Most Out of Your Indexing
Object Oriented Design
Top 35-interview-questions-on-sap-abap
Filtered Indexes In Sql 2008
CREO / PROE QUESTIONS
Tableau interview questions www.bigclasses.com
Optimizing Application Performance - 2022.pptx

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Encapsulation theory and applications.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPT
Teaching material agriculture food technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Building Integrated photovoltaic BIPV_UPV.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Encapsulation theory and applications.pdf
The AUB Centre for AI in Media Proposal.docx
20250228 LYD VKU AI Blended-Learning.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Mobile App Security Testing_ A Comprehensive Guide.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation_ Review paper, used for researhc scholars
Unlocking AI with Model Context Protocol (MCP)
Diabetes mellitus diagnosis method based random forest with bat algorithm
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Teaching material agriculture food technology
Digital-Transformation-Roadmap-for-Companies.pptx

Indexes: Structure, Splits and Free Space Management Internals

  • 1. Indexes: Structure, Splits and Free Space Management Internals OakTable World, 29 September 2014 Christian Antognini BASEL BERN BRUGG LAUSANNE ZUERICH DUESSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MUNICH STUTTGART VIENNA 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 1
  • 2. 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 2 @ChrisAntognini  Senior principal consultant, trainer and partner at Trivadis in Zurich (CH)  christian.antognini@trivadis.com  http://antognini.ch  Focus: get the most out of Oracle Database  Logical and physical database design  Query optimizer  Application performance management  Author of Troubleshooting Oracle Performance Apress, 2008/2014  OakTable Network, Oracle ACE Director
  • 3. AGENDA 1. Concepts 2. Index Keys 3. Splits 4. Free Space 5. Reorganizations 6. Bitmap 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 3
  • 4. 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 Concepts 4
  • 5. Structure of a B-Tree 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 5 24 51 12 29 42 86 2 ROWID 8 ROWID 10 ROWID 11 ROWID 12 ROWID 18 ROWID 20 ROWID 24 ROWID 26 ROWID 29 ROWID 34 ROWID 38 ROWID 42 ROWID 51 ROWID 55 ROWID 73 ROWID branch blocks 86 ROWID 99 ROWID left<24 right≥24 leaf blocks root block
  • 6. 2014 © Trivadis Nulls  NULL values are stored in the index only when at least one of the indexed columns is not NULL  Exception: bitmap indexes always store indexed data  For unique indexes the uniqueness is guaranteed only if at least one of the indexed columns is not NULL  NULL values are stored after not NULL values in the index Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 6
  • 7. 2014 © Trivadis Myths  Oracle B-tree indexes can become “unbalanced” over time and need to be rebuilt  Deleted space in an index is “deadwood” and over time requires the index to be rebuilt  If an index reaches “x” number of levels, it becomes inefficient and requires the index to be rebuilt  If an index has a poor clustering factor, the index needs to be rebuilt  To improve performance, indexes need to be regularly rebuilt Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 7 Source: Oracle B-Tree Index Internals: Rebuilding The Truth, Richard Foote
  • 8. 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 Index Keys 8
  • 9. Internal Key  Internally a unique key is needed to sort the indexed columns  For unique indexes the internal key is the same as the index key  For non-unique indexes the ROWID of the indexed row is added to the index key to make it unique  For global indexes an extended ROWID is used, otherwise a restricted ROWID is enough 2014 © Trivadis  Therefore  The index entries are sorted in a consistent way  Even for non-unique indexed the order of the index entries changes only when the indexed table is reorganized (i.e. not if the index is rebuilt!) Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 9
  • 10. Branch Block Key  In branch blocks the internal key is truncated after the first byte that differs from the last key of the left leaf block  All keys are preceded by a length field  1 byte for data up to 127 bytes  Otherwise 2 bytes - The high bit of the first byte is set (0x80) - The remaining bits of the first byte and the second byte contain the length  Partially stored keys are terminated by 0xFE  Nulls have a column length of 0xFF, trailing nulls are stored 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 10 RDBA Len Key 1 Data Key 1 Len Key X Data Key X
  • 11. Leaf Block Key  All keys are preceded by a length field  1 byte for data up to 127 bytes  Otherwise 2 bytes - The high bit of the first byte is set (0x80) - The remaining bits of the first byte and the second byte contain the length  Nulls have a column length of 0xFF, trailing nulls are stored  For global indexes an extended ROWID is used, otherwise a restricted ROWID is enough 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 11 Flag Lock Len Key 1 Data Key 1 Len ROWID ROWID (optional)
  • 12. 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 Splits 12
  • 13. 2014 © Trivadis Splits  Two split methods are implemented  50:50 split  The keys are evenly distributed over two blocks  Based on size, not number of keys  99:1 split (a.k.a. 90:10)  The new key is the right-most of the index  A new leaf block containing only the new key is added  Useful for increasing values like sequences and timestamps  A change in the structure of an index (like a split) is not rollbacked if the transaction that caused it is rollbacked Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 13
  • 14. 2014 © Trivadis Splits Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 14 #1
  • 15. 2014 © Trivadis Splits Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 15 #1 #2 #3
  • 16. 2014 © Trivadis Splits #2 #4 #3 Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 16 #1 #2 #3
  • 17. 2014 © Trivadis Splits #1 Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 17 #1 #2 #4 #3 #5 #2 #4 #3
  • 18. 2014 © Trivadis Splits Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 18
  • 19. 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 Free Space 19
  • 20. Reminder  PCTFREE is only used when the index is created (or rebuilt)  An update is implemented as a delete followed by an insert  The free space in leaf blocks is strongly dependent on the type of split (50:50 2014 © Trivadis or 99:1)  PCTUSED cannot be used for indexes Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 20
  • 21. Free Space 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 21 #1 #2 #3 #4
  • 22. Free Space 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 22 #1 #2 #4 #3
  • 23. 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 Reorganizations 23
  • 24. Reorganizations  If the free space is not automatically reused, it should be manually reclaimed  This is unusual, therefore such an operation should only be performed if it is really necessary  To manually reclaim free space two possibilities exists  Rebuild: the index is recreated  Coalesce: free space in contiguous blocks is merged and, therefore, some blocks are unchained  Unnecessary rebuild/coalesce may lead to sub-optimal data density in leaf blocks  Too much free space, i.e. too low density  Too much block splits, i.e. too high density 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 24
  • 25. Rebuild vs. Coalesce 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 25 Pro Cons Rebuild  Doesn’t lock table (online rebuilds only)  Reclaim all the free space  Locks table during rebuild (offline rebuilds only)  Doubles space usage temporarily  The index is completely recreated (to do so large sorts may be performed) Coalesce  Doesn’t lock table  Current index structure is reused  Doesn’t reclaim all the free space  Can generate lot of redo
  • 26. 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 Bitmap 26
  • 27. 2014 © Trivadis Bitmap  A bitmap index is a regular B-tree, only the internal key differs from the non-bitmap index!  The key is composed by  Indexed column(s)  Start/End ROWID  Bitmap representing the rows that have the key - To save space it is “compressed” Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 27
  • 28. Summary 2014 © Trivadis  B-tree indexes cannot become “unbalanced”  Deleted space in an index can be reused  Indexes do not need to be regularly rebuilt Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 28
  • 29. Questions and answers ... Christian Antognini Senior Principal Consultant christian.antognini@trivadis.com BASEL BERN BRUGG LAUSANNE ZUERICH DUESSELDORF FRANKFURT A.M. FREIBURG I.BR. HAMBURG MUNICH STUTTGART VIENNA 2014 © Trivadis Indexes: Structure, Splits and Free Space Management Internals 29 September 2014 29