View previous topic :: View next topic
|
Author |
Message |
atulbagewadikar
New User
Joined: 15 Jun 2006 Posts: 26
|
|
|
|
Hi,
Which is more efficient way from below two & how:
1. READ view BY descriptor/superdescriptor WHERE condition
2. READ view BY descriptor/superdescriptor
ACCEPT IF (the same condition given on WHERE clause above)
Regards,
Atul |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
In most cases,the first option.
O. |
|
Back to top |
|
|
atulbagewadikar
New User
Joined: 15 Jun 2006 Posts: 26
|
|
|
|
Ofer,
Could you please explain how it works in background? |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Sorry, I can't tell that, since I don't know that. I only know that Software AG's fine manuals state, more then once, that the usage of ACCEPT should be limited as it is known to perform a little heavy.
I can guess, however, that the WHERE criteria are filtered by ADABAS, whereas the ACCEPT/REJECT statements are pure NATURAL.
O. |
|
Back to top |
|
|
Ralph Zbrog
New User
Joined: 21 Nov 2009 Posts: 58 Location: California
|
|
|
|
Ofer71's first statement is correct - WHERE is a tad faster than ACCEPT, but WHERE is applied by Natural, not Adabas.
The rule of thumb is, the fewer the number of statements, the more efficient the program. This is based on the presumption that each statement is interpreted at run time. (In fact, some statements are generated as machine code, even more if you have Natural Optimizer Compiler.)
Since WHERE is a clause and ACCEPT is a statement, WHERE will be a tad faster. |
|
Back to top |
|
|
Steve Robinson
New User
Joined: 14 Nov 2009 Posts: 12 Location: U.S.
|
|
|
|
As far as performance goes, there is an additional difference between ACCEPT and WHERE.
A record that "flunks" a WHERE clause does not increment *COUNTER.
A record that "flunks" an ACCEPT has already incremented *COUNTER.
Forgetting performance for a minute; as Ralph noted, WHERE is part of the READ. By contrast, ACCEPT is a standalone statement.
This means ACCEPTs can be scattered throughout a READ loop.
I find the functionally equivalent IF some-condition ESCAPE TOP easier to read, and hence, understood by maintenance programmers. But that is purely subjective.
steve |
|
Back to top |
|
|
nan_ishan
New User
Joined: 15 Apr 2009 Posts: 3 Location: Pune
|
|
|
|
atulbagewadikar wrote: |
1. READ view BY descriptor/superdescriptor WHERE condition
2. READ view BY descriptor/superdescriptor
ACCEPT IF (the same condition given on WHERE clause above)
|
Defintely the first one is more efficient.
Reason:
In first case by giving where clause the number of records fetched from Adabas is limited.
In second case the entire adabas file will be read and the unmatching records will be skipped.
Thus, considering performance wise, first case is efficient.
* Please correct if I am wrong |
|
Back to top |
|
|
Ralph Zbrog
New User
Joined: 21 Nov 2009 Posts: 58 Location: California
|
|
|
|
The number of records retrieved by Adabas is identical!
Both WHERE and ACCEPT conditions are applied by Natural, so the records must be returned to Natural for the conditions to be applied.
See my posting above for an explanation of why WHERE is a bit faster than ACCEPT. |
|
Back to top |
|
|
|