× 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.



James

I would try a couple things. Both are related to you USER# question.

You can put that condition into the JOIN instead of the WHERE. Results may vary - I forget exactly, but sometimes this results in a surprise or two.

Otherwise, you can do a correlated table expression - or a nested table expression. The former uses the WITH ... AS kind of thing, which is a way to define a SELECT that has the selectivity on USER#. Then it has an alias you can use instead of the original table name.

The latter is just putting a SELECT statement, with its own WHERE clause, in the place where you know have "from SCHEDACTVIEW join" - put the SELECT where SCHEDACTVIEW is.

Is there an index on USER#? If not, it will either probably create on on the fly or do a table scan. To be most effective, USER# maybe should be first column in the index - but this doesn't help the JOIN criteria much.

Are there indexes on a combination of RECORD_ID and ACCOUNT_ID over each table? That'd help the JOIN. But probably not the selection on USER#

There's a manual in InfoCenter on optimization that gives lots of suggestions to make this stuff work.

Are there any advised indexes in Visual Explain? Could be worth a try.

HTH
Vern

On 3/4/2013 4:39 PM, James H. H. Lampert wrote:
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.


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.