indexes and indexing in oracle 12c
TRANSCRIPT
INDEXES AND INDEXING IN ORACLE 12C
© Oren Nakdimon
Oren Nakdimon
www.db-oriented.com
+972-54-4393763
@DBoriented
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
WHO AM I? A CHRONOLOGY BY “ORACLE YEARS”
When What Where
Oracle 6/7 1991-1997 Developer IAF
Oracle 8 1997-1998 Server Group Manager Golden Screens
Oracle 8i/9i 1998-2003 DBA Group Manager TELEknowledge
Oracle 10g/11g 2004-2011 VP R&D and Israel Site Manager
Olista
Oracle 11g/12c 2011-2015 Freelance Consultant
2015- Database Expert
http://www.db-oriented.com/blog [English]
http://www.db-oriented.com/blog-2 [Hebrew]
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
AGENDA
Multiple indexes on the same column list
Indexes and extended strings
Online operations
Asynchronous global index maintenance
Partial indexes
Advanced index compression
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
THE USUAL WARNING
Before you decide to apply any of the presented features in production, make sure:
to thoroughly test them for your applications and environments
that you have the required license to use them
Multiple Indexes on the Same Column List
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
INVISIBLE INDEXES (11G)
An invisible index is:
Maintained by DML
Invisible to the optimizer Unless optimizer_use_invisible_indexes is true
@iind
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
MULTIPLE INDEXES ON THE SAME COLUMN LIST
Before 12c
Impossible to define several indexes on the same column list
In 12c
It is possible, as long as Only one of the indexes is visible
The indexes are different somehow; for example:
Unique vs. non-unique
B*tree vs. bitmap
Partitioned vs. non-partitioned
@mind
Extended Strings
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
EXTENDED STRINGS
By default, maximum length of:
VARCHAR2 and NVARCHAR2 columns is 4KB
RAW columns is 2KB
If MAX_STRING_SIZE = EXTENDED, it is 32KB
Implemented like LOBs
SQL string functions can return 32KB
@32k
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
EXTENDED STRINGS – ENABLING
MAX_STRING_SIZE can be changed from STANDARD to EXTENDED, but not from EXTENDED to STANDARD
COMPATIBLE must be set to 12.0.0.0 or higher
Can be done only in UPGRADE mode
The script utl32k.sql must be executed
Objects may be invalidated
Instructions: http://docs.oracle.com/cloud/latest/db121/REFRN/refrn10321.htm
Online DDL Operations
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
ONLINE DDL OPERATIONS
In 12c more operations can be executed online:
ALTER INDEX VISIBLE
ALTER INDEX INVISIBLE
DROP INDEX ONLINE
ALTER INDEX UNUSABLE ONLINE
ALTER TABLE MOVE SUB/PARTITION ONLINE
@online1|2|3|4
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
ONLINE DDL OPERATIONS
Offline Operations Online Operations
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
ONLINE DDL OPERATIONS
Offline Operations Online Operations
Get ORA-54 due to active transactions
Wait for active transactions to end
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
ONLINE DDL OPERATIONS
Offline Operations Online Operations
Get ORA-54 due to active transactions
Wait for active transactions to end
Block new DML statements Do not block new DML statements
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
ONLINE DDL OPERATIONS
Offline Operations Online Operations
Get ORA-54 due to active transactions
Wait for active transactions to end
Block new DML statements Do not block new DML statements
ALTER INDEX UNUSABLE drops the index segment
ALTER INDEX UNUSABLE keeps the index segment
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
ONLINE DDL OPERATIONS
Offline Operations Online Operations
Get ORA-54 due to active transactions
Wait for active transactions to end
Block new DML statements Do not block new DML statements
ALTER INDEX UNUSABLE drops the index segment
ALTER INDEX UNUSABLE keeps the index segment
MOVE PARTITION may lead to unusable indexes
MOVE PARTITION keeps the indexes usable
Asynchronous Global Index Maintenance
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
ASYNC GLOBAL INDEX MAINTENANCE
DROP/TRUNCATE PARTITION
Before 12c: either fast operation or keeping global indexes usable
In 12c: both fast operation and keeping global indexes usable
New data dictionary column ORPHANED_ENTRIES
Orphaned index entries are:
Not deleted as part of the operation
Not reused (usually)
@async1
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
ASYNC GLOBAL INDEX MAINTENANCE
Cleaning out the orphaned entries:
Alter index rebuild
Alter index coalesce cleanup
DBMS_PART.CLEANUP_GIDX
PMO_DEFERRED_GIDX_MAINT_JOB
@async2
Partial Indexes
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
PARTIAL INDEXES
In 12c it is possible to create an index on a subset of partitions
Supported for both local and global indexes
The optimizer is aware of it
INDEXING ON | INDEXING OFF
At table/partition level
INDEXING PARTIAL
At index level
New data dictionary columns: INDEXING
@pind
Advanced Index Compression
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
INDEX COMPRESSION CONCEPT CREATE INDEX PEOPLE_IDX ON PEOPLE
(LAST_NAME,FIRST_NAME)
Allen,Alex,rowid
Allen,Barbara,rowid
Allen,David,rowid
Allen,James,rowid
Allen,John,rowid
Allen,Linda,rowid
Allen,Mary,rowid
Allen,Michael,rowid
Allen,Patricia,rowid
Allen,Robert,rowid
Blake,David,rowid
Blake,James,rowid
Blake,Lisa,rowid
Blake,Maria,rowid
Blake,William,rowid
#1=Allen
#2=Blake
#1,Alex,rowid
#1,Barbara,rowid
#1,David,rowid
#1,James,rowid
#1,John,rowid
#1,Linda,rowid
#1,Mary,rowid
#1,Michael,rowid
#1,Patricia,rowid
#1,Robert,rowid
#2,David,rowid
#2,James,rowid
#2,Lisa,rowid
#2,Maria,rowid
#2,William,rowid
COMPRESS 1
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
INDEX COMPRESSION CONCEPT – CONT.
Smith,Alex,rowid
Smith,Alex,rowid
Smith,Alex,rowid
Smith,Alex,rowid
Smith,Barbara,rowid
Smith,Barbara,rowid
Smith,Barbara,rowid
Smith,Barbara,rowid
Smith,Barbara,rowid
Smith,David,rowid
Smith,David,rowid
Smith,David,rowid
Smith,David,rowid
Smith,David,rowid
Smith,David,rowid
#1=Smith
#1,Alex,rowid
#1,Alex,rowid
#1,Alex,rowid
#1,Alex,rowid
#1,Barbara,rowid
#1,Barbara,rowid
#1,Barbara,rowid
#1,Barbara,rowid
#1,Barbara,rowid
#1,David,rowid
#1,David,rowid
#1,David,rowid
#1,David,rowid
#1,David,rowid
#1,David,rowid
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
INDEX COMPRESSION CONCEPT – CONT.
Xa,Alex,rowid
Xander,Barbara,rowid
Xanders,David,rowid
Xanthopoulos,Kevin,rowid
Xanthos,Sandra,rowid
Xavier,Sarah,rowid
Xayachack,Scott,rowid
Xayarath,Martin,rowid
Xayasane,Donna,rowid
Xayavong,Edward,rowid
#1=Xa #2=Xander
#3=Xanders #4=Xanthopoulos
#5=Xanthos #6=Xavier
#7=Xayachack #8=Xayarath
#9=Xayasane #a=Xayavong
#1,Alex,rowid
#2,Barbara,rowid
#3,David,rowid
#4,Kevin,rowid
#5,Sandra,rowid
#6,Sarah,rowid
#7,Scott,rowid
#8,Martin,rowid
#9,Donna,rowid
#a,Edward,rowid
@acmp
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
PREFIX INDEX COMPRESSION (SINCE ORACLE8I)
Implemented in the leaf block level
May reduce the size of the index
Today’s optimal prefix length may be suboptimal tomorrow
All the index blocks are compressed the same way
This presentation is available in http://db-oriented.com/presentations © O
ren N
akdim
on
ADVANCED INDEX COMPRESSION
Same mechanism, but:
Each block may be compressed or not
Each block may have different number of columns in the prefix table
And it’s automatic
THANK YOU
Oren Nakdimon
www.db-oriented.com
+972-54-4393763
@DBoriented
© Oren Nakdimon