Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Order By Bogs down the Statement
As a note to a reply I posted on why a query would slow down when an order
by clause was added to it the following was posted. Note - reply referred
to use of init.ora parameters for sort area and temp tablespace existence
and parameters.
oliver.willandsen_at_sg.cec.be wrote in article
19981105202414.19650.00000018_at_ng134.aol.com>,
l
> >
>>Rich and Mark,
Oliver, I could be wrong, but I do not believe that the two rules you posted are true in that adding an order by clause to a query will not necessarily prevent Oracle from using an index to solve the query. I have seen numerous explain plans where Oracle uses an index to retrieve rows and then performs a sort on columns that are not declared with a not null constraint. The columns in the index being used and the columns in the order by clause do not even have to match so how could using a nullible column in an order by clause cause Oracle to stop using the index.
The rules you posted seem to be necessary for the optimizer to eliminate the sort step by substituting an index ordered retrieval plan. That is if the index column order matches the order by clause the optimizer could retrieve the rows in index order and not sort them. Now the optimizer could be choosing to do this, but I doubt that this is the original poster's problem. I could misunderstand your reply, but I do not think that these two rules apply here. Received on Fri Nov 06 1998 - 12:20:33 CST