× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Your embedded SQL is it static or dynamic?
If it is static try to add OPTIMIZE for x ROWS (x must be a small integer
value, i.e. 3 or 10) at the end of the DECLARE Statement.

In this way you will change the optimization goal.
For dynamic SQL statement (also performed from STRSQL or Run SQL Script) the
default is *FIRSTIO, i.e. the query is optimized so that the first block of
data is returned as fast as possible. The optimizer may decide for an index
access instead of a table scan.
For static SQL Statements the default is *ALLIO, i.e. the query is optimized
so that all data is returned as fast as possible. The optimizer may decide
for a table scan instead of an index access.

If the x in the OPTIMIZE FOR x ROWS clause is set to a small integer value,
Optimization goal *FIRSTIO is used.
If the x is set to a big integer value or all, the optimization goal *ALLIO
is used.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
?Train people well enough so they can leave, treat them well enough so they
don't want to.? (Richard Branson)


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxx> On Behalf Of Justin
Taylor
Sent: Freitag, 29. Juni 2018 17:41
To: MIDRANGE-L (midrange-l@xxxxxxxxxxxx) <midrange-l@xxxxxxxxxxxx>
Subject: CURSOR-Table Scan vs Index Scan

SQL Performance Center shows that this query (from embedded SQL) performs a
Table Scan (runtime 420ms):
declare POCSR cursor for select PO# , INV , STK , DESCR1 , DESCR2 , DESCR3
from PO where STK like : H or DESCR1 like : H or DESCR2 like : H or DESCR2
like : H order
by INV , PO# desc for read only

I ran the same query in Run SQL Scripts, substituting the same literal for
:H. That uses an Index Scan (runtime 95ms).

Run SQL Scripts is using a LF keyed on INV. Debug data for the app shows
that LF wasn't selected for this reason:
17 - The left-most key of the access path did not match any fields specified
for the selection criteria. Therefore, key row positioning could not be
performed, making the cost to use this access path higher than the cost
associated with the chosen access method.

I have a standard index over (INV, PO#, x). I'm thinking about creating a
new index over only (INV, PO#). Would a standard or EVI index work better?

TIA
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.