Re: force use of an index - how to?

From: Dmajor7 <dmajor7_at_aol.com>
Date: 1995/04/29
Message-ID: <3nuo63$cjg_at_newsbf02.news.aol.com>#1/1


In message <3n4fkr$l6v_at_news.hk.net> tlrapro_at_hk.net (Telerate (Asia-Pacific) Ltd.) writes:

|If I can't choose my column to be stored via an index in descending
 order,
|would i get the same effect if I have the following:
|
|(Assume Table A has a column x that has values generated by a sequence
|number in descending order. Withouth an index, the rows of column x
 probably
|is in descending order. Now add an index to column x for Table A.
|Since the index are sorted in ascending order only, would it be logical
|to assume that on a SELECT x from A, it would return the rows in
|descending order?
|
|Thanks for your help.
|
|Regards,
|Bill

The key word here being "probably". If rows have ever been deleted then the deleted space may have been reused and the physical order is no longer there. The way I solved this was to store, instead of the actual value, 99999999 - value. You could also just make it negative. Of course if you're talking about an alpha field then the problem becomes a bit more tricky: you have to store it as all bits reversed. Of course if you have users creating their own SQL queries, then you need to store the field as it's original value as well.




Ken Denny, Insight Industries Inc (I cubed) All opinions expressed ... (the ususal)

Received on Sat Apr 29 1995 - 00:00:00 CEST

Original text of this message