Home > AS/400 Tips > iSeries administrator tips > Dynamically reorganizing DB2 files
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES ADMINISTRATOR TIPS

Dynamically reorganizing DB2 files


Peter M. Codispoti
04.18.2001
Rating: -2.78- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This tip is one example of how information can be extracted from DB2/400 files and used to reorganize members only when deleted records exist. Note: My choice is to reorganize even if one record is deleted. One could calculate the percentage of deleted records and choose not to reorganize that member if it was less than that value.

How it works:
I schedule CL program REORG to run early Sunday morning -- see the code below. It contains DSPFD commands for each Library I want to analyze and each requests the member list option for physical files only. The first command issued overwrites the file SYPMBR in Library QGPL while subsequent commands append the data to that file. After all Libraries have been processed we call RPG program SYGMBR2.

SYGMBR2 tests the delete count field (MLNDTR), and if it's not equal to zero the member is reorganized. To reorganize the file, SYGMBR2 takes the left most two characters from the member name and sets the variable JOBQ to the appropriate value. Note: In our shop these two characters are consistent with the system to which they belong -- i.e. AR=Accounts Receivable; PE/PR/PY are all a part of Human Resources; etc. Therefore, it's fairly easy to ensure that only one member in a given system is reorganized before the next in the same system. All others default to the QBATCH job queue. Once the JOBQ has been set SYGMBR2 calls CL program SYCMBR2, passing variables MLLIB (library name), MLFILE (file name), MLNAME (member name), and the JOBQ. The process continues until all records have been read.

SYCMBR2 submits the RGZPFM command to the appropriate job queue. The "Job Name" is the "File Name" whose member is being reorganized.

The Benefits:
It's fully automatic. The only time changes need to be made is when a Library is added or deleted. In our shop we use Infinium's products, and when new releases are installed files come and go. Because all physical files are a


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
iSeries administrator tips
Translating Linux for IBM i admins: Using GUI to make it easy
Translating Linux for IBM i admins: Working with jobs and networking
OpenOffice: What to know before making the transition from Microsoft Office
OpenOffice: An enterprise open source solution
Database performance comparisons on IBM i
Translating Linux for IBM i admins: User profile commands
Modern System i reports using Client Access
Tips for installing Lotus Domino server on a System i partition
The iSeries Blog has a new home on IT Knowledge Exchange
Virtualization for IBM i: Backups

Integrated File System (IFS)
Transfer files from one environment to another without closing all other AS/400 sessions
Securing the integrated file system on IBM System i
Generically send a text file from the IFS via FTP
Setting ILE and C+++ compilers to runtime
Use a virtual directory to move a .bmp file from the IFS to a remote server to run a software package
Backing up PDFs within the IFS on AS/400
FTP from AS/400 to PC folder
Copying the spool file stream to IFS
An automated CL method of moving a query from AS/400 to Excel
IFS folder error

Performance
Extend storage capacity on an IBM i without negatively effecting system performance
Database drivers on the i: MySQL vs. IBM Toolbox
Performance tuning for IBM i: The basics and beyond
IBM releases new Power products for the midrange
Top System i admin tips for 2006
Catholic Charities keeps track of homeless with iSeries
i5 error messages: What you need to know
IBM races for clock speed
System shutting down after cleanup
What is the relationship between QZDAOSINIT jobs and QDBSRVnn tasks?

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


nalyzed library-by-library, we view whatever happens to be there at that time. Files with multiple members only have their members reorganized if the member has deleted records -- not every member whether it needs it or not. In our shop reorganization has gone from 12 hours to 3 hours or less and I know that whatever needed done was done!

The Programs:

1. CL Program REORG

2. RPG Program SYGMBR2

3. CL Program SYCMBR2

Reader Feedback

Steve W. writes: This is all well and good, and can be the basis for a more robust utility that incorporates thresholds to control what files really need to be reorganized. However the problem is that the reorganization job needs to have an exclusive lock on the file for the length of the reorganization, which is nearly impossible in today's 24x7 e-business environment.

Two other solutions come to mind:

1) The use of the reuse deleted records attribute to eliminate the need for reorganizations. This can have detrimental impact on performance and programs which foolishly assume that the relative record number is always in FIFO order.

2) SoftLanding Systems Turnover PDQ. I have been using this product for two years now and can heartily recommend its use and reliability. This product creates a duplicate of the file, copies records from the original into the duplicate (thus compressing out deleted records) while also reading the journal receiver over the original file to ensure that all add/change/delete transactions are applied. Finally, at a controlled point in time, it will obtain a lock on the original file (okay, it will only work in a 23.9 x 7 environment) then swap the duplicate with the original. I would consider this a far more "Dynamic" solution that the example.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts