Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
IBM Software Group
®
DB2DART
• Database Analysis and Reporting Tool
• By
• Umesh Dande
• umedande@in.ibm.com
IBM Software Group | DB2 Information Management Software
– 1. DB2DART – An Overview
– Example of DB2DART where and how to ...
IBM Software Group | DB2 Information Management Software
DB2DART – An Overview
As this tool have vast potential still it ...
IBM Software Group | DB2 Information Management Software
 db2dart - architectural correctness of databases
Automatic reco...
IBM Software Group | DB2 Information Management Software
Command Syntax
>>-db2dart--database-name- >< '-action' '-options-...
IBM Software Group | DB2 Information Management Software
 Granularity
 Database: db2dart <db> /DB
 Tablespace: db2dart ...
IBM Software Group | DB2 Information Management Software
 Sample DB2Dart Report
DART (V9.7) Report:
2011-12-20-07.16.48.7...
IBM Software Group | DB2 Information Management Software
 Performance Issue
 Correct Index corruption
DB2DART – Check in...
IBM Software Group | DB2 Information Management Software
DB2DART – Performance Issue
 Performance Issue
 Same Query runn...
IBM Software Group | DB2 Information Management Software
Check index marked invalid
 How to correct index corruption
 Ge...
IBM Software Group | DB2 Information Management Software
DB2DART – Reduce high water mark
 Reduce high water mark with db...
IBM Software Group | DB2 Information Management Software
• db2dart sample /dhwm /tsi 8
• High water mark: 288 pages, 9 ext...
IBM Software Group | DB2 Information Management Software
• db2 drop table tab9
• db2dart sample /dhwm /tsi 8
• High water ...
IBM Software Group | DB2 Information Management Software
• Table: IHUBV97.TAB8
• DAT object size: 2
• INX object size: 0
•...
IBM Software Group | DB2 Information Management Software
• db2 "reorg table IHUBV97.TAB8"
• DB20000I The REORG command com...
IBM Software Group | DB2 Information Management Software
DB2DART – Table data export
 Table data got corrupted.
 Table i...
IBM Software Group | DB2 Information Management Software
Following is way to recover these tables
We can see following err...
IBM Software Group | DB2 Information Management Software
Filename used for output data file is tab7.del. If existing file,...
IBM Software Group | DB2 Information Management Software
How to differentiate between data page and index page
Following i...
IBM Software Group | DB2 Information Management Software
How to differentiate between data page and index page
Following ...
IBM Software Group | DB2 Information Management Software
 inspect database for architectural integrity, checking the page...
IBM Software Group | DB2 Information Management Software
• Sample output of inspect
• db2 connect to sample
• db2 inspect ...
IBM Software Group | DB2 Information Management Software
db2 inspect check table name tab8 results keep tab8.txt
db2inspf ...
IBM Software Group | DB2 Information Management Software
 To estimate the space saving
db2 inspect rowcompestimate table ...
IBM Software Group | DB2 Information Management Software
Difference -DB2DART and Inspect
Tests performed db2dart INSPECT
S...
IBM Software Group | DB2 Information Management Software
Difference -DB2DART and Inspect
Tests performed db2dart INSPECT
C...
IBM Software Group | DB2 Information Management Software
Difference -DB2DART and Inspect
Tests performed db2dart INSPECT
C...
IBM Software Group | DB2 Information Management Software
Difference -DB2DART and Inspect
Block Map Object
Tests performed ...
IBM Software Group | DB2 Information Management Software
 DB2DART should be schedule in regular maintenance
plan
 If not...
IBM Software Group | DB2 Information Management Software
Questions
Upcoming SlideShare
Loading in …5
×

db2dart and inspect

7,597 views

Published on

Published in: Technology, Business
  • it is very useful
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

db2dart and inspect

  1. 1. IBM Software Group ® DB2DART • Database Analysis and Reporting Tool • By • Umesh Dande • umedande@in.ibm.com
  2. 2. IBM Software Group | DB2 Information Management Software – 1. DB2DART – An Overview – Example of DB2DART where and how to use  Performance issue  Index corruption  High water mark  Export table data 2. Inspect - An Overview Example of inspect  Estimate Row compression  Difference – db2dart and Inspect DB2DART
  3. 3. IBM Software Group | DB2 Information Management Software DB2DART – An Overview As this tool have vast potential still it is rarely used by DBA DBAs can use the tool – increases productivity db2dart db2trc db2support db2diag db2exfmt db2top db2pd
  4. 4. IBM Software Group | DB2 Information Management Software  db2dart - architectural correctness of databases Automatic recovery of the database  “Offline” tool for checking the architectural correctness of a database  Critical for investigating problems involving data corruption  It is “Offline Tool” why? DB2DART – An Overview
  5. 5. IBM Software Group | DB2 Information Management Software Command Syntax >>-db2dart--database-name- >< '-action' '-options-' /DB – Inspect entire database /T - Inspects only Table /TSF – Inspects only table space files and container /DD - Dumps formatted table data /DDEL – Dumps formatted data into in delimited format DB2DART – An Overview
  6. 6. IBM Software Group | DB2 Information Management Software  Granularity  Database: db2dart <db> /DB  Tablespace: db2dart <db> /TS  Table: db2dart <db> /T /TSI /OI  db2dart /MI -- Index level DB2DART – An Overview
  7. 7. IBM Software Group | DB2 Information Management Software  Sample DB2Dart Report DART (V9.7) Report: 2011-12-20-07.16.48.786055 Database Name: SAMPLE Report name: SAMPLE.RPT Old report back-up: SAMPLE.BAK Database Subdirectory: /home/umesh/ihubv97/NODE0000/SQL00006 Operational Mode: Database Inspection Only (INSPECT) ______________________________________________________________________________ ------------------------------------------------------------------------------------------------------------------------------- Action option: DB Connecting to Buffer Pool Services... Database inspection phase start. Tablespace file inspection phase start. Loading tablespace files. Inspecting next tablespace and associated containers. Inspecting next tablespace and associated containers. Inspecting next tablespace and associated containers. Inspecting next tablespace and associated containers. Inspecting next tablespace and associated containers. Inspecting next tablespace and associated containers. Inspecting next tablespace and associated containers. Inspecting next tablespace and associated containers. Inspecting next tablespace and associated containers. 9 tablespaces were identified and their containers checked. Tablespace file inspection phase end. DB2DART – An Overview
  8. 8. IBM Software Group | DB2 Information Management Software  Performance Issue  Correct Index corruption DB2DART – Check index marked invalid
  9. 9. IBM Software Group | DB2 Information Management Software DB2DART – Performance Issue  Performance Issue  Same Query running slow  Explain Plan looks identical  Index corruption might be problem Following is sample db2dart sample Index inspection phase start. Index obj: 26 In pool: 0 Scanning pages for unique index itoken(0) root page:1p. Scanning pages for unique index itoken(1) root page:2p. Error: page in tree but not marked in use: Object Page (722) Error: in page 722, pool page 722, of obj 26, in tablespace 0. Error: Page data will be dumped to report. To correct this use following command Mark index bad db2dart db2_name /MI Pool id : 0 Indexid : 26  According to INDEXREC setting index will be recreated
  10. 10. IBM Software Group | DB2 Information Management Software Check index marked invalid  How to correct index corruption  Get the table space and index id from syscat tables. • Get the TBSPACEID and INDEX_OBJECTID with the following command. • db2 "select TBSPACEID, IID, INDEX_OBJECTID from syscat.indexes where tabname='TAB_1' " • TBSPACEID IID INDEX_OBJECTID – ----------- ------ -------------- – 3 1 278 – 3 2 279 db2dart <DBNAME> /di /tsi <TBSPACEID> /oi <INDEX_OBJECTED> /ps 0 /np 1 /v y db2dart sample /di /tsi 3 /oi 278 /ps 0 /np 1 /v y • The requested DB2DART processing has completed successfully! • Complete DB2DART report found in: • /home/umesh/sqllib/db2dump/DART0000/SAMPLE.RPT 1.3 Check the SAMPLE.RPT • Free Page Map: • Page Type = x01000210 • pg0FileLSN = 0000 0DAC 5374 • nextSMP= 0 flags=x1 Indexes are marked INVALID db2dart db2_name /MI Pool id : 0 Indexid : 26  According to INDEXREC setting index will be recreated
  11. 11. IBM Software Group | DB2 Information Management Software DB2DART – Reduce high water mark  Reduce high water mark with db2dart (DMS tablespace)  Following is example of same ● Suppose we have tablespace with three tables 0 tab7 499|500 tab8 999|1000 tab9 1499|1999 TBS size is 2000 HWM is 1499 0 tab7 499|500 tab8 999|1000 tab9 1499|1999 Now we dropped tab7 and tab 9 TBS size is 2000 Still HWM is 1499 0 tab7 499|500 tab8 999|1000 tab9 1499|1999 We run db2dart TBS Size is 2000 HWM will be 999
  12. 12. IBM Software Group | DB2 Information Management Software • db2dart sample /dhwm /tsi 8 • High water mark: 288 pages, 9 extents (extents #0 - 8) • [0000] 65534 0x0e [0001] 65534 0x0e [0002] 65535 0x00 [0003] 4 0x40* • [0004] 4 0x00* [0005] 5 0x40* [0006] 5 0x00* [0007] 6 0x40* • [0008] 6 0x00* • db2dart sample /lhwm /tsi 8 /np7 • Dump high water mark processing - phase start. • Number of free extents below high water mark: 0 • Number of used extents below high water mark: 9 • High water mark: 288 pages, 9 extents (extents #0 - 8) • Lower high water mark processing - phase start. • Current high water mark: 8 • Desired high water mark: 0 • Number of used extents in tablespace: 7 • Number of free extents below original HWM: 2 • Number of free extents below desired HWM: 0 • Number of free extents below current HWM: 2 • High water mark: 288 pages, 9 extents (extents #0 - 8) • db2 drop table tab7 • db2dart sample /dhwm /tsi 8 • [0000] 65534 0x0e [0001] 65534 0x0e [0002] 65535 0x00 [0003] == EMPTY == • [0004] == EMPTY == [0005] 5 0x40* [0006] 5 0x00* [0007] 6 0x40* • [0008] 6 0x00* • Dump high water mark processing - phase start. • Number of free extents below high water mark: 2 • Number of used extents below high water mark: 7 DB2DART – Reduce high water mark
  13. 13. IBM Software Group | DB2 Information Management Software • db2 drop table tab9 • db2dart sample /dhwm /tsi 8 • High water mark: 288 pages, 9 extents (extents #0 - 8) • [0000] 65534 0x0e [0001] 65534 0x0e [0002] 65535 0x00 [0003] == EMPTY == • [0004] == EMPTY == [0005] 5 0x40* [0006] 5 0x00* [0007] == EMPTY == • [0008] == EMPTY == • Dump high water mark processing - phase start. • Number of free extents below high water mark: 4 • Number of used extents below high water mark: 5 • db2dart sample /lhwm /tsi 8 /np 5 • High water mark: 288 pages, 9 extents (extents #0 - 8) • Lower high water mark processing - phase start. • Current high water mark: 8 • Desired high water mark: 0 • Number of used extents in tablespace: 5 • Number of free extents below original HWM: 4 • Number of free extents below desired HWM: 0 • Number of free extents below current HWM: 4 • Step #1: Object ID = 5 • => Offline REORG of this table (do not specify a temporary tablespace • and do not use the LONGLOBDATA option). DB2DART – Reduce high water mark Offline Reorg suggestion
  14. 14. IBM Software Group | DB2 Information Management Software • Table: IHUBV97.TAB8 • DAT object size: 2 • INX object size: 0 • XDA object size: 0 • LF object size: 0 • LOB object size: 0 • LOBA object size: 0 • BMP object size: 0 • Total size of object parts: 2 • Minimum number of extents that will move by this operation: 2 • Current high water mark: 4 • Desired high water mark: 0 • Number of used extents in tablespace: 5 • Number of free extents below original HWM: 4 • Number of free extents below desired HWM: 0 • Number of free extents below current HWM: 0 • High water mark: 288 pages, 9 extents (extents #0 - 8) • [0000] 65534 0x0e [0001] 65534 0x0e [0002] 65535 0x00 [0003] == EMPTY == [0004] == EMPTY == [0005] 5 0x40* [0006] 5 0x00* [0007] == EMPTY == • [0008] == EMPTY == • Dump high water mark processing - phase start. • Number of free extents below high water mark: 4 • Number of used extents below high water mark: 5 DB2DART – Reduce high water mark
  15. 15. IBM Software Group | DB2 Information Management Software • db2 "reorg table IHUBV97.TAB8" • DB20000I The REORG command completed successfully. • High water mark: 224 pages, 7 extents (extents #0 - 6) • [0000] 65534 0x0e [0001] 65534 0x0e [0002] 65535 0x00 [0003] 5 0x40* • [0004] 5 0x00* [0005] == EMPTY == [0006] == EMPTY == • Dump high water mark processing - phase start. • Number of free extents below high water mark: 2 • Number of used extents below high water mark: 5 DB2DART – Reduce high water mark
  16. 16. IBM Software Group | DB2 Information Management Software DB2DART – Table data export  Table data got corrupted.  Table is not accessible  Select table fails with error sql1477N  This is scenario which happens when load is failed with non recoverable option  Alter table statement fails for activate not logged initially
  17. 17. IBM Software Group | DB2 Information Management Software Following is way to recover these tables We can see following error message in db2diag ADM5571W DB2 is marking object "0" of table "TBSPACEID=8.TABLEID=4“ bash-3.00$ db2dart sample /DDEL Table object data formatting start. Please enter Table ID or name, tablespace ID, first page, num of pages: 4,8,0,999999 2 of 2 columns in the table will be dumped. Column numbers and datatypes of the columns dumped: 0 VARCHAR() -VARIABLE LENGTH CHARACTER STRING 1 VARCHAR() -VARIABLE LENGTH CHARACTER STRING Default filename for output data file is TS8T4.DEL, do you wish to change filename used? y/n Y • Please enter filename for output data file (maximum characters 8 for name and 3 for extension): • tab7.del DB2DART – Table data export
  18. 18. IBM Software Group | DB2 Information Management Software Filename used for output data file is tab7.del. If existing file, data will be appended to it. Formatted data being dumped ... Dumping Page 0 .... Dumping Page 1 .... Dumping Page 2 .... Dumping Page 3 .... Dumping Page 4 .... Dumping Page 5 .... Dumping Page 6 .... Dumping Page 7 .... Dumping Page 8 .... Table object data formatting end. The requested DB2DART processing has completed successfully! Complete DB2DART report found in: /home/ihubv97/sqllib/db2dump/DART0000/SAMPLE.RPT • bash-3.00$ ls -l /home/ihubv97/sqllib/db2dump/DART0000/ • total 600 • -rw-r----- 1 ihubv97 db2iadm 1584 Dec 15 13:04 BUDGET.BAK • -rw-r----- 1 ihubv97 db2iadm 1566 Dec 15 13:04 BUDGET.RPT • -rw-r--r-- 1 ihubv97 db2iadm 39525 Dec 16 16:42 DART.INF • -rw-r----- 1 ihubv97 db2iadm 38194 Dec 11 12:52 PMR.BAK • -rw-r----- 1 ihubv97 db2iadm 156688 Dec 11 12:52 PMR.RPT • -rw-r----- 1 ihubv97 db2iadm 2551 Dec 16 16:42 SAMPLE.BAK • -rw-r----- 1 ihubv97 db2iadm 2013 Dec 19 11:18 SAMPLE.RPT • -rw-r----- 1 ihubv97 db2iadm 45864 Dec 19 11:18 tab7.del DB2DART – Table data export
  19. 19. IBM Software Group | DB2 Information Management Software How to differentiate between data page and index page Following is db2diag error captured for data page corruption A3751 LEVEL: Severe PID : 1106162 TID : 13366 PROC : db2sysc 0 INSTANCE: tsm48 NODE : 000 DB : TSMDB1 APPHDL : 0-7 APPID: 127.0.0.1.33030.110623062649 AUTHID : TSM48 EDUID : 13366 EDUNAME: db2redow (TSMDB1) 0 FUNCTION: DB2 UDB, buffer pool services, sqlb_verify_page, probe:2 MESSAGE : ZRC=0x86020001=-2046689279=SQLB_BADP "page is bad" DIA8400C A bad page was encountered. DATA #1 : String, 64 bytes Error encountered trying to read a page - information follows : DATA #2 : String, 23 bytes Page verification error DATA #3 : Page ID, PD_TYPE_SQLB_PAGE_ID, 4 bytes 2229977 DATA #4 : Object descriptor, PD_TYPE_SQLB_OBJECT_DESC, 88 bytes Obj: {pool:6;obj:5;type:0} Parent={5;5} Need to engage db2support for this correction DB2DART – Table data export
  20. 20. IBM Software Group | DB2 Information Management Software How to differentiate between data page and index page Following is db2diag error captured for index page corruption A3751 LEVEL: Severe PID : 1106162 TID : 13366 PROC : db2sysc 0 INSTANCE: tsm48 NODE : 000 DB : TSMDB1 APPHDL : 0-7 APPID: 127.0.0.1.33030.110623062649 AUTHID : TSM48 EDUID : 13366 EDUNAME: db2redow (TSMDB1) 0 FUNCTION: DB2 UDB, buffer pool services, sqlb_verify_page, probe:2 MESSAGE : ZRC=0x86020001=-2046689279=SQLB_BADP "page is bad" DIA8400C A bad page was encountered. DATA #1 : String, 64 bytes Error encountered trying to read a page - information follows : DATA #2 : String, 23 bytes Page verification error DATA #3 : Page ID, PD_TYPE_SQLB_PAGE_ID, 4 bytes 2229977 DATA #4 : Object descriptor, PD_TYPE_SQLB_OBJECT_DESC, 88 bytes Obj: {pool:6;obj:5;type:1} Parent={5;5} DB2DART can be used DB2DART – Table data export
  21. 21. IBM Software Group | DB2 Information Management Software  inspect database for architectural integrity, checking the pages of the database for page consistency  “Online” tool  Estimate row compression INSPECT – An Overview
  22. 22. IBM Software Group | DB2 Information Management Software • Sample output of inspect • db2 connect to sample • db2 inspect check database result sample.txt • The output of inspect will be stored in db2dump folder • Format this file with db2inspf • db2inspf sample.out.000 sample.out • DATABASE: SAMPLE • VERSION : SQL09073 • 2011-12-20-11.36.49.182557 • Action: CHECK DATABASE • Tablespace ID: 8 • Result file name: sample.out • Database phase start. • Tablespace phase start. Tablespace ID: 8 • Tablespace name: TEST1 • Tablespace Type: DMS - Database Managed Space; Extent size: 32; Page size: 8192; Number of containers: 1 • Container name: /home/ihubv97/test1 • Table phase start (ID Signed: -2, Unsigned: 65534; Tablespace ID: 8) : • Data phase start. Object: 65534 Tablespace: 8 • Data phase end. • Table phase end. INSPECT – database inspection
  23. 23. IBM Software Group | DB2 Information Management Software db2 inspect check table name tab8 results keep tab8.txt db2inspf tab8.txt tab8.out The inspect result will be like this DATABASE: SAMPLE VERSION : SQL09073 2011-12-20-12.05.30.791725 Action: CHECK TABLE Schema name: IHUBV97 Table name: TAB8 Tablespace ID: 8 Object ID: 5 Result file name: tab8.txt Table phase start (ID Signed: 5, Unsigned: 5; Tablespace ID: 8) : IHUBV97.TAB8 Data phase start. Object: 5 Tablespace: 8 Traversing DAT extent map, anchor 96. Extent map traversal complete. DAT Object Summary: Total Pages 18 - Used Pages 18 - Free Space 5 % Data phase end. Table phase end. Processing has completed. 2011-12-20-12.05.30.794316 INSPECT – Index and table checking
  24. 24. IBM Software Group | DB2 Information Management Software  To estimate the space saving db2 inspect rowcompestimate table name tab7 schema ihubv97 results keep rowcomp db2inspf rowcomp rowcomp.txt The inspect result will be like this DATABASE: SAMPLE VERSION : SQL09073 2011-12-20-14.07.54.811637 Action: ROWCOMPESTIMATE TABLE Schema name: IHUBV97 Table name: TAB7 Tablespace ID: 8 Object ID: 4 Result file name: rowcomp Table phase start (ID Signed: 4, Unsigned: 4; Tablespace ID: 8) : IHUBV97.TAB7 Data phase start. Object: 4 Tablespace: 8 Row compression estimate results: Percentage of pages saved from compression: 64 Percentage of bytes saved from compression: 64 Compression dictionary size: 2304 bytes. Expansion dictionary size: 3080 bytes. Data phase end. Table phase end. Processing has completed. 2011-12-20-14.07.54.827509 INSPECT – Table compression
  25. 25. IBM Software Group | DB2 Information Management Software Difference -DB2DART and Inspect Tests performed db2dart INSPECT SMS table spaces Check table space files YES NO Validate contents of internal page header fields YES YES DMS table spaces Check for extent maps pointed at by more than one object YES NO Check every extent map page for consistency bit errors NO YES Check every space map page for consistency bit errors NO YES Validate contents of internal page header fields YES YES Verify that extent maps agree with table space maps YES NO Table Space
  26. 26. IBM Software Group | DB2 Information Management Software Difference -DB2DART and Inspect Tests performed db2dart INSPECT Check data objects for consistency bit errors YES YES Check the contents of special control rows YES NO Check the length and position of variable length columns YES NO Check the LONG VARCHAR, LONG VARGRAPHIC, and large object (LOB) descriptors in table rows YES NO Check the summary total pages, used pages and free space percentage NO YES Validate contents of internal page header fields YES YES Verify each row record type and its length YES YES Verify that rows are not overlapping YES YES Data Object
  27. 27. IBM Software Group | DB2 Information Management Software Difference -DB2DART and Inspect Tests performed db2dart INSPECT Check for consistency bit errors YES YES Check the location and length of the index key and whether there is overlapping YES YES Check the ordering of keys in the index YES NO Determine the summary total pages and used pages NO YES Validate contents of internal page header fields YES YES Verify the uniqueness of unique keys YES NO Check for the existence of the data row for a given index entry NO YES Verify each key to a data value NO YES Index Object
  28. 28. IBM Software Group | DB2 Information Management Software Difference -DB2DART and Inspect Block Map Object Tests performed db2dart INSPECT Check for consistency bit errors YES YES Determine the summary total pages and used pages NO YES Validate contents of internal page header fields YES YES Tests performed db2dart INSPECT Check the allocation structures YES YES Determine the summary total pages and used pages (for LOB objects only) NO YES Long and LOB Object
  29. 29. IBM Software Group | DB2 Information Management Software  DB2DART should be schedule in regular maintenance plan  If not possible on production database (live database) , should be run on database, restored from backup Suggestions from DB2 Support Team
  30. 30. IBM Software Group | DB2 Information Management Software Questions

×