4-oracle-developer-tables-indexes-essentials-m4-slides
4-oracle-developer-tables-indexes-essentials-m4-slides
David Berry
http://buildingbettersoftware.blogspot.com/
Introduction
students table
student_id first_name last_name phone
PCTFREE and
Row Migration Freelists Row Chaining
PCTUSED
Database Blocks
Client
Oracle Instance Physical
Application
Storage
Database Block
Block Header Block Header
• Block type information Row
• Object assignment
Row
• Row directory
Row
Row
Data Row
• Actual data for your table Free Space
Row
Row
Free Space
• Allows for updates to rows Row
Free Space
Oracle Storage Terminology
Data block
Data block
Data block
Data block
Data block
Data block
Data block
Data block
Data block
Data block
Data block
Data block
Data block
Data block
Index Operation and Row Lookup
datafile
datafile
datafile
Tablespace Block Size
Between 2 KB and 32 KB
(8 KB is a typical size)
Empty block
Empty block
Empty block
Empty block
Empty block
Empty block
Empty block
Empty block
Empty block
Empty block
Full table scan reads all blocks below the high water mark
Empty block
Empty block
High Water Mark and Full Table Scans
Should I Worry?
• Generally, no
• Natural to have a few empty blocks below the high water mark
UPDATE students
SET last_name = ‘Anderson’
WHERE student_id = 188728;
UPDATE students
SET phone = ‘419-500-5489’
WHERE student_id = 208741;
PCTFREE Introduction
Data block
Block Header
Row data
Row data
Row data
Row data
Row data
Row data
No space is left for row to
New data
expand when the row is
updated
PCTFREE Introduction
Data block
Block header
Row data
Row data
Row data
Row data
Data block
Block header
Row data
Row data
Row data
Row data
Free
RowSpace
data
RowSpace
Free data
Row data
Free Space
PCTUSED Example
Data block
Block header
Row data
Data block
Block header
Row data
Row data
Free Space
New data
Free Space
Free Space
• Logging tables
Examples
• Some data warehouse applications
Using a High PCTFREE Value
Free Space
Value between 2 – 32 KB
Tablesapce
block size Assume for example 4 KB
Estimate row sizes for each table from logical data model
400001 …. ….
Foreign key
600483 …. ….
between tables
7839390 …. ….
8920201 …. ….
Data storage using data blocks
Tablespaces
Row Migration
Freelists
Row Chaining
Oracle Database Concepts Guide
http://bit.ly/Ora12cDatabaseConcepts