DB2 LUW V9.7 (Cobra) - Storage is Charmed

Embed Size (px)

DESCRIPTION

 

Text of DB2 LUW V9.7 (Cobra) - Storage is Charmed

  • 1. Sept. 2009 Bill Minor IBM DB2 LUW V9.7 (Cobra) Storage is Charmed

2. Highlights

  • This presentation will dive into storage management and administration in DB2 LUW. A detailed, holistic look into storage will be provided, including a preview of new exciting features and capabilities planned for DB2's next release.
  • Topics of discussion will include:
    • Line dancing with LOB and XML data
    • Compression to the max- Deep compression gets deeper with index, temp, xml and lob compression along with replication support
    • Swimming in shallow water- life without the High Water Mark and space reclamation made easy
    • Itty Bitty Reorg- one range partition at a time
    • Mean and lean MDC

3. Compression To Date

  • DB2 V8.1 Database Backup Compression
  • DB2 V8.1 NULL and Default Value Compression
  • DB2 V8.1 MDC Tables
  • DB2 9.1 Row (or Table) Compression
  • DB2 9.5 Enhanced Row Compression support
  • DB2 9.5 XML Inlining (compression of small XML docs)

4. Roadmap: Where Are We Headed?

  • Further reduction in overall storage footprint
  • But also, improved administration of storage as a whole (capacity, space reclamation, online support, monitoring, )
  • Technology Preview (TP)

5. Agenda

  • LOB Inlining(XML Inlining DB2 V9.5)
  • Compression Replication Support
  • Index Compression
  • Temp Table Compression
  • Space Reclaim: Sparse MDC Tables
  • Tablespace Extent Remapping (Tablespace HWM Management)
  • Local or Partitioned Index Support for Range Partitioned Tables
  • XDA (XML) Compression

6. Inlining

  • If a table possesses LOB or XML data that can be inlined, there are considerable benefits with respect to performance and storage use
  • Performance
    • Whenever LOBs are inserted/retrieved, a disk I/O cost is incurred each time since this data is not buffered (unlike with base table data)
    • When inlined, this I/O cost is reduced since this data get buffered along with the base table data they are inlined with
  • Storage
    • Storage allocated to the storage object is reduced by inlining XML/LOB data in the base table (though base table storage increases)
    • Inlining small XML/LOBs can result in a noticeable decrease in net total storage since the decrease in storage size is greater than the increase in base table storage size
    • XML/LOBs inlined within the base table data can be compressed

7. XML Inlining and Compression(DB2 V9.5) 100 Concurrent Users 12-way AIX 8. LOB Inlining (TP)

  • Instead of strictly storing LOB data in the LOB storage object, the LOBs, if sufficiently sized, can be stored in the formatted rows of the base table
  • Dependant on page size, the maximum length a LOB can be to qualify for inlining is 32 669 bytes
  • LOB inlining is analogous to XML inlining for XML data
  • Example:
  • create table mytab1 (a int, b char(5), c clob inline length 1000 )

a Base table, mytab1 LOB storage object b c 3 cat 9 dog rat 27 bbbbbbbbbbbb aaaaaaaaaaa cccccccccccc 9. How does it work?

  • When creating a table with LOB columns, by default, an inline length is set for each LOB column (based on the maximum length of the column)
  • To explicitly specify an inline length, there are two methods:
    • During table creation
    • By altering an existing tables LOB columns
  • To then inline the existing data, reorg table with LONGLOBDATA option
  • Examples
  • create table mytab1 (a int, b char(5), c clob inline length 1000)
  • alter table mytab1 alter column c set inline length 2000
  • Note:
  • When altering a LOB columns inline length, it cannot be smaller than the inline
  • length set by a prior table create/alter

10. Example: LOB Inlining

  • All LOBs in this table are smaller than the default inline length for the LOB columns
    • 100% of the LOBs for this table, inlined in Cobra!

15616 33152 46336 65536 Total (KBs) 10752 10880 10752 10880 Indexes (KBs) 128 128 30336 30336 LOB storage (KBs) 4736 22144 5248 24320 Base table (KBs) Cobra (LOB inlining, compression) Cobra (LOB inlining) V9.5 (compression) V9.5 11. LOB Inlining Notes:

  • If the clause INLINE LENGTH is not specified, the default initial inline length is equal to the size of the LOB descriptor (the size of the LOB descriptor varies depending on the LOB size of the column)
  • Inlined LOB data is treated as if it were VARCHAR data
  • If LOB data cannot be inlined it will be inserted in the LOB object (which is stored separately from the table rows)

12. Inlining Administrative Table Functions

  • ADMIN_EST_INLINE_LENGTH()
    • Returns an estimate of the inline length required to inline the data, a negative value if data cannot be inlined, or if data already inlined, the actual inline length is returned
  • ADMIN_IS_INLINED ()
    • Will report whether the XML documents in a column are inlined or not
  • Example:
  • select admin_is_inlined(xml_doc1) as IS_INLINED, admin_est_inline_length(xml_doc1) as EST_INLINE_LENGTH from tab1
  • IS_INLINEDEST_INLINE_LENGTH
  • ---------------------------
  • 1292
  • 0450
  • 0454

13. Table Compression in V9.1/9.5

  • To compress a table the COMPRESS attribute must be enabled
  • When compression is active, user data written to the log files is compressed (we do not compress log files but compress the data in them)
  • Replication programs read the log files and therefore need to be able to decipher the contents of a log file that contains compressed data
  • Only one of COMPRESS YES or DATA CAPTURE CHANGES can be enabled on a table in V9.1/9.5

14. Compression & Replication (TP)

  • DB2 V9.5 -compress yesnot compatible withdata capture changesclause
  • Capture requires uncompressed log data in log records
  • Recall- log data from compressed records in compressed format
    • alter table rowcomp.rc1 compress yes
    • DB20000IThe SQL command completed successfully.
    • alter table rowcomp.rc1 data capture changes
    • DB21034EThe command was processed as an SQL statement because it was not a
    • valid Command Line Processor command.During SQL processing it returned:
    • SQL0270NFunction not supported (Reason code = "83").SQLSTATE=42997

Example: Insert log record User record not compressed User record compressed Log Header TX 1235 Mary Smith Log Header 05 06 02 07 04 15. Compression and db2ReadLog

  • db2ReadLog API will now decompress log data before returning log records

Log db2ReadLog API Log db2ReadLog API Dictionary Compressed user data in logs Uncompressed user data in logs DB2V9.7with iFilterOption ONDB2V9.5with iFilterOption ON 16. Compression Replication Support

  • When enabled, a single historical dictionary will also be retained in the table data object
  • This allows for latency in the log read
    • If the existing compression dictionary is reset, the prior dictionary is still available to the log reader in order to interpret log records that were written using that earlier version of the dictionary
  • ADMIN_GET_TAB_INFO can be used to get the sizes of dictionaries

17. Index Compression (TP)

  • The approach used is different than row compression
    • Various algorithms are employed at the discretion of the database engine
      • RID List Compression
      • Prefix Compression
      • Index meta-data optimization
  • Compression of index objects via
    • COMPRESS clause on CREATE INDEX statement
    • COMPRESS clause on new ALTER INDEX statement
      • Index reorganization required to rebuild the index in compressed (or uncompressed) format
    • By default, new indexes on a row compressed table will be compressed (except for MDC block indexes and XML meta and paths indexes)

18. Index Compression (continued)

  • Two new columns added to SYSIBM.SYSINDEXES and SYSIBM.SYSINDEXPARTITIONS
    • COMPRESSION