DOAG 2008 LOB versus SecureFiles
Dr. Günter Unbescheid Database Consult GmbH
Jachenau
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 2 von 61
Database Consult GmbH
• Gegründet 1996• Kompetenzen im Umfeld von ORACLE-basierten Systemen• Tätigkeitsbereiche
– Tuning, Installation, Konfiguration– Expertisen/Gutachten– Support, Troubleshooting, DBA-Aufgaben – Datenmodellierung und –design– Datenbankdesign, Systemanalysen– Programmierung: SQL,PL/SQL,Java, JSP, ADF UIX, BC4J– Workshops– www.database-consult.de
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 3 von 61
LOB-Erfahrungen
• Dokumenten-Speicherungssystem– Strukturierte Ablage: Projekte – Objekttypen – Keys– Row Level Security (VPD)– derzeit ca. 1 Million Dokumente
• South Asian Languages– Linguistische Datenbank – noch in Entwicklung– Texte – Bibiographien – Konkordanz – linguistisches Tagging– derzeit ca. 20.000 Dateien
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 4 von 61
Agenda
• Einführung: SecureFiles im Überblick• Rückblick LOBs
– Features, Parameter, Internals
• Einblick SecureFiles– Features, Parameter, Internals
• Kennzahlen LOB versus SecureFiles
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 5 von 61
Einführung: SecureFiles
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 6 von 61
Originalton Oracle ...
SecureFiles is a major paradigm shift with the choice of files storage.
SecureFiles offers the best-of-both-worlds architecture from both the database and filesystem worlds for storing unstructured data.
SecureFiles is a completely new architecture inside the Oracle Database 11g for handling file or unstructured data. It features entirely new disk formats, network protocol, space management, redo and undo formats, buffer caching, and intelligent I/O subsystem.
With SecureFiles, Oracle has perfected the use of the database for storage of all enterprise data.
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 7 von 61
Überblick SecureFiles• Neues Feature in 11g zur Speicherung/Handhabung
unstrukturierter Daten – keine neuer Datentyp– Superset der LOB-Schnittstellen– Tablespace mit Automatic Segment Space Management ASSM
• Design-Ziele– Performance – dynamisch Speicherallokationen– Speichereffizienz – Compression, Deduplikation– Sicherheit - Encryption
• Lizenz-Verhalten– Basisfunktionalität enthalten in SE1, SE und EE– Compression und Deduplication für EE mit „Advanced
Compression Option“– Encryption für EE mit „Advanced Security Option“
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 8 von 61
Überblick SecureFiles• Komplette Überarbeitung von
– Speicherformat– Space-/Memory-Management– Zugriffsprotokoll (Netz)– Caching und Locking– Redo und Undo Algorithmen– Cluster Verhalten
• Filesystem-Daten integrierbar in die Datenbank– Konsistenz und Transaktionslogik– einheitliche Security-Konfiguration– einheitliche Backup-Verfahren
• Man erinnert sich ...– iFS (2000), Oracle Files (9i) ...
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 9 von 61
Überblick SecureFiles
• Write Gather Cache– puffert bis zu 4MB vor dem Schreiben auf Platte– optimiert Speicherallokation– ermöglicht optimiertes Platten-IO (reduzierte write-latency)– alloziert vom Buffer-Cache auf Transaktionsbasis
• Space Management– dynamische Allokation aufeinanderfolgender Blöcke auf Basis
von in-memory Statisktiken– Präallokation auf Basis vorausgehender Anforderungen– optimierte Freigabe von Speicherplatz (deletes, updates)
• Pre-Fetching – read-ahead• Network Layer – Lesen der bulk-Daten ohne Staging
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 10 von 61
Überblick SecureFiles• LOB-Index
– (10g) Zugriff auf Chunks + Verwaltung von Freiplatz– (11g) Chunk-Verwaltung über eigene Meta-Blöcke (LOB-
Segment)
• Reduzierte Parameter– kein FREEPOOLS, FREELISTS, FREELIST GROUPS und
PCTVERSION
• Speichereffizienz durch Komprimierung– Standard-Algorithmen, Automatisierte Komprimierung
• Verschlüsselung– Standard Algorithmen (3DES168, AES192 (default), AES256)– transparentes Key-Management
• Integriert: XML DB, Multimedia, Spatial, Oracle UCM
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 11 von 61
Intermezzo: Dumps Syntaxüberblick
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 12 von 61
Formatierte Dumps
- Tracefile Identifier alter session set tracefile_identifier = &tid;
-- Segment Header dbms_space_admin.segment_dump
-- Data Blocks alter system dump datafile &Fno block min &BMin block max &BMax;
-- Undo Data alter system dump undo header '&RSN'; alter system dump undo block '&RSN' XID &USN &SLOT &SQN;
-- Redo Data for Block Number alter system dump logfile '&LM' DBA min &Fno &Bno DBA max &Fno &Bno;
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 13 von 61
Rückblick: LOBs Features
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 14 von 61
LOB
• Komplette Überarbeitung des alten LONG-Typs• Large Objects als Datentyp ab der Version 8.0
– CLOB, BLOB, NCLOB und BFILE
• Maximalgrößen 10g/11g– 1000 (LOB-)Spalten pro Tabelle– Maximum size: (4 GB - 1) * DB_BLOCK_SIZE (8 TB to 128 TB)– Maximum BFILE 4 GB
• Datenstrukturen– Lob-Locator + Inode, LOB-Index, LOB-Segment– Storage innerhalb der Row (<=4000 Bytes) oder LOB-Segment– Speichereinheiten CHUNKs (LOB-Segment)
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 15 von 61
LOB-Welt
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 16 von 61
Rückblick: LOBs Internals
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 17 von 61
DDL-Beispiel (11g)-- db_securefile = PERMITTED (LOB per Default) -- db_block_size = 8192 -- LMTS Tablespace (System Managed) mit ASSM
CREATE TABLE LOB.lt1 ( c1 NUMBER , c2 VARCHAR2(20) , c3 CLOB) LOB (c3) STORE AS lob_lt1_c3 -- Variante: STORE AS BASICFILE lob_lt1_c3 ( TABLESPACE userlob STORAGE (INITAL 10M) -- ENABLE STORAGE IN ROW -- CHUNK 8192 INDEX ilob_lt1_c3 (STORAGE (INITIAL 2m))
) TABLESPACE usertab STORAGE (INITIAL 1M);
INSERT INTO lob.lt1 VALUES (1,'Test', null); INSERT INTO lob.lt1 VALUES (1,'Test', empty_clob());
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 18 von 61
DDL Klauseln
• STORE AS <lob_segment_name> INDEX <lob_index_name> – Klauseln erlauben explizite Namensgebung– ansonsten: SYS_LOB<nn>$$ , SYS_IL<nn>$$
• TABLESPACE und STORAGE– getrennt für Tabelle und (LOB-Segment + LOB-Index) möglich– ACHTUNG: LOB-Index Storage wird ignoriert!
• ENABLE | DISABLE STORAGE IN ROW– maximale Speicherlänge in der Row 4000 (mit Overhead)
• CHUNK <chunk_size> – kleinste(!) Speichereinheit für LOB-Segment-Daten (nicht Tabelle)– Minimum Blockgrösse der LOB-Tablespace
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 19 von 61
DDL Klauseln
• CACHE / NOCACHE (LOB-Klausel)– wirksam nur für LOB-Daten– Zugriff per Buffer Cache oder direct read/write
• CACHE READS– Zugriff per Buffer Cache nur für read-Operations
• UNDO und Consistent Reads– kein UNDO für LOB-Data– nur für LOB-Locator und LOB-Index Änderungen– CR per PCTVERSION (Anteil % von UNDO-Daten d. Segm.)
oder RETENTION (= undo_retention init.ora)
• LOGGING– volles REDO für LOB-Pages
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 20 von 61
Dump Legende: Blocktypen LOB
Level 2 Bitmap Block (ASSM)
Pagetable Segment Header
Level 1 Bitmap Block (ASSM)
Segment High Water Mark
Leerer oder unformatierter Block
Extent-Ende
Lob-Locator (20 Bytes)
Lob-Inode (16 Bytes)
Daten Block
Index Block
Index Block (Dummy Row)
PAGETABLE MANAGED LOB BLOCK
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 21 von 61
Internals
create table – enable storage – insert empty_clob()
seg/obj: 0x115a9 csc: 0x00.27d94d itc: 2 flg: E typ: 1 – DATA ntab=1 nrow=1 tl: 50 fb: --H-FL-- lb: 0x1 cc: 3 col 0: [ 2] c1 12 col 1: [ 6] 4b 65 79 20 31 37 col 2: [36] 00 54 00 01 02 0c 00 00 00 01 00 00 00 01 00 00 00 02 60 67 00 10 09 00 00 00 00 00 00 00 00 00 00 00 00 00
Segment Map
Table
LOB Seg
LOB Ind
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 22 von 61
Internals
• LOB-Locator– identifiziert LOB-Instance– Länge maximal/aktuell
• LOB-ID eindeutiger Identifizierer (2 Bytes für Index 8 Bytes OID)
• Inode– Pointer zu Chunks nur bei
enable storage in row– 16 Bytes + maximal 12 DBAs
á 4 Byte (48 Byte)– ansonsten LOB-Index
LOB Locator: Length: 84(36) Version: 1 Byte Length: 1 LobID: 00.00.00.01.00.00.00.02.60.67 Flags[ 0x02 0x0c 0x00 0x00 ]: Type: CLOB Storage: BasicFile Enable Storage in Row Characterset Format: IMPLICIT Partitioned Table: No Options: ReadWrite Inode: Size: 16 Flag: 0x09 [ Valid DataInRow ] Future: 0x00 (should be '0x00') Blocks: 0 Bytes: 0 Version: 00000.0000000000 Inline data[0]
len(2), vsn(2), flg(4), bytl(2), lobid(10), inode(16), data
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 23 von 61
Internals
create table – enable storage – insert clob 2000 rpad mit String bla
seg/obj: 0x115b3 csc: 0x00.27eb5d itc: 2 flg: E typ: 1 – DATA ntab=1 nrow=1 tl: 2052 fb: --H-FL-- lb: 0x1 cc: 3 col 0: [ 2] c1 13 col 1: [ 6] 4b 65 79 20 31 38 col 2: [2036] 00 54 00 01 02 0c 00 00 00 01 00 00 00 01 00 00 00 02 60 cc 07 e0 09 00 00 00 00 00 07 d0 00 00 00 00 00 01 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 ..... 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 24 von 61
Internals
• LOB wird vollständig in variabler Länge mit der restlichen Rows im Datenblock gespeichert
• Byte Length 1 = BLOB/CLOB/BFILE
• LOB-Locator unverändert• Inline data verweisen auf LOB-
Storage
LOB Locator: Length: 84(2036) Version: 1 Byte Length: 1 LobID: 00.00.00.01.00.00.00.02.60.cc Flags[ 0x02 0x0c 0x00 0x00 ]:
Type: CLOB Storage: BasicFile Enable Storage in Row Characterset Format: IMPLICIT Partitioned Table: No Options: ReadWrite
Inode: Size: 2016 Flag: 0x09 [ Valid DataInRow ] Future: 0x00 (should be '0x00') Blocks: 0 Bytes: 2000 Version: 00000.0000000001 Inline data[2000]
len(2), vsn(2), flg(4), bytl(2), lobid(10), inode(16), data
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 25 von 61
Internals
create table – enable storage – insert clob 2000 dann update auf Länge 20000 und ein weiteres Update
tab 0, row 0, @0x1f28 tl: 62 fb: --H-FL-- lb: 0x1 cc: 3 col 0: [ 2] c1 14 col 1: [ 6] 4b 65 79 20 31 39 col 2: [48] 00 54 00 01 02 0c 00 00 00 01 00 00 00 01 00 00 00 02 61 95 00 1c 05 00 00 00 00 02 0e 98 00 00 00 00 00 02 01 00 0b 0d 01 00 0b 0e 01 00 0b 1e
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 26 von 61
Internals
• LOB wird ausgelagert in Chunks, Inode bleibt in Row
• DBAs zeigen auf Chunks des LOB-Segments
• Update erzeugt neue Lob-ID und neue Version des Inode
LOB Locator: Length: 84(48) Version: 1 Byte Length: 1 LobID: 00.00.00.01.00.00.00.02.61.95 Flags[ 0x02 0x0c 0x00 0x00 ]:
Type: CLOB Storage: BasicFile Enable Storage in Row Characterset Format: IMPLICIT Partitioned Table: No Options: ReadWrite
Inode: Size: 28 Flag: 0x05 [ Valid
InodeInRow(ESIR) ] Future: 0x00 (should be '0x00') Blocks: 2 Bytes: 3736 Version: 00000.0000000002 DBA Array[3]: 0x01000b0d 0x01000b0e 0x01000b1e
len(2), vsn(2), flg(4), bytl(2), lobid(10), inode(16), data
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 27 von 61
Internals – LOB Segment
buffer tsn: 4 rdba: 0x01000b0c (4/2828) frmt: 0x02 chkval: 0x01db type: 0x28=PAGETABLE MANAGED LOB BLOCK Object Id 71100 LobId: 000100026194 PageNo 2 Version: 0x0000.00000001 pdba: 16780041 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 ... 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 20 20 20 20 20 20 20 20 ...
buffer tsn: 4 rdba: 0x01000b0d (4/2829) LobId: 000100026195 PageNo 0
buffer tsn: 4 rdba: 0x01000b0e (4/2830) LobId: 000100026195 PageNo 1
buffer tsn: 4 rdba: 0x01000b0f (4/2831) LobId: 000100026194 PageNo 0
buffer tsn: 4 rdba: 0x01000b10 (4/2832) LobId: 000100026194 PageNo 1
buffer tsn: 4 rdba: 0x01000b1e (4/2846) LobId: 000100026195 PageNo 2
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 28 von 61
LOB-IndexBH (0x2abe4a9c) file#: 4 rdba: 0x01000b13 (4/2835) class: 4 ba: 0x2a81a000 frmt: 0x02 chkval: 0x0000 type: 0x23=PAGETABLE SEGMENT HEADER Highwater:: 0x01000b15 ext#: 0 blk#: 4 ext size: 8 Last Level 1 BMB: 0x01000b11 Last Level II BMB: 0x01000b12 --------------------------------- BH (0x2b7ec6ec) file#: 4 rdba: 0x01000b14 (4/2836) class: 1 ba: 0x2b54c000 seg/obj: 0x115bd csc: 0x00.27f606 itc: 2 flg: E typ: 2 - INDEX
Leaf block dump =============== kdxcolev 0 --> Level kdxconco 2 --> number of index Columns kdxconro 1 --> number of index entries kdxledsz 32 --> bytes ROWID data kdxlebksz 8032 --> usable block size
row#0[7982] flag: ------, lock: 2, len=50, data:(32): --> first part 3 RDBAs of "old" chunks 01 00 0b 0c 01 00 0b 0f 01 00 0b 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
col 0; len 10; (10): 00 01 49 24 79 aa 00 00 00 00 col 1; len 4; (4): 01 00 0b 0c --> Page 2 of "old" LOB-Data end of chain ----- end of leaf block dump -----
0x01000b13
0x01000b150x01000b110x01000b12
01 00 0b 0c 01 00 0b 0f 01 00 0b 10
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 29 von 61
LOB-Index – disable storage
row#0[7932] flag: ---D--, lock: 2, len=50, data:(32): 00 20 03 00 00 00 00 02 0e 98 00 00 00 00 00 01 01 00 61 ff 01 00 62 00 01 00 61 fc 00 00 00 00
col 0; len 10; (10): 00 00 00 01 00 00 00 02 76 7a col 1; len 4; (4): 00 00 00 00
row#1[7882] flag: ------, lock: 2, len=50, data:(32): 00 20 03 00 00 00 00 02 0e 9b 00 00 00 00 00 01 01 00 61 fd 01 00 61 fe 01 00 b2 0e 00 00 00 00
col 0; len 10; (10): 00 00 00 01 00 00 00 02 76 7b col 1; len 4; (4): 00 00 00 00
LOB-IDs für alte und neue DatenFixe Länge für
data part: 4 – 8 DBAs
01 00 61 fd
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 30 von 61
Internals – Table-Segment
create table – disable storage – insert clob 50.000
BH (0x2fbf38ac) file#: 4 rdba: 0x01000b30 (4/2864) class: 1 ba: 0x2fa64000 seg/obj: 0x115e8 csc: 0x00.2aba02 itc: 2 flg: E typ: 1 - DATA tl: 34 fb: --H-FL-- lb: 0x1 cc: 3 col 0: [ 2] c1 16 col 1: [ 6] 4b 65 79 20 32 31 col 2: [20] 00 54 00 01 02 08 00 00 00 01 00 00 00 01 00 00 00 02 65 7c LOB Locator:
Length: 84(20) Version: 1 Byte Length: 1
LobID: 00.00.00.01.00.00.00.02.65.7c Flags[ 0x02 0x08 0x00 0x00 ]:
Type: CLOB Storage: BasicFile Disable Storage in Row Characterset Format: IMPLICIT Partitioned Table: No
Options: ReadWrite
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 31 von 61
Internals – LOB IndexBH (0x2c7e4eac) file#: 4 rdba: 0x01000b3b (4/2875) frmt: 0x02 chkval: 0x0000 type: 0x23=PAGETABLE SEGMENT HEADER Highwater:: 0x01000b3d ext#: 0 blk#: 4 ext size: 8
BH (0x2fbece3c) file#: 4 rdba: 0x01000b3c (4/2876) seg/obj: 0x115ea csc: 0x00.2ab8e1 itc: 2 flg: E typ: 2 – INDEX kdxcolev 0 kdxconro 3 row#0[7982] flag: ---D--, lock: 2, len=50, data:(32): 00 20 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
col 0; len 10; (10): 00 00 00 01 00 00 00 02 65 7b col 1; len 4; (4): 00 00 00 00 row#1[7932] flag: ------, lock: 2, len=50, data:(32): 00 20 03 00 00 00 00 06 04 b8 00 00 00 00 00 01 01 00 0b 38 01 00 0b 34 01 00 0b 35 01 00 0b 36
col 0; len 10; (10): 00 00 00 01 00 00 00 02 65 7c col 1; len 4; (4): 00 00 00 00 row#2[7882] flag: ------, lock: 2, len=50, data:(32): 01 00 0b 37 01 00 0b 45 01 00 0b 46 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
col 0; len 10; (10): 00 00 00 01 00 00 00 02 65 7c col 1; len 4; (4): 00 00 00 04
Neue LOB-IDmit den ersten 4 DBAs
1. Inode mit alter LOB-ID
Page Count Offset
01 00 0b 37 01 00 0b 45 01 00 0b 46
01 00 0b 38 01 00 0b 34 0100 0b 35 01 00 0b 36
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 33 von 61
Einblick: SecureFiles Features und Internals
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 34 von 61
Syntax-Strukturen
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 35 von 61
SecureFiles• Voreinstellungen (init.ora) – db_securefile
– ALWAYS – versucht SF– FORCE – erzwingt SF oder scheitert– PERMITTED – SF nur wenn explizit genannt (Default)– NEVER – nicht erlaubt, SF Option erzeugen Fehler– IGNORE – keine SF, Options werden ignoriert
-- Anlegencreate table TEST (cpk number(10) not null, document clob) lob(document) store as SECUREFILE doc_sf(nocache logging retention autoCOMPRESS DEDUPLICATE ENCRYPT)
/
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 36 von 61
DDL-Beispiel (11g)-- db_securefile = PERMITTED (LOB per Default) -- db_block_size = 8192
CREATE TABLE LOB.lt1 ( c1 NUMBER , c2 VARCHAR2(20) , c3 CLOB) LOB (c3) STORE AS SECUREFILE lob_lt1_c3 ( TABLESPACE userlob STORAGE (INITAL 10M) -- ENABLE STORAGE IN ROW -- CHUNK 8192 INDEX ilob_lt1_c3
) TABLESPACE usertab STORAGE (INITIAL 1M) /
INSERT INTO lob.lt1 VALUES (1,'Test', empty_clob()); UPDATE lob.lt1 SET c3 = rpad('bla',20, 'bla');
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 37 von 61
SecureFiles – Storage Klauseln
• RETENSION-Klausel– regelt CR-Verhalten von SF in Abhängigkeit von UNDO-TS– Wert MAX – LOB-Segment wächst bis MAXSIZE bevor Undo-
Platz freigegeben wird.– Wert AUTO – interne Kalkualtion der R-Periode– Wert NONE – keine Retention– Wert MIN <n> - Vorhaltezeit in Sekunden
• FILESYSTEM_LIKE_LOGGING– alternativ zu LOGGING oder NOLOGGING– logging der Metadaten von SF ~ meatadata journaling
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 39 von 61
Internals
Segment Map
Table
LOB Seg
LOB Ind
NGLOB: Lob Extent Header
NGLOB: Hash Bucket
NGLOB: Segment Header
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 40 von 61
Neue Blocktypen
• Lob Extent Header– erster Block in jedem SF-LOB-Extent
• LOB Segment Header– zweiter Block des ersten Extents– Highwater Mark, Extent Map– Übersicht über Hash Bucket Blöcke
• Hash Buckets – variable Chunk-Grössen– 7 Buckets für Chunks unterschiedlicher Größenordnungen– 2k to 32K, 32k to 64k, 64k to 128k, 128k to 256k, 256k to 512k,
512k to 1m, 1m to 64m– Freipaltzverwaltung über Committed Free Space (CFS)
[Retention] und Uncommited Free Space (UFS)
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 41 von 61
Internals - Table
• Lob-Locator mit Lob-ID – 30 Bytes• Lob-ID nach wie vor 10 Bytes• Inline Daten 20 Bytes
BH (0x2e3f92dc) file#: 4 rdba: 0x01000b97 (4/2967) seg/obj: 0x115ff csc: 0x00.2af286 itc: 2 flg: E typ: 1 – DATA tab 0, row 0, @0x1f2c tl: 64 fb: --H-FL-- lb: 0x1 cc: 3 col 0: [ 2] c1 18 col 1: [ 6] 4b 65 79 20 32 33 col 2: [50] 00 54 00 01 02 0c 00 80 00 01 00 00 00 01 00 00 00 02 67 3e 00 1e 48 90 00
18 00 00 14 01 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 42 von 61
Internals – TableLOB Locator: Length: 84(50) Version: 1 Byte Length: 1 LobID: 00.00.00.01.00.00.00.02.67.3e Flags[ 0x02 0x0c 0x00 0x80 ]:
Type: CLOB Storage: SecureFile Characterset Format: IMPLICIT Partitioned Table: No Options: ReadWrite
SecureFile Header: Length: 30 Old Flag: 0x48 [ DataInRow SecureFile ] Flag: 0x90 [ INODE Valid ] Layers:
Lengths Array: INODE:24 INODE: 00 00 14 01 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c 61 62 6c
Länge ohne Overhead (HEX)
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 43 von 61
Beispiel 20000: TableSecureFiles mit disable storage in rowUpdate CLOB auf Gesamtlänge von 20.000 Bytes
col 2: [44] 00 54 00 01 02 0c 00 80 00 01 00 00 00 01 00 00 00 02 68 6a 00 18 40 90 00 12 21 00 4e 20 01 01 01 01 00 08 b0 01 01 01 00 07 95 02
LOB Locator:
Length: 84(44) Version: 1 Byte Length: 1
LobID: 00.00.00.01.00.00.00.02.68.6a Flags[ 0x02 0x0c 0x00 0x80 ]: Type: CLOB Storage: SecureFile Characterset Format: IMPLICIT Partitioned Table: No Options: ReadWrite
SecureFile Header: Length: 24 Old Flag: 0x40 [ SecureFile ] Flag: 0x90 [ INODE Valid ] Layers:
Lengths Array: INODE:18 INODE:
21 00 4e 20 01 01 01 01 00 08 b0 01 01 01 00 07 95 0201 00 07 95 0201 00 08 b0 01
Chunk DBAs mit Längenbyte(s)
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 44 von 61
InternalsSegment Map
Table
LOB Ind
LOB Seg E0
E1
E2
NGLOB: Lob Extent Header
NGLOB: Hash Bucket
NGLOB: Segment Header
LOCAL LOBS
NGLOB: Persistent Undo
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 45 von 61
Beispiel 3: TableSecureFiles mit disable storage in rowUpdate CLOB verkürzt von Gesamtlänge 20.000 auf 3 Bytes
Itl Xid Uba Flag Lck Scn/Fsc 0x01 0x0007.003.000005f1 0x00c002a5.01a0.0f C--- 0 scn 0x0000.002b1a5f 0x02 0x0006.009.0000065e 0x00c004cd.01b4.35 --U- 1 fsc 0x0007.002b5aa2 tl: 51 fb: --H-FL-- lb: 0x2 cc: 3 col 2: [37] 00 54 00 01 02 0c 00 80 00 01 00 00 00 01 00 00 00 02 69 f9 00 11 40 90 00 0b 20 00 03 01 00 00 01 00 07 97 01
LOB Locator: Length: 84(37) Version: 1 Byte Length: 1 LobID: 00.00.00.01.00.00.00.02.69.f9 Flags ... SecureFile Header:
Length: 17 Old Flag: 0x40 [ SecureFile ] Flag: 0x90 [ INODE Valid ] Layers:
Lengths Array: INODE:11 INODE:
20 00 03 01 00 00 01 00 07 97 01
Chunk DBAs schrumpfen
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 46 von 61
Beispiel 3: LOB Segment
frmt: 0x02 chkval: 0xd388 type: 0x3f=NGLOB: Segment Header
Extent Map ----------------------------------------------------------------- 0x01000789 length: 16 0x010008a9 length: 8 0x010008b1 length: 8 0x01000b49 length: 8 0x01000bb1 length: 8
BH (0x2cffd09c) file#: 4 rdba: 0x0100078d (4/1933) class: 8 ba: 0x2cfda000 Hash Bucket Header Dump Range: 2k to 32k Inst:1 Flag:5 Total:0 FSG_COUNT:0 OBJD:71184 Inc:0 Free Space Chunk Summary Inst:1 Minc:1 Maxc:1227544841 Count:3 Tot:5 MAXC:6 CFS Chunk List -------------- Chunk:0 DBA: 0x01000798 Len:1 Xid: 0x0001.001.000005c7 Ctime:1 Chunk:1 DBA: 0x010008b0 Len:1 Xid: 0x0005.007.000005cd Ctime:1227544841 Chunk:2 DBA: 0x01000795 Len:2 Xid: 0x0005.007.000005cd Ctime:1227544841 Deleted Chunk:3 DBA: 0x01000795 Len:2 Xid: 0x0007.003.000005f1 Ctime:1 Deleted Chunk:4 DBA: 0x01000797 Len:1 Xid: 0x0006.009.0000065e Ctime:1 Deleted Chunk:5 DBA: 0x010008b0 Len:1 Xid: 0x0007.003.000005f1 Ctime:1 --------------------------------------------------------
0x3f=NGLOB: Segment Header
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 47 von 61
Beispiel 4: Table
Itl Xid Uba Flag Lck Scn/Fsc 0x01 0x0004.016.00000625 0x00c029a9.01ab.0a ---- 1 fsc 0x0000.00000000 0x02 0x0006.009.0000065e 0x00c004cd.01b4.35 C--- 0 scn 0x0000.002b5aa2
ntab=1 nrow=2 tab 0, row 1, @0x1e9e tl: 53 fb: --H-FL-- lb: 0x1 cc: 3 col 2: [39] 00 54 00 01 02 0c 00 80 00 01 00 00 00 01 00 00 00 02 6c 20 00 13 40 90 00 0d 22 00 04 cb e5 01 00 02 01 00 0d 0a 28
LOB Locator: Length: 84(39) Version: 1 Byte Length: 1 LobID: 00.00.00.01.00.00.00.02.6c.20 SecureFile Header:
Length: 19 Old Flag: 0x40 [ SecureFile ] Flag: 0x90 [ INODE Valid ] Layers:
Lengths Array: INODE:13
INODE: 22 00 04 cb e5 01 00 02 01 00 0d 0a 28
Einfügen Lob der Länge 314341 Bytes
1 Chunk der Länge 40 (0x28)DBA 01000d0a
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 48 von 61
Beispiel 4: LOB-SegmentExtent Map
----------------------------------------------------------------- 0x01000789 length: 16 0x010008a9 length: 8 0x010008b1 length: 8 0x01000b49 length: 8 0x01000bb1 length: 8 0x01000d09 length: 128
-- aus Hash Bucket
Range: 256k to 512k Free Space Chunk Summary CFS Chunk List --------------
Deleted Chunk:0 DBA: 0x01000d0a Len:40 Xid: 0x0004.016.00000625 Ctime:1 --------------------------------------------------------
Range: 512k to 1m Free Space Chunk Summary Inst:1 Minc:1 Maxc:1 Count:1 Tot:127 MAXC:1 CFS Chunk List --------------
Chunk:0 DBA: 0x01000d32 Len:87 Xid: 0x0005.003.000005d6 Ctime:1 --------------------------------------------------------
Neues Extent
CFS – committed free space deleted – nicht frei
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 49 von 61
Beispiel 5: Extent Aufbau
• Aufbau von SF als BLOB mit Standardeinstellungen
• enable storage in row
• Einfügen einer Datei der Größe 144M
• Ungünstige Extent- Entwicklung bei Standard Storage
• Uniform Size (Beispiel 20M) zeigt kontrolliertere Entwicklung
length: 16 length: 8 length: 8 length: 1024 length: 1024 length: 128 length: 128 length: 128 length: 1024 length: 1024 length: 1024 length: 1024 length: 128 -> 13x length: 1024 length: 8192 length: 1024 length: 1024 length: 1024 length: 1024
length: 2560 length: 2560 length: 2560 length: 2560 length: 2560 length: 2560 length: 2560 length: 2560 length: 2560
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 50 von 61
Beispiel 5: TableSecureFile Header: Length: 357 Old Flag: 0x40 [ SecureFile ] Flag: 0x90 [ INODE Valid ] Layers:
Lengths Array: INODE:351 INODE:
23 00 08 f7 1c ce 24 36 01 01 00 0b ed 04 01 01 00 0c 02 07 01 01 00 0c 00 01 02 01 00 11 0a 7f 22 01 00 0d 8a 01 80 02 01 00 15 0a 7f 22 01 00 13 8a 01 80 01 01 00 11 8a 06 22 01 00 0f 0a 02 00 01 01 00 15 8a 08 22 01 00 12 0a 01 80 02 01 .... 22 01 00 23 0a 01 4d 22 01 00 1f 8a 03 00 22 01 00 24 8a 02 00 02 01 00 24 57 33 02 01 00 29 0a 7f 02 01 00 27 8a 7f 02 01 00 27 0a 7f 02 01 00 2a 8a 7f 02 01 00 28 0a 7f 02 01 00 29 8a 7f 02 01 00 28 8a 7f 02 01 00 2c 8a 7f 02 01 00 2b 0a 7f 02 01 00 2b 8a 7f 02 01 00 2a 0a 7f 02 01 00 31 0a 7f 02 01 00 2d 0a 7f 02 01 00 51 11 78 22 01 00 31 91 06 80 22 01 00 2d 8a 03 80 02 01 00 2c 0a 7f 23 01 00 38 11 19 00 22 01 00 51 8a 03 ff 02 01 00 59 8a fa
Typ: hier 1 Längen-Byte
Länge (HEX)
Chunk DBA
Teil des LOB-LocatorsGespeichert mit der Row
Typ: hier 2 Längen-Byte
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 51 von 61
Write Cache / IO Pool
• SF nutzt Shared IO Pool zur Optimierung der IO-Operationen– puffert writes Call-übergreifend– optimiert IO bei kleineren Chunks
• Daten spezifisch für Session• Infos per v$sgainfo und v$sga_dynamic_components• _shared_io_pool_size 24 MB (default) (veränderbar)• bei Überlauf Nutzung der PGA
– Statistiken hierzu in v$securefile_timer View
NAME INVOCATIONS LAYER_NAMEkdlw kcbi PGA alloc timer 0 Write gather cachekdlw kcbi PGA free timer 0 Write gather cachekdlw kcb PGA borrow timer 0 Write gather cachekdlw kcb PGA free timer 0 Write gather cache
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 52 von 61
Deduplication
• Eliminiert Redundanzen – Speichereffizienz– innerhalb eines LOB-Segmentes– nicht Partitions-übergreifend– secure hashes
• Individuelle LOB-IDs, individuelle Lob Locator• „Identität“ ermittelt über prefix hash und full hash
– Einstieg auf LOB-Segment über LOB-Index
• Redundanzfreie Speicherung in Chunks– beachten: Blockgrösse = minimale Chunkgröße
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 53 von 61
Deduplication - Tableseg/obj: 0x11685 csc: 0x00.2d8b47 itc: 2 flg: E typ: 1 – DATA Itl Xid Uba Flag Lck 0x01 0x0005.000.000005f3 0x00c003b9.01e8.24 --U- 2 ntab=1 nrow=2 tl: 186 fb: --H-FL-- lb: 0x1 cc: 3 col 0: [ 2] c1 1a col 1: [ 6] 4b 65 79 20 32 35 col 2: [172] LOB Locator: Length: 84(172) LobID: 00.00.00.01.00.00.00.02.6f.a5 SecureFile Header: Length: 152
Old Flag: 0x40 [ SecureFile ] Flag: 0x81 [ DEDUP Valid ] Layers: Lengths Array: DEDUP:146
DEDUP: Version: 0 Type: SHA1 (2) Flag: 0 Length: 146 Prefix Hash Key (20):
9c fd cd 88 c8 48 a7 3f 95 df f6 f7 26 6f 84 18 22 d8 67 a1
Full Hash Key (20): 9c fd cd 88 c8 48 a7 3f 95 df f6 f7 26 6f 84 18 22 d8 67 a1
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 54 von 61
Deduplikation – LOB Indexseg/obj: 0x11687 csc: 0x00.2d8a7c itc: 2 flg: E typ: 2 - INDEX
Itl Xid Uba Flag Lck 0x01 0x0000.000.00000000 0x00000000.0000.00 ---- 0 0x02 0x0005.000.000005f3 0x00c003b9.01e8.23 --U- 1 kdxconco 3 kdxconro 1
kdxlebksz 8032
row#0[7732] flag: ------, lock: 2, len=300, data:(255):00 00 00 01 00 00 00 02 6f a5 00 00 00 02 00 00 0b 20 00 c8 01 00 00 01 00
61 c0 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
.... 00 00 00 00 00
col 0; len 20; (20): 9c fd cd 88 c8 48 a7 3f 95 df f6 f7 26 6f 84 18 22 d8 67 a1
col 1; len 20; (20): 9c fd cd 88 c8 48 a7 3f 95 df f6 f7 26 6f 84 18 22 d8 67 a1
col 2; NULL
Lob-ID
Index enthält 3 „Spalten“ 1 Row eingefügt
DBA mit length
Hash Keys
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 55 von 61
Compression und Encryption
• Wirkungsbereich: LOB-Segment• Compression
– automatische Erkennung der Formate– Auswirkungen: Latenzzeit, CPU-Last
• Encryption– Algorithmen: 3DES168, AES128, AES192 (default), AES256– durchgeführt auf Blocklevel für LOB-Column
<LOB compression clause> ::= { COMPRESS [ HIGH | MEDIUM ] | NOCOMPRESS }
<LOB encryption clause> ::= { ENCRYPT [ USING 'encrypt_algorithm' ] [ IDENTIFIED BY password ]
| DECRYPT }
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 56 von 61
Einblick: SecureFiles Performance-Kennzahlen
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 57 von 61
Performancevergleich
0
1
2
3
4
5
6
7
Throuput [MB/s]
Cache/Logging write Cache/Logging read
Secure FileBasic File
Hardware: Pentium III@900MHz; Windows 2000 - LobSize: 10MB
Faktor 8,18
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 58 von 61
Performancevergleich
0
10
20
30
40
50
60
Throuput [MB/s]
Cache/Logging write Cache/Logging read
Secure FileBasic File
Hardware: Intel Xeon 2-CPU@3GHz - LobSize: 10MB
Faktor 2,9Faktor 1,2
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 59 von 61
Resumee
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 60 von 61
Resumee SecureFiles
• Dynamische Chunkgrößen• Entlastung des LOB-Index• Eigene Space-Verwaltung über Hash-Bucket-Blöcke• Eigene Persistent Undo-Blöcke• Deutlich verbessert Schreib- und Leseraten• Gewohntes API-Umfeld• Vertraute Syntax• „Erben“ die RAC-Orientierung von ASSM
Database Consult GmbH©Database Consult GmbH - Jachenau
LOB
versus SecureFiles
12/2008 Folie 61 von 61
Danke für´s Zuhören...