|
I forgot to include this message from the app debug data:
Temporary result file built for query.
7 - The query optimizer chose to use a sort rather than an access path to order the results of the query.
That's why I'm thinking an index for the ORDER BY.
From: Justin Taylor
Sent: Friday, June 29, 2018 10:41 AM
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
As an Amazon Associate we earn from qualifying purchases.
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.