Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: QUESTION - Behavior of returning records on a query
BD wrote:
> Hi, all.
>
> I have a query I have been asked to tune. I'll describe my issue, and
> then outline the specifics below.
>
> Basically, several variants of this query are being used. In each
> varation, one variable (field) is being changed - it's likely in a
> drop-down or something. The complaint is that the speed of returning
> the result set does not appear to be consistent as this field is
> changed.
>
> This field can be one of 9 different values. The developer who has
> asked me to look at it indicates that when the application runs, it
> returns values _immediately_ if this value is set to one thing, but
> takes several seconds if it is set to something else.
>
> I ran the query in a SQLPlus window, and noted how long it took, and
> how many rows were returned, for each value.
>
> In _MOST_ cases, the results are the same, in that: I see no results
> for about 15 seconds, and then the result set is returned.
>
> When the field is set to one specific value, I see records returned
> INSTANTLY, although there are many more records returned, and it takes
> about twice as long to return the whole result set as it does in any
> other case.
>
> What I do not understand is:
>
> -Why am I seeing records returned instantly in one case, and in every
> other case, the query is processed for almost 15 seconds before the
> result set is returned?
> -How can I tune this? I know that sounds like a 'dopey' question, but
> my problem is that I cannot understand how the behavior is different,
> and so I am unclear what to address!
>
> I don't expect the group wants to see create statements for all the
> tables and indexes here... so I'll start with the query, the explain
> plan, the values returned, and an outline of the behavior which I can't
> make sense of.
>
> Thanks for reading this far! ;)
>
> QUERY:
>
> Select
> tblCollect.*,
> tblCollectDetail.*,
> tblAccountInfo.fstrListFormatName as fstrPerson,
> tblAccountInfo.fstrID as fstrAccountID,
> tblAccountInfo.fstrAccountType as fstrAccountType,
> tblAccountInfo.fstrOffice as fstrLocalOffice,
> tblAccountInfo.fdtmEnd
>>From tblCollect, tblCollectDetail, tblAccountInfo
it is a matter of selectivity... apparently there are approximately 1.5M records in this db.. retrieving 4 out of 1.5 takes some time especially when it is doing a full table scan on collectdetail. etc..
But to start returning 1.47M records - does not take any time at all to start finding matches...
Can you tell us what indexes exist on these tables? do they include the accountid, collectid, category? have you analyzed the indexes/tables recently? Received on Fri Feb 24 2006 - 21:49:36 CST