I haven't followed this in great detail but, if you want to limit the search
to a particular user first, perhaps you could try a CTE and use that as the
source for the balance of your query.
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of James H. H. Lampert
Sent: Monday, March 04, 2013 2:39 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: More still, Re: Questions about RPG service program as an SQL
UDF
On 3/4/13 12:39 PM, Tom E Stieger wrote:
I'm wondering if this has to do with how your JOIN is defined.
What is you did the following instead:
from SCHEDACTVIEW join ACCOUNTVIEWon
SCHEDACTVIEW.RECORD_ID=ACCOUNTVIEW.RECORD_ID
and SCHEDACTVIEW.ACCOUNT_ID=ACCOUNTVIEW.ACCOUNT_ID
where SCHEDACTVIEW.USER# = ?
It should logically be the same, but due to the UDF I'm not sure if
the optimizer will see it as the same.
Unfortunately, no change: it still runs through the entire file (as
witnessed by the diagnostic version of the censor), and the Visual Explain
looks exactly the same, either way (I'm back on our box).
Ditto if I add "AND SCHEDACTVIEW.RECORD_ID < 999999999" (which would weed
out activities that aren't "account-only," since a RECORD_ID with more than
9 digits can never be an account) (for more, see below)
It's as if the optimizer itself is fighting me.
Is there some way to refactor this so that it checks whether the USER#
matches *before* it bothers looking for anything else?
**********
***I changed this from ACCOUNT_ID b/c I thought it might be a typo***
Actually, there is no RECORD_ID field in ACCOUNTVIEW.
SCHEDACTVIEW.RECORD_ID can be an account ID, a contact ID, or an
account/contact relation ID, which is why we have that 3-branched UNION ALL
in there. SCHEDACTVIEW.ACCOUNT_ID is a separate direct link to the account
(or zero, for activities with a contact but no account)
Which is to say that the SCHEDACTVIEW.ACCOUNT_ID=ACCOUNTVIEW.ACCOUNT_ID
comparison is redundant here. But getting rid of it accomplishes nothing.
--
This is the RPG programming on the IBM i (AS/400 and 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.