MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SEARCH & SEARCH ALL statement in COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Saty
Beginner


Joined: 22 Jul 2004
Posts: 1
Topics: 1

PostPosted: Thu Jul 22, 2004 2:52 am    Post subject: SEARCH & SEARCH ALL statement in COBOL Reply with quote

SEARCH ALL performs binary search whereas SEARCH performs a linear search in tables. SEARCH ALL is therefore more efficient than SEARCH esp for long tables.

However, the linear search performed by SEARCH can also be accomplished by browsing through an array by varying the subscript. Is the use of SEARCH more efficient than browsing through an array? Is so, why ecaxtly is it more efficient?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Jul 22, 2004 4:19 am    Post subject: Reply with quote

saty,

Performance wise there is no difference between COBOL linear search and PERFORM UNTIL. When excueted both of them perform alike.

On the other hand there is a difference between a linear search(SEARCH) and binary search (SEARCH ALL).

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dhruv
Beginner


Joined: 01 Jun 2004
Posts: 10
Topics: 1

PostPosted: Thu Jul 22, 2004 4:30 am    Post subject: Reply with quote

The following need to considered when deciding between a linear SEARCH vs PERFORM

SEARCH uses index Specified in the INDEXED BY CLAUSE.

Also, linear SEARCH on a table using a OCCURS DEPENDING ON clause, can come out of the search faster.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Jul 22, 2004 4:32 am    Post subject: Reply with quote

Quote:

Also, linear SEARCH on a table using a OCCURS DEPENDING ON clause, can come out of the search faster.


Dhruv,

Can you elaborate more on the above statement?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dhruv
Beginner


Joined: 01 Jun 2004
Posts: 10
Topics: 1

PostPosted: Thu Jul 22, 2004 4:37 am    Post subject: Reply with quote

Lets say you a table with 100 elements.

But only the first 30 elements have been populated. IF the ODOvariable is 30, then the SEARCH will come out after scanning through the first 30 elements, rather than searcing all 100 elements.

Hope its clear

Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Jul 22, 2004 4:40 am    Post subject: Reply with quote

Quote:

But only the first 30 elements have been populated. IF the ODOvariable is 30, then the SEARCH will come out after scanning through the first 30 elements, rather than searcing all 100 elements.


Dhruv,

Doesn't this hold good for PERFORM VARYING also?

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dhruv
Beginner


Joined: 01 Jun 2004
Posts: 10
Topics: 1

PostPosted: Thu Jul 22, 2004 4:48 am    Post subject: Reply with quote

If you use a limiting factor (equivalent of the ODO) in the PERFORM VARYING statement, in conjunction with an indexed variable(not a working storage variable), then i suppose the PERFORM VARYING might come close to the SEARCH performance wise, although, even for big tables, there is very little difference to chose from the 2.


Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group