What happens if you code it like so.

Select fields from files where :inputclientNbr in (0, clientNumber) and :inputAmt in (0, amount)

When inputClientNbr host variable is 0, then all clients would end up getting selected, otherwise only the inputclientnumber is selected.

When inputAmt is 0, then all transaction amounts will be selected, otherwise only that transaction amount would be.



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of David FOXWELL
Sent: Monday, March 07, 2011 9:56 AM
To: RPG programming on the IBM i / System i
Subject: Embedded sql without index faster than with index


Hi all,

I am having a strange performance issue while loading a subfile from an sql cursor.
It seems that when the sql select gets run and no index can be used, it is MUCH faster than when an index can be used.

I have 2 transaction files , currentTransactions and historyTransactions. Both these files have logicals with the client number as the first key field.

I am using sql to search these files with any range of client numbers and a transaction amount. I am doing something like :
select fields from files where clientNumber between c1 and c2 and amount between a1 and a2

No index has yet been created for the transaction amount. I am now testing to see what the performance is like.

If I enter an amount 20.25 and no client number, my statement will be something like :
select fields from files where clientNumber between 0 and 999999 and amount between 20.25 and 20.25

If I enter client number 12345 and no amount, my statement will be something like :
select fields from files where clientNumber between 12345 and 12345 and amount between 0 and 9999999999.99

The first statement is running twice as fast than the second, which I don't understand. They are both taking several seconds to run.

I've tried debugging and copying and pasting the result into an iNav sql script window and it runs in a split second.

I thought maybe it was other logic between reading the cursor and writing to the subfile, but if I enter no client and no amount, the subfile displays immediately.

any ideas would be most welcome.
--
This is the RPG programming on the IBM i / System i (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.

________________________________

Notice from Bob Evans Farms, Inc: This e-mail message, including any attachments, may contain confidential information that is intended only for the person or entity to which it is addressed. Any unauthorized review, use, disclosure or distribution is strictly prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message and any attachments.

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.