According to "SQL at Work", page 28:

"..., if a logical file contains select/omit criteria, it cannot be used
as an access path to a physical file in resolution of an SQL query."

So if your logical has select/omit, then the SQL engine ignores it as a
viable access path.  Try creating either an index or another logical
with the same key structure but no select/omits.  Then change your SQL
program to point to the physical file.  

Remember that one of the beauties of SQL is that the programmer can
ignore the implementation details and let the SQL engine determing the
best access path.  That being said, appropriate access paths must exist
in order to be used...

HTH,

Joel
http://www.rpgnext.com


On Thu, 2003-11-13 at 21:27, Steve Cross wrote:
> Joel,
> 
> Yes the logical file has select criteria.  The SQL "Order By" statement
> matches the key to the logical, but the low level message says the optimizer
> chose to build its own path (takes 3 minutes), rather than using the logical
> (It thought it would be faster).  Running STRSQL using the same SQL
> statement finds the correct logical and immediately displays the data.
> 
> Is there a way to tell the SQL engine not to find its own path, but instead
> use the logical we defined in the SQL statement?
> 
> Thanks,
> Steve
> 
> 
> 
> -----Original Message-----
> From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
> On Behalf Of Joel Cochran
> Sent: Thursday, November 13, 2003 9:33 AM
> To: RPG programming on the AS400 / iSeries
> Subject: Re: Embedded SQL performance question.
> 
> Does the Logical have any select and omit criteria?
> 
> Joel
> http://www.rpgnext.com
> 
> 
> On Thu, 2003-11-13 at 19:34, Steve Cross wrote:
> > Hi,
> >  
> > I have an embedded SQL statement in my RPG program
> > 
> > It's a typical select statement over a logical file. 
> > 
> > the where selections and the order by are against the 1st two primary 
> > key fields.
> > 
> > when I execute this statement using Interactive SQL it runs fine. 
> > quick response and debug says it chose the logical access path
> > 
> > when I run it in the RPG program the optimizer builds its own access 
> > path and takes 3 minutes to execute.
> > 
> > the statements are identical.
> > 
> > what am I doing wrong.  I am running OS V5R2
> > 
> > Thanks in advance,
> > Steve
> _______________________________________________
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
> To post a message email: RPG400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: RPG400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.