Oracle Indexes: From the Concept to Internals
Prepared by:
Deiby Gómez
Oracle ACE & OCM 11g
Pythian Oracle Consultant
Session ID#: 292
© 2014 Pythian Confidential2
- Oracle ACE (23 years old)
- Oracle Certified Master 11g (24 years old)
- OCP 11g & 12c, RAC 11g, SOA, Exadata X3
- President of Guatemala Oracle User Group
- Pythian Oracle Database Consultant
Twitter: @hdeiby
Facebook: /HDeiby
Email: gomez@pythian.com
Blog: www.oraclefromguatemala.com.gt
© 2014 Pythian Confidential3
WHAT IS AN “INDEX”?
© 2014 Pythian Confidential4
B-TREE INDEXES
© 2014 Pythian Confidential5
Root (Branch)
Branch
Leaf
B-TREE INDEX: CONCEPTS
© 2014 Pythian Confidential6
WHAT IS AN “INDEX”?
© 2014 Pythian Confidential7
B-TREE INDEX: INTERNALS
Header
Free Space
Data
© 2014 Pythian Confidential8
B-TREE INDEX: INTERNALS
Leaf node Branch node
Branch block dump
=================
header address 139950945835596=0x7f48de699a4c
kdxcolev 2
KDXCOLEV Flags = - - -
kdxcolok 0
kdxcoopc 0x80: opcode=0: iot flags=--- is
converted=Y
kdxconco 1
kdxcosdc 0
kdxconro 1
kdxcofbo 30=0x1e
kdxcofeo 8048=0x1f70
kdxcoavs 8018
kdxbrlmc 16779590=0x1000946
kdxbrsno 0
kdxbrbksz 8056
kdxbr2urrc 0
Leaf block dump
===============
header address 139950941831268=0x7f48de2c8064
kdxcolev 0
KDXCOLEV Flags = - - -
kdxcolok 0
kdxcoopc 0x80: opcode=0: iot flags=--- is
converted=Y
kdxconco 1
kdxcosdc 0
kdxconro 1
kdxcofbo 38=0x26
kdxcofeo 8021=0x1f55
kdxcoavs 7983
kdxlespl 0
kdxlende 0
kdxlenxt 0=0x0
kdxleprv 0=0x0
kdxledsz 6
kdxlebksz 8032
row#0[8021] flag: ------, lock: 0, len=11, data:(6):
01 00 00 85 00 00
col 0; len 2; (2): c1 02
----- end of leaf block dump -----
row#0[8048] dba: 16779592=0x1000948
col 0; len 3; (3): c2 09 10
----- end of branch block dump -----
© 2014 Pythian Confidential9
B-TREE INDEX: INTERNALS
Leaf node Branch node
Branch block dump
=================
header address 139950945835596=0x7f48de699a4c
kdxcolev 2
KDXCOLEV Flags = - - -
kdxcolok 0
kdxcoopc 0x80: opcode=0: iot flags=--- is
converted=Y
kdxconco 1
kdxcosdc 0
kdxconro 1
kdxcofbo 30=0x1e
kdxcofeo 8048=0x1f70
kdxcoavs 8018
kdxbrlmc 16779590=0x1000946<--Address to Prev
Node
kdxbrsno 0<--Last index entry modified
kdxbrbksz 8056<--usable space in the block.
kdxbr2urrc 0
row#0[8048] dba: 16779592=0x1000948 <--Pointer
to the 2nd intermediate branch block
col 0; len 3; (3): c2 09 10 <--first column
value used to navigate
----- end of branch block dump -----
Leaf block dump
===============
header address 139950941831268=0x7f48de2c8064
kdxcolev 0 <--block level
KDXCOLEV Flags = - - -
kdxcolok 0 <--itl of service tx holding block lock
kdxcoopc 0x80: opcode=0: iot flags=--- is converted=Y
<--block lock op code
kdxconco 1<--number of columns
kdxcosdc 0<--Split or Deleted count
kdxconro 1<--Number of entries
kdxcofbo 38=0x26 <--offset where the free space in
this block starts
kdxcofeo 8021=0x1f55 <--offset where the free space
in this block finishes
kdxcoavs 7983 <--(kdxcofeo-kdxcofbo) The free space!
kdxlespl 0<--space held by unlocked split entries
kdxlende 0 <--entries deleted
kdxlenxt 0=0x0 <--there is not pointer to Next Leaf
Node
kdxleprv 0=0x0 <--there is not pointer to Previous
Leaf Node
kdxledsz 6<--bytes used by rowed data (KEYDATA)
kdxlebksz 8032<--usable space in the block.
row#0[8021] flag: ------, lock: 0, len=11, data:(6):
01 00 00 85 00 00
col 0; len 2; (2): c1 02
----- end of leaf block dump -----
© 2014 Pythian Confidential10
B-TREE INDEX SELECT OPERATION: CONCEPTS
1,rowid
1,rowid 2,rowid
1,rowid 2,rowid …. 814,rowid 815,rowid
create table dgomez.t1(id number,value varchar2(20));
Select id,value from dgomez.t1 where id=2;
1,rowid 2,rowid …… 814,rowid 815,rowid
ID Value
2 Deiby
Note: 1 entry per Leaf Node
© 2014 Pythian Confidential11
B-TREE INDEX SELECT OPERATION: INTERNALS
SQL> select id, value from dgomez.t1 where id=2;
ID V
---------- -
2 Deiby
Execution Plan
----------------------------------------------------------
Plan hash value: 408250987
-----------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 15 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T1 | 1 | 15 | 2 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | BTREE | 1 | | 2 (0)| 00:00:01 |
-----------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ID"=2)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
4 consistent gets
0 physical reads
0 redo size
457 bytes sent via SQL*Net to client
508 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
© 2014 Pythian Confidential12
B-TREE INDEX DELETE OPERATION: INTERNALS
Delete from ioug.t1 where vkey='D';
row#0[8021] flag: ------, lock: 0, len=11
col 0; len 1; (1): 41
col 1; len 6; (6): 01 80 00 87 00 00
row#1[8010] flag: ------, lock: 0, len=11
col 0; len 1; (1): 42
col 1; len 6; (6): 01 80 00 87 00 01
row#2[7977] flag: ------, lock: 0, len=11
col 0; len 1; (1): 43
col 1; len 6; (6): 01 80 00 87 00 03
row#3[7988] flag: ---D--, lock: 2, len=11
col 0; len 1; (1): 44 <---vkey=’D’
col 1; len 6; (6): 01 80 00 87 00 02
----- end of leaf block dump -----v
• The entry is just marked as “deleted” but it is not
deleted really.
• The deleted Index entry can be reused.
© 2014 Pythian Confidential13
B-TREE INDEX UPDATE OPERATION: INTERNALS
row#0[8021] flag: ------, lock: 0, len=11
col 0; len 1; (1): 41
col 1; len 6; (6): 01 80 00 87 00 00
row#1[8010] flag: ------, lock: 0, len=11
col 0; len 1; (1): 42
col 1; len 6; (6): 01 80 00 87 00 01
row#2[7999] flag: ---D--, lock: 2, len=11
col 0; len 1; (1): 43 <---vkey=’C’
col 1; len 6; (6): 01 80 00 87 00 02
row#3[7988] flag: ------, lock: 2, len=11
col 0; len 1; (1): 44 <---vkey=’D’
col 1; len 6; (6): 01 80 00 87 00 02
----- end of leaf block dump -----
update ioug.t1 set vvalue=‘D' where vkey='C';
© 2014 Pythian Confidential14 14
BITMAP INDEXES
© 2014 Pythian Confidential15
BITMAP INDEX: CONCEPTS
15
© 2014 Pythian Confidential16
BITMAP INDEX: CONCEPTS
© 2014 Pythian Confidential17
BITMAP INDEX SELECT OPERATION
17
© 2014 Pythian Confidential18
BITMAP INDEX UPDATE OPERATION
18
row#0[8005] flag: ------, lock: 0, len=27
col 0; len 6; (6): 43 61 6e 61 64 61
col 1; len 6; (6): 01 80 00 83 00 00
col 2; len 6; (6): 01 80 00 83 00 0f
col 3; len 3; (3): c9 0c 03
row#1[7886] flag: ------, lock: 2, len=35
col 0; len 9; (9): 47 55 41 54 45 4d 41 4c 41vkey=GUATEMALA
col 1; len 6; (6): 00 00 00 00 00 00 Beginning of ROWIDs
col 2; len 6; (6): 01 80 00 83 00 0f Ending of ROWIDs
col 3; len 8; (8): f9 91 df 80 dc 08 61 08 Bitmap String
row#2[7975] flag: ---D--, lock: 2, len=30
col 0; len 9; (9): 47 75 61 74 65 6d 61 6c 61vkey=Guatemala
col 1; len 6; (6): 01 80 00 83 00 00 Beginning of ROWIDs
col 2; len 6; (6): 01 80 00 83 00 0f Ending of ROWIDs
col 3; len 3; (3): c9 61 08 Bitmap String
row#3[7948] flag: ------, lock: 0, len=27
col 0; len 6; (6): 4d 65 78 69 63 6f
col 1; len 6; (6): 01 80 00 83 00 00
col 2; len 6; (6): 01 80 00 83 00 0f
col 3; len 3; (3): c9 92 04
----- end of leaf block dump -----
update ioug.t1 set vkey='GUATEMALA' where vkey='Guatemala';
© 2014 Pythian Confidential19
BITMAP INDEX INSERT OPERATION
• If the KEY exists:
– The Bitmap String is updated
• If the KEY doesn’t exist
– A new Bitmap Entry is created with its
own Bitmap String
19
© 2014 Pythian Confidential20
BITMAP INDEX DELETE OPERATION
• If after the deletion there are some rows with the KEY afer
the DELETE operation, then the Index is not marked as
deleted and only the Bitmap String is updated with “0” in
the positions where our deleted rows were stored.
• If after delete there is no any row with the KEY after the
DELETE operatioN, then the Index Entry is marked as
deleted with “--D--”
20
row#2[7975] flag: ---D--, lock: 2, len=30
Before-->
Delete Op-->
After-->
Before-->
After-->
© 2014 Pythian Confidential21 21
FUNCTION-BASED INDEXES
© 2014 Pythian Confidential22
FUNCTION-BASED INDEX
22
create index functionbasedIDX on dgomez(upper(value));
insert into dgomez values (1,'deiby');
Leaf block dump
===============
…..
…..
row#0[8017] flag: ------, lock: 0, len=15
col 0; len 5; (5): 44 45 49 42 59 ’DEIBY’(not ‘deiby’)
col 1; len 6; (6): 01 40 00 83 00 00
----- end of leaf block dump -----
• The same B-Tree structure and
• The same behavior than B-Tree Indexes but
with the values stored with the function applied.
© 2014 Pythian Confidential23 23
REVERSED-KEY INDEXES
© 2014 Pythian Confidential24
REVERSED-KEY INDEX
24
• The same B-Tree structure and
• Every byte of the KEY is reversed .
create index reversekeyIDX on dgomez(value) reverse;
• 204
• 205
• 206
• 207
• 402
• 502
• 602
• 702
© 2014 Pythian Confidential25
REVERSED-KEY INDEX
25
• The same B-Tree structure and
• Every byte of the KEY is reversed .
create index reversekeyIDX on dgomez(value) reverse;
row#0[8019] flag: ------, lock: 0, len=13
col 0; len 3; (3): 34 30 32<-The value
col 1; len 6; (6): 02 40 00 87 00 04<-RowID
row#1[8006] flag: ------, lock: 0, len=13
col 0; len 3; (3): 35 30 32
col 1; len 6; (6): 02 40 00 87 00 05
row#2[7993] flag: ------, lock: 0, len=13
col 0; len 3; (3): 36 30 32
col 1; len 6; (6): 02 40 00 87 00 06
row#3[7980] flag: ------, lock: 0, len=13
col 0; len 3; (3): 37 30 32
col 1; len 6; (6): 02 40 00 87 00 07
----- end of leaf block dump -----
34 30 32 => 4 0 2
35 30 32 => 5 0 2
36 30 32 => 6 0 2
37 30 32 => 7 0 2
But not…
204
205
206
207
© 2014 Pythian Confidential26 26
INDEXES ON VIRTUAL COLUMNS
© 2014 Pythian Confidential27
INDEXES ON VIRTUAL COLUMNS
27
create table dgomez(
value1 varchar(10),
value2 varchar2(10),
result as (value1||value2));
row#0[8017] flag: ------, lock: 0, len=15
col 0; len 5; (5): 64 65 69 62 79 <--deiby
col 1; len 6; (6): 01 40 00 87 00 00 <---ROWID
----- end of leaf block dump -----
create index vcolumn on dgomez(result);
insert into dgomez (value1,value2) values ('dei','by');
• The same B-Tree structure
• The dynamic value of KEY is stored physically.
• A change on dependent column will update the Index
© 2014 Pythian Confidential28

Indexes From the Concept to Internals

  • 1.
    Oracle Indexes: Fromthe Concept to Internals Prepared by: Deiby Gómez Oracle ACE & OCM 11g Pythian Oracle Consultant Session ID#: 292
  • 2.
    © 2014 PythianConfidential2 - Oracle ACE (23 years old) - Oracle Certified Master 11g (24 years old) - OCP 11g & 12c, RAC 11g, SOA, Exadata X3 - President of Guatemala Oracle User Group - Pythian Oracle Database Consultant Twitter: @hdeiby Facebook: /HDeiby Email: gomez@pythian.com Blog: www.oraclefromguatemala.com.gt
  • 3.
    © 2014 PythianConfidential3 WHAT IS AN “INDEX”?
  • 4.
    © 2014 PythianConfidential4 B-TREE INDEXES
  • 5.
    © 2014 PythianConfidential5 Root (Branch) Branch Leaf B-TREE INDEX: CONCEPTS
  • 6.
    © 2014 PythianConfidential6 WHAT IS AN “INDEX”?
  • 7.
    © 2014 PythianConfidential7 B-TREE INDEX: INTERNALS Header Free Space Data
  • 8.
    © 2014 PythianConfidential8 B-TREE INDEX: INTERNALS Leaf node Branch node Branch block dump ================= header address 139950945835596=0x7f48de699a4c kdxcolev 2 KDXCOLEV Flags = - - - kdxcolok 0 kdxcoopc 0x80: opcode=0: iot flags=--- is converted=Y kdxconco 1 kdxcosdc 0 kdxconro 1 kdxcofbo 30=0x1e kdxcofeo 8048=0x1f70 kdxcoavs 8018 kdxbrlmc 16779590=0x1000946 kdxbrsno 0 kdxbrbksz 8056 kdxbr2urrc 0 Leaf block dump =============== header address 139950941831268=0x7f48de2c8064 kdxcolev 0 KDXCOLEV Flags = - - - kdxcolok 0 kdxcoopc 0x80: opcode=0: iot flags=--- is converted=Y kdxconco 1 kdxcosdc 0 kdxconro 1 kdxcofbo 38=0x26 kdxcofeo 8021=0x1f55 kdxcoavs 7983 kdxlespl 0 kdxlende 0 kdxlenxt 0=0x0 kdxleprv 0=0x0 kdxledsz 6 kdxlebksz 8032 row#0[8021] flag: ------, lock: 0, len=11, data:(6): 01 00 00 85 00 00 col 0; len 2; (2): c1 02 ----- end of leaf block dump ----- row#0[8048] dba: 16779592=0x1000948 col 0; len 3; (3): c2 09 10 ----- end of branch block dump -----
  • 9.
    © 2014 PythianConfidential9 B-TREE INDEX: INTERNALS Leaf node Branch node Branch block dump ================= header address 139950945835596=0x7f48de699a4c kdxcolev 2 KDXCOLEV Flags = - - - kdxcolok 0 kdxcoopc 0x80: opcode=0: iot flags=--- is converted=Y kdxconco 1 kdxcosdc 0 kdxconro 1 kdxcofbo 30=0x1e kdxcofeo 8048=0x1f70 kdxcoavs 8018 kdxbrlmc 16779590=0x1000946<--Address to Prev Node kdxbrsno 0<--Last index entry modified kdxbrbksz 8056<--usable space in the block. kdxbr2urrc 0 row#0[8048] dba: 16779592=0x1000948 <--Pointer to the 2nd intermediate branch block col 0; len 3; (3): c2 09 10 <--first column value used to navigate ----- end of branch block dump ----- Leaf block dump =============== header address 139950941831268=0x7f48de2c8064 kdxcolev 0 <--block level KDXCOLEV Flags = - - - kdxcolok 0 <--itl of service tx holding block lock kdxcoopc 0x80: opcode=0: iot flags=--- is converted=Y <--block lock op code kdxconco 1<--number of columns kdxcosdc 0<--Split or Deleted count kdxconro 1<--Number of entries kdxcofbo 38=0x26 <--offset where the free space in this block starts kdxcofeo 8021=0x1f55 <--offset where the free space in this block finishes kdxcoavs 7983 <--(kdxcofeo-kdxcofbo) The free space! kdxlespl 0<--space held by unlocked split entries kdxlende 0 <--entries deleted kdxlenxt 0=0x0 <--there is not pointer to Next Leaf Node kdxleprv 0=0x0 <--there is not pointer to Previous Leaf Node kdxledsz 6<--bytes used by rowed data (KEYDATA) kdxlebksz 8032<--usable space in the block. row#0[8021] flag: ------, lock: 0, len=11, data:(6): 01 00 00 85 00 00 col 0; len 2; (2): c1 02 ----- end of leaf block dump -----
  • 10.
    © 2014 PythianConfidential10 B-TREE INDEX SELECT OPERATION: CONCEPTS 1,rowid 1,rowid 2,rowid 1,rowid 2,rowid …. 814,rowid 815,rowid create table dgomez.t1(id number,value varchar2(20)); Select id,value from dgomez.t1 where id=2; 1,rowid 2,rowid …… 814,rowid 815,rowid ID Value 2 Deiby Note: 1 entry per Leaf Node
  • 11.
    © 2014 PythianConfidential11 B-TREE INDEX SELECT OPERATION: INTERNALS SQL> select id, value from dgomez.t1 where id=2; ID V ---------- - 2 Deiby Execution Plan ---------------------------------------------------------- Plan hash value: 408250987 ----------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 15 | 2 (0)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID| T1 | 1 | 15 | 2 (0)| 00:00:01 | |* 2 | INDEX UNIQUE SCAN | BTREE | 1 | | 2 (0)| 00:00:01 | ----------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("ID"=2) Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 4 consistent gets 0 physical reads 0 redo size 457 bytes sent via SQL*Net to client 508 bytes received via SQL*Net from client 1 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed SQL>
  • 12.
    © 2014 PythianConfidential12 B-TREE INDEX DELETE OPERATION: INTERNALS Delete from ioug.t1 where vkey='D'; row#0[8021] flag: ------, lock: 0, len=11 col 0; len 1; (1): 41 col 1; len 6; (6): 01 80 00 87 00 00 row#1[8010] flag: ------, lock: 0, len=11 col 0; len 1; (1): 42 col 1; len 6; (6): 01 80 00 87 00 01 row#2[7977] flag: ------, lock: 0, len=11 col 0; len 1; (1): 43 col 1; len 6; (6): 01 80 00 87 00 03 row#3[7988] flag: ---D--, lock: 2, len=11 col 0; len 1; (1): 44 <---vkey=’D’ col 1; len 6; (6): 01 80 00 87 00 02 ----- end of leaf block dump -----v • The entry is just marked as “deleted” but it is not deleted really. • The deleted Index entry can be reused.
  • 13.
    © 2014 PythianConfidential13 B-TREE INDEX UPDATE OPERATION: INTERNALS row#0[8021] flag: ------, lock: 0, len=11 col 0; len 1; (1): 41 col 1; len 6; (6): 01 80 00 87 00 00 row#1[8010] flag: ------, lock: 0, len=11 col 0; len 1; (1): 42 col 1; len 6; (6): 01 80 00 87 00 01 row#2[7999] flag: ---D--, lock: 2, len=11 col 0; len 1; (1): 43 <---vkey=’C’ col 1; len 6; (6): 01 80 00 87 00 02 row#3[7988] flag: ------, lock: 2, len=11 col 0; len 1; (1): 44 <---vkey=’D’ col 1; len 6; (6): 01 80 00 87 00 02 ----- end of leaf block dump ----- update ioug.t1 set vvalue=‘D' where vkey='C';
  • 14.
    © 2014 PythianConfidential14 14 BITMAP INDEXES
  • 15.
    © 2014 PythianConfidential15 BITMAP INDEX: CONCEPTS 15
  • 16.
    © 2014 PythianConfidential16 BITMAP INDEX: CONCEPTS
  • 17.
    © 2014 PythianConfidential17 BITMAP INDEX SELECT OPERATION 17
  • 18.
    © 2014 PythianConfidential18 BITMAP INDEX UPDATE OPERATION 18 row#0[8005] flag: ------, lock: 0, len=27 col 0; len 6; (6): 43 61 6e 61 64 61 col 1; len 6; (6): 01 80 00 83 00 00 col 2; len 6; (6): 01 80 00 83 00 0f col 3; len 3; (3): c9 0c 03 row#1[7886] flag: ------, lock: 2, len=35 col 0; len 9; (9): 47 55 41 54 45 4d 41 4c 41vkey=GUATEMALA col 1; len 6; (6): 00 00 00 00 00 00 Beginning of ROWIDs col 2; len 6; (6): 01 80 00 83 00 0f Ending of ROWIDs col 3; len 8; (8): f9 91 df 80 dc 08 61 08 Bitmap String row#2[7975] flag: ---D--, lock: 2, len=30 col 0; len 9; (9): 47 75 61 74 65 6d 61 6c 61vkey=Guatemala col 1; len 6; (6): 01 80 00 83 00 00 Beginning of ROWIDs col 2; len 6; (6): 01 80 00 83 00 0f Ending of ROWIDs col 3; len 3; (3): c9 61 08 Bitmap String row#3[7948] flag: ------, lock: 0, len=27 col 0; len 6; (6): 4d 65 78 69 63 6f col 1; len 6; (6): 01 80 00 83 00 00 col 2; len 6; (6): 01 80 00 83 00 0f col 3; len 3; (3): c9 92 04 ----- end of leaf block dump ----- update ioug.t1 set vkey='GUATEMALA' where vkey='Guatemala';
  • 19.
    © 2014 PythianConfidential19 BITMAP INDEX INSERT OPERATION • If the KEY exists: – The Bitmap String is updated • If the KEY doesn’t exist – A new Bitmap Entry is created with its own Bitmap String 19
  • 20.
    © 2014 PythianConfidential20 BITMAP INDEX DELETE OPERATION • If after the deletion there are some rows with the KEY afer the DELETE operation, then the Index is not marked as deleted and only the Bitmap String is updated with “0” in the positions where our deleted rows were stored. • If after delete there is no any row with the KEY after the DELETE operatioN, then the Index Entry is marked as deleted with “--D--” 20 row#2[7975] flag: ---D--, lock: 2, len=30 Before--> Delete Op--> After--> Before--> After-->
  • 21.
    © 2014 PythianConfidential21 21 FUNCTION-BASED INDEXES
  • 22.
    © 2014 PythianConfidential22 FUNCTION-BASED INDEX 22 create index functionbasedIDX on dgomez(upper(value)); insert into dgomez values (1,'deiby'); Leaf block dump =============== ….. ….. row#0[8017] flag: ------, lock: 0, len=15 col 0; len 5; (5): 44 45 49 42 59 ’DEIBY’(not ‘deiby’) col 1; len 6; (6): 01 40 00 83 00 00 ----- end of leaf block dump ----- • The same B-Tree structure and • The same behavior than B-Tree Indexes but with the values stored with the function applied.
  • 23.
    © 2014 PythianConfidential23 23 REVERSED-KEY INDEXES
  • 24.
    © 2014 PythianConfidential24 REVERSED-KEY INDEX 24 • The same B-Tree structure and • Every byte of the KEY is reversed . create index reversekeyIDX on dgomez(value) reverse; • 204 • 205 • 206 • 207 • 402 • 502 • 602 • 702
  • 25.
    © 2014 PythianConfidential25 REVERSED-KEY INDEX 25 • The same B-Tree structure and • Every byte of the KEY is reversed . create index reversekeyIDX on dgomez(value) reverse; row#0[8019] flag: ------, lock: 0, len=13 col 0; len 3; (3): 34 30 32<-The value col 1; len 6; (6): 02 40 00 87 00 04<-RowID row#1[8006] flag: ------, lock: 0, len=13 col 0; len 3; (3): 35 30 32 col 1; len 6; (6): 02 40 00 87 00 05 row#2[7993] flag: ------, lock: 0, len=13 col 0; len 3; (3): 36 30 32 col 1; len 6; (6): 02 40 00 87 00 06 row#3[7980] flag: ------, lock: 0, len=13 col 0; len 3; (3): 37 30 32 col 1; len 6; (6): 02 40 00 87 00 07 ----- end of leaf block dump ----- 34 30 32 => 4 0 2 35 30 32 => 5 0 2 36 30 32 => 6 0 2 37 30 32 => 7 0 2 But not… 204 205 206 207
  • 26.
    © 2014 PythianConfidential26 26 INDEXES ON VIRTUAL COLUMNS
  • 27.
    © 2014 PythianConfidential27 INDEXES ON VIRTUAL COLUMNS 27 create table dgomez( value1 varchar(10), value2 varchar2(10), result as (value1||value2)); row#0[8017] flag: ------, lock: 0, len=15 col 0; len 5; (5): 64 65 69 62 79 <--deiby col 1; len 6; (6): 01 40 00 87 00 00 <---ROWID ----- end of leaf block dump ----- create index vcolumn on dgomez(result); insert into dgomez (value1,value2) values ('dei','by'); • The same B-Tree structure • The dynamic value of KEY is stored physically. • A change on dependent column will update the Index
  • 28.
    © 2014 PythianConfidential28