Ugif 10 2012 ppt0000001


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Ugif 10 2012 ppt0000001

  1. 1. Partition Defragmenter Yoram Benchetrit Mercredi 3 Octobre 2012 User Group Informix France
  2. 2. AgendaA bit of partition backgroundThe problem with fragmented dataHow does the feature workFunctionality & considerationsDefragmenter in OATExample User Group Informix France
  3. 3. A bit of partition backgroundWhat is an extent ? – Collection of physically contiguous pages on disk – Extent can hold data page, index page, bitmap page etc…What is a partition ? – Logical collection of all the extents allocated for a given table or index. – Space for partition is allocated in units of extents and is not necessarily contiguous.Each partition are unique within the system – oncheck –pt <partnum> User Group Informix France
  4. 4. A bit of partition backgroundPartition logical to physical extent relationship User Group Informix France
  5. 5. A bit of partition background Before Defragmenting Chunk 14 Extents for table A Extents for other tables Free pages User Group Informix France
  6. 6. A bit of partition background After Defragmenting Chunk 14 Extents for table A User Group Informix France
  7. 7. A bit of partition background Previous Solutions – Table unload and reload Oncheck –me – Off-line table reorganization – Non-recoverable – Unsupported User Group Informix France 7
  8. 8. A bit of partition backgroundHow many extents exist ? – Run oncheck –pe. – Run oncheck –pt. – SQL database sysmaster; select unique te_partnum, count(*) from systabextents group by 1 having count(*) > NN order by 1 desc; • Where NN is a value. User Group Informix France
  9. 9. The problem with fragmented dataWhat’s the problem with many extents? – Full partition page. • Prohibits new inserts. – Might not be at maximum number of rows. • Need to either delete older entries, if possible. – or • Requires a manual table recreation. – (FYI: Actually, this can no longer exist in 11.70) User Group Informix France
  10. 10. The problem with fragmented data Many extents degrades performance. – Need to skip over non-contiguous disk areas. – Slower retrieval of data. – Mapping logical page numbers to physical addresses is slower. – Chunk allocations are slower with long free list pages – Archive extent-sorting phase is slower User Group Informix France
  11. 11. The problem with fragmented data What’s the problem with many extents? – Many tables with many extents feels overbearing. • Outputs from oncheck –pe & -pt. User Group Informix France
  12. 12. How does the feature workRun new SQL API functions. – sysadmin database. – execute function [admin|task] ("<defragment", "<database>:[<owner>.]<table>[#index]") • or – execute function [admin|task] ("<defragment partnum", "<partnum> [, <partnum>, ... ]”); User Group Informix France
  13. 13. How does the feature work– What goes on behind the scenes. • Check validity. • Create new extent. • Might need just one adding • Start a loop and process all old extents. – Read old extent. – Move all old extent pages to the new extent. – Delete old extent. • Loop end. User Group Informix France
  14. 14. How does the feature workLog the work using five new log types. – Start defragmentation. – End defragmentation. – Add new defragmentation extent. – Remove old defragmentation extent. – Move page.Will result in a surge in logical log usage. User Group Informix France
  15. 15. How does the feature workMonitoring progress. – onstat -g defragment. • Searching for extents. • Merging extents. • Defrag_completed. • Defrag_failed. User Group Informix France
  16. 16. How does the feature workRecoverable if server shuts down orcrash – Defragmenter cleaner thread will remove extra extents after fast recovery • Rolls back current unit of work (UOW) if needed. – 08:52:06 Defragmenter cleaner thread now running – 08:52:06 Defragmenter cleaner thread cleaned:1 partitions – Will the object be consistent ? • Yes. – Choose to run again to complete the job. User Group Informix France
  17. 17. FunctionalityCan defragment table onlineNo locks placed on objectOnly allowed one defragmenter running perdbspaceReplication is supported (HDR, MACH11, ER)Run via the SQL API interface. User Group Informix France
  18. 18. ConsiderationsFunctionality not allowed – Functional indexes. – VTI & VII objects. – Temporary tables. – Sort tables. – Optical blobs. – System catalog tables User Group Informix France
  19. 19. ConsiderationsCannot stop once job submittedCannot run simultaneously when table being – Altered – Truncated – Drop – Compress, Repack, ShrinkNot the same as compress/repack/shrinkEnterprise Replication. – Table needs to be in CDR alter mode. • Mode unset automatically at end of job User Group Informix France
  20. 20. ConsiderationsOperation is logging-intensive – Each page move is logically logged (DFMVPG) • 70-80 bytes per page movedSmall units of work to avoid long transaction. – It may send other transactions over the thresholdNew extents created at end of dbspace.Schedule during low activity.Perform after a backup. User Group Informix France
  21. 21. Defragmenter in OATOn the OAT menu, expandSpace Administration > Space Optimization User Group Informix France 21
  22. 22. Defragmenter in OAT On the Actions menu, click Optimize Space.Select the tables. User Group Informix France 22
  23. 23. Defragmenter in OATSelect Defragment extents and click OK. User Group Informix France 23
  24. 24. Defragmenter in OATAutomatic Storage Optimization – Can automate defragmenting using OAT. – Enabled via scheduler task “auto_crsd” • This can also do compressing, repacking, shrinking. • ‘crsd’ stand for compress, repack, shrink, defragment – This can also be enabled via SQL User Group Informix France
  25. 25. Defragmenter in OAT‘auto_crsd’ task details – In OAT -> Task Scheduler -> Task Details • UPDATE ph_task SET tk_enable = T‘ WHERE tk_name = auto_crsd; User Group Informix France
  26. 26. Defragmenter in OAT‘auto_crsd’ task parameters. – UPDATE ph_threshold SET value = F WHERE name = AUTODEFRAG_ENABLED; – UPDATE ph_threshold SET value = ‘100‘ WHERE name = AUTODEFRAG_EXTENTS; User Group Informix France
  27. 27. ExampleSQL to create three fragmented tables – create table tab1 (a serial, b int, c int); – create table tab2 (a serial, b int, c int); – create table tab3 (a serial, b int, c int); – create procedure ins (a int, b int) define c int; • for c = a to b • insert into tab1 values (0, 88, 99); • insert into tab2 values (0, 88, 99); • insert into tab3 values (0, 88, 99); • end for; – end procedure; – execute procedure ins (1, 1000000); User Group Informix France
  28. 28. Exampleoncheck –pe before defragment. User Group Informix France
  29. 29. Exampleoncheck –pt before defragment.– FYI : in 11.70 No longer limited to one partn page. User Group Informix France
  30. 30. ExampleSQL API function. – execute function task ("defragment", "oltr:tab1"); (expression) OK User Group Informix France
  31. 31. Exampleoncheck –pe after defragment. User Group Informix France
  32. 32. Exampleoncheck –pt after defragment. User Group Informix France
  33. 33. Exampleonlog output User Group Informix France
  34. 34. SummaryInformix Defragmenter Capabilities – Partition Extents Defragmentation – New System Admin SQL API – OAT GUI Interface – Automatic Defragmentation – Can be completed with compress/repack/shrink for optimal storage optimization User Group Informix France
  35. 35. Questions ? User Group Informix France
  36. 36. Merci Yoram Benchetrit Mercredi 3 Octobre 2012 User Group Informix France