A wide-spreaded myth
Andrew Max, October 20, 2005 - 2:19 pm UTC
It's astonishing, but I've already seen similar "do-order-by-yourself" approach.
For example, here:
</code>
http://asktom.oracle.com/pls/asktom/f?p=100:11:::::P11_QUESTION_ID:9843506698920#9896083461138 <code>
Now I see it's a wide-spreaded myth of some kind: "we can put hint in our query and get rid of that annoying ORDER BY".
However, I agree with Tom 100%. This is really terrible. NEVER do that.
With hint, there are lot of things which may destroy your "ordering":
- Someone dropped your index
- Someone marked index as UNUSABLE and your session is run under SKIP_UNUSABLE_INDEXES set to TRUE.
- Your index is partitioned.
- Some day you decided to use PQ.
...
and so on...
Best regards --
Andrew.
October 20, 2005 - 4:56 pm UTC
The optimizer skips your index for whatever reason
your index is sorted binary, not character wise (meaning the index isn't sorted!!! not according to what you end users expect)
there is ONLY ONE WAY TO GET ORDERED DATA
and that is to use order by.
Cannot wait for 10gr2 and people using group by to "sort", they will be big time "surprised" by group by hash
David Aldridge, October 20, 2005 - 10:38 pm UTC
>> Cannot wait for 10gr2 and people using group by to "sort", they will be big time "surprised" by group by hash <<
... and add to the "I wish Oracle had ..." list a new init parameter "sort_on_group_by" :D
October 21, 2005 - 8:06 am UTC
never.
Pk enforcement and local partitioned indexes
Rudi, October 26, 2005 - 8:43 am UTC
Hi Tom
Bellow is a quote from the Oracle Performance Tuning Guide:
"The INDEX_ASC hint explicitly chooses an index scan for the specified table. If the statement uses an index range scan, then Oracle scans the index entries in ascending
order of their indexed values".
So actually I do have a reason to expect the result set to be sorted.
The only pitfall is locally partitioned indexes,but its not written in the manual.
I have however a followup question :how does Oracle maintain uniqueness for Primary keys which are based on local partitioned indexes?
October 26, 2005 - 12:27 pm UTC
but you have multiple indexes to scan in ascending order and they do not say "data will be returned sorted" do they?
unless
until
only if
you have an order can you have any expectation about the order of rows. period.
NO GETTING AROUND IT. PERIOD.
That and indexes store the data sorted in BINARY - not according to sort order necessarily.
last question: that only works if the primary key is in fact part of the partition key, else you will not have a locally partitioned index on the primary key.