IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to handle alternate index in DB2?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
guruji
Warnings : 1

New User


Joined: 13 Apr 2007
Posts: 59
Location: Chennai

PostPosted: Fri Jun 15, 2007 4:56 pm
Reply with quote

Hi,

I am doing a conversion from an existing VSAM file into a DB2 table. While maping the variables, I found a difficulty in handling the alternate Index that is exixting in VSAM.

Could you please suggest me a solution?

Thanks,
Reni
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jun 18, 2007 6:26 am
Reply with quote

Hello,

For us to be able to help with this question
Quote:
While maping the variables, I found a difficulty in handling the alternate Index that is exixting in VSAM.
you need to tell us what difficulty you found.

Did you encounter some compile problem, a run-time error, other?

When you describe what is not working as desired, we can offer suggestions.
Back to top
View user's profile Send private message
guruji
Warnings : 1

New User


Joined: 13 Apr 2007
Posts: 59
Location: Chennai

PostPosted: Tue Jun 19, 2007 3:07 pm
Reply with quote

The problem I faced is nothing else but how to map the VSAM alternate indexes to DB2?
Is it something like handling creting more than one index corresponding to the AIX in VSAM?

Thanks,
Reni
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Tue Jun 19, 2007 5:46 pm
Reply with quote

If you are traversing the VSAM file via the alternate index in COBOL, and you want the new DB2 program to see the records in the same order (which presumably you do), then you will most likely replace your VSAM processing with a DB2 cursor whose SELECT's ORDER BY clause specifies the record order matching your VSAM alt index.

If you do this frequently, or have lots of records when you do, then having a key built on these fields will assist efficiency.

Real DB2 experts (which I am not) - please chime in here.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jun 19, 2007 6:25 pm
Reply with quote

Hello,

In addition to defining a cursor that retrieves the rows in the needed order, the fields in question need to be defined as indexes to db2 to provide direct access rather than a full table traversal.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Tue Jun 19, 2007 6:57 pm
Reply with quote

Dick -

Doesn't the issue of having an index on those fields relate to table size?

Also, if the table is very frequently updated, therefore requiring lots of index maintenance overhead, but the cursor in question seldom needed, then might it be better to forget the index and allow an occasional full traversal?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jun 19, 2007 7:20 pm
Reply with quote

Hello,

That would be the ever famous "it depends".

If it is a multiple-hundred million row table any full traversal will have a noticable impact. If it is a 100 or 1000 row table, a full traversal will barely be noticed.

The same with additional index definitions. Records are inserted and deleted only once, so there is that one-time cost of the additional index(es). If these index fields are changed quite often, that would need to be considered. If rows are added and not purged for a very long time, additional index entries speed lots of different queries and batch processing. If rows are used very often in online and ad-hoc queries/reporting, additional indexes are usually your friend.

The index entries are not stored with the table data, so the actual table data size does not increase - index space would increase, but that is usually not linear.

If there is doubt about which way to go, it is a good idea to test different approaches. The alternative to use may become obvious or it may not. One of the things i've found tougher to test is getting a couple hundred or a couple thousand concurrent "users" to see how the alternatives perform when not running in an isolated environment (i.e. single tester/process). Sometimes an isolated test is quite sufficient to demonstrate an unattractive alternative icon_smile.gif .

As i mentioned at the beginning of this reply - it depends, but i encourage in depth testing for anything that may be a critical process or substantial resource consumer.
Back to top
View user's profile Send private message
ameen.syed

New User


Joined: 23 Jun 2007
Posts: 2
Location: bangalore

PostPosted: Fri Aug 03, 2007 8:51 am
Reply with quote

Will creating of Referencial - keys in DB2, help in mapping of Alternate index in VSAM???PLz let me know
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Aug 03, 2007 6:17 pm
Reply with quote

Hello,

There is no relationship bewteen DB2 keys and alternate indexes in vsam. They are in completely different environments.

If you clarify your question, we may be able to offer suggestions.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Fri Aug 03, 2007 6:24 pm
Reply with quote

Also note, even with an alternate index, you can't ensure the rows are in any kind of order without using the ORDER BY.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Aug 03, 2007 7:12 pm
Reply with quote

it appears that your table design was based on the vsam record format. rarely does a vsam record convert directly to a db2 row if any normalization has been done. The quick and dirty get it done now will always bite your butt later! (I know that one should not use always when talking about computers, but I was actually talking about lazyness)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Cobol file using index COBOL Programming 2
No new posts DL/I status code AK for GU call using... IMS DB/DC 1
No new posts Add column to existing records using ... JCL & VSAM 2
No new posts choice of clustering index DB2 3
No new posts Secondary index error while loading d... IMS DB/DC 2
Search our Forums:

Back to Top