Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Advantage of INDEX over OCCURS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Mon Oct 06, 2008 5:53 pm    Post subject: Advantage of INDEX over OCCURS
Reply with quote

Hi,

I am using a Array which is used to load the data sequentially,process it and write into on Output File.

Array is declared like this.

10 WS-TEMP-ARRAY OCCURS 10 TIMES INDEXED BY W-INDX.
15 WS-TEMP-YR PIC X(02).
15 WS-TEMP-NO PIC X(20).

For my Case as i m not searching the array ,just loading the Array and processing it sequentially. Will Index is advantageous over Suscript ? If so what are the reasons for that?
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Oct 06, 2008 6:24 pm    Post subject:
Reply with quote

using a subscript requires the occurance number be converted to an offset.

SETting the INDEX up by 1 increases the offset, not the occurance, therefore no conversion is necessary.

and it does not matter that you are not searching the table, you are addressing each occurance.

It is all in the programmer guide, top of page.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8053
Location: East Dubuque, Illinois, USA

PostPosted: Mon Oct 06, 2008 6:26 pm    Post subject:
Reply with quote

I've always heard that IBM's claim is INDEX is faster than subscripts. However, for a 10-element table that is not searched, I doubt it really matters whether INDEX or subscript is used.
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Mon Oct 06, 2008 6:41 pm    Post subject:
Reply with quote

Robert Sample wrote:
However, for a 10-element table that is not searched, I doubt it really matters whether INDEX or subscript is used.


For this Scenario will INDEX is preffered or not.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8053
Location: East Dubuque, Illinois, USA

PostPosted: Mon Oct 06, 2008 6:54 pm    Post subject:
Reply with quote

The Programmer's Guide doesn't specify a lower limit for efficiency, but I doubt you'd be able to easily measure the CPU time difference with only 10 table entries:
Quote:
8.1.3 Handling tables efficiently


Pay close attention to table-handling operations, particularly when they are a major part of an application. Several techniques can improve the efficiency of these operations and can also influence the optimizer. The return for your efforts can be significant.

The following two guidelines affect your choice of how to refer to table elements:

* Use indexing rather than subscripting.

Although the compiler can eliminate duplicate indexes and subscripts, the original reference to a table element is more efficient with indexes than with subscripts, even if the subscripts are BINARY. The value of an index has the element size factored into it, whereas the value of a subscript must be multiplied by the element size when the subscript is used. The index already contains the displacement from the start of the table, and this value does not have to be calculated at run time. However, subscripting might be easier to understand and maintain.

* Use relative indexing.

Relative index references (that is, references in which an unsigned numeric literal is added to or subtracted from the index name) are executed as fast as direct index references and sometimes faster. There is no merit in keeping alternative indexes with the offset factored in.
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Mon Oct 06, 2008 7:02 pm    Post subject: Reply to: Advantage of INDEX over OCCURS
Reply with quote

Thanks Robert.But will the Usage of Index for this Scenario is disadvantagable when compared to subscript or for this scenario there will not be much diff if we use any of these(Index/Subscript)
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8053
Location: East Dubuque, Illinois, USA

PostPosted: Mon Oct 06, 2008 7:10 pm    Post subject:
Reply with quote

IBM's manual statement I quoted earlier is clear. INDEX is always more efficient than subscripts, period. What I am saying is that for the table you have defined, the "more efficient" isn't going to be worth worrying about; probably a few nanoseconds or microseconds. Leave it indexed and move on to more important issues.
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 216
Location: India

PostPosted: Mon Oct 06, 2008 7:19 pm    Post subject:
Reply with quote

Robert Sample wrote:
IBM's manual statement I quoted earlier is clear. INDEX is always more efficient than subscripts, period. What I am saying is that for the table you have defined, the "more efficient" isn't going to be worth worrying about; probably a few nanoseconds or microseconds. Leave it indexed and move on to more important issues.



Thanks Robert icon_biggrin.gif
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
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 Several errors during building altern... Andi1982 JCL & VSAM 11 Wed Jul 06, 2016 7:39 pm
No new posts Drop building Alternate Index for a p... bhavin.mehta JCL & VSAM 6 Mon Jul 04, 2016 3:47 pm
No new posts VSAM Alternate Index in CICS jacobdng CICS 2 Fri May 06, 2016 1:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us