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 

simple select or opening a cursor - the best performance

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


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Tue Jun 05, 2007 7:37 pm    Post subject: simple select or opening a cursor - the best performance Reply with quote

I am really aware of the reasons to use a cursor instead of a simple select...

But, in terms of performance, is there a difference between opening a cursor to retrieve one row (fetch 1 row only) or executing a simple select?

I ask that because I have an assistant (a program) that generates Cobol programs that retrieve data from db2 tables.

U provide a SQL query and the assistant generates a complete Cobol program that executes the query, and formats the output data area.

We use it to create Cobol subroutines that can be invoked by many callers.

It saves the effort of coding very similar programs that are meant only to recover data from a database.

The problem is that this assistant only generates programs with cursors, even when u only need to retrieve 1 row.

My doubt now is: is a simple select more efficient than a cursor that retrieves only 1 row (fetch 1 row only)?

Is my assistant generating not optimized Cobol code?

Thanks,

JC
Back to top
View user's profile Send private message Send e-mail
CICS Guy
Intermediate


Joined: 30 Apr 2007
Posts: 292
Topics: 3

PostPosted: Tue Jun 05, 2007 7:54 pm    Post subject: Re: simple select or opening a cursor - the best performance Reply with quote

jctgf wrote:
Is my assistant generating not optimized Cobol code?
It might, but is it worth the loss of productivity in generating the routines vs a slight (if any) improvment in some executions of those routines?
If you can identify some high use single row selects and can prove that there is any savings from singleton fetches, change them....Otherwise, "Don't worry, be happy"....
Back to top
View user's profile Send private message
jajularamesh
Beginner


Joined: 14 Apr 2006
Posts: 87
Topics: 33

PostPosted: Wed Jun 06, 2007 1:31 am    Post subject: Reply with quote

Singleton select is far more efficient than using the cursor for the same requirement.

Regards,
Ramesh(Venkata Apparao Jajula)
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Wed Jun 06, 2007 2:56 am    Post subject: Reply with quote

Code generators use cursors so that there is no possiblility of -811's.

Sure, a singleton select is 'faster' than open/fetch/close; but is receiving a -811 efficient?

The selling point behind code generators is that people without programming experience can create code to solve business needs, without problems - that is efficient................
_________________
Dick Brenholtz
American living in Varel, Germany
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 -> Database 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