View previous topic :: View next topic |
Author |
Message |
jctgf Beginner
Joined: 05 Nov 2006 Posts: 89 Topics: 36
|
Posted: Tue Jun 05, 2007 7:37 pm Post subject: simple select or opening a cursor - the best performance |
|
|
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 |
|
 |
CICS Guy Intermediate
Joined: 30 Apr 2007 Posts: 292 Topics: 3
|
Posted: Tue Jun 05, 2007 7:54 pm Post subject: Re: simple select or opening a cursor - the best performance |
|
|
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 |
|
 |
jajularamesh Beginner
Joined: 14 Apr 2006 Posts: 87 Topics: 33
|
Posted: Wed Jun 06, 2007 1:31 am Post subject: |
|
|
Singleton select is far more efficient than using the cursor for the same requirement.
Regards,
Ramesh(Venkata Apparao Jajula) |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Wed Jun 06, 2007 2:56 am Post subject: |
|
|
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 |
|
 |
|
|