Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to handle alternate index in DB2?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
guruji
Warnings : 1

New User


Joined: 13 Apr 2007
Posts: 59
Location: Bangalore

PostPosted: Fri Jun 15, 2007 4:56 pm    Post subject: How to handle alternate index in DB2?
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

Site Director


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

PostPosted: Mon Jun 18, 2007 6:26 am    Post subject:
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: Bangalore

PostPosted: Tue Jun 19, 2007 3:07 pm    Post subject:
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

Active Member


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

PostPosted: Tue Jun 19, 2007 5:46 pm    Post subject:
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

Site Director


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

PostPosted: Tue Jun 19, 2007 6:25 pm    Post subject:
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

Active Member


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

PostPosted: Tue Jun 19, 2007 6:57 pm    Post subject:
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

Site Director


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

PostPosted: Tue Jun 19, 2007 7:20 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Fri Aug 03, 2007 6:17 pm    Post subject:
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    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Fri Aug 03, 2007 7:12 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Confusion b/w index and subscript Deepak kumar25 Mainframe Interview Questions 7 Thu Aug 31, 2017 6:50 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm
No new posts Order BY AND Index Nileshkul DB2 2 Sat Dec 31, 2016 6:33 pm
No new posts hot to get details when "EXEC CI... Andi1982 CICS 11 Tue Sep 20, 2016 5:01 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us