473,473 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

descending Indexes

I can't find a way to create descending Indexes in PG. Is this possible?

If so, can you point me in the right direction?
If not, can I request this to be an enhancement?

Thanks
Nov 11 '05 #1
5 2396

On Thu, 4 Sep 2003, Bupp Phillips wrote:
I can't find a way to create descending Indexes in PG. Is this possible?

If so, can you point me in the right direction?
If not, can I request this to be an enhancement?


You can do it, but it's a bit difficult. You need to make an operator
class for the type in question that orders in the reverse order and use
that operator class in making the index. I don't remember if I sent an
example the last time this came up, but you might want to check the
archives.
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #2
Stephan Szabo <ss****@megazone.bigpanda.com> writes:
On Thu, 4 Sep 2003, Bupp Phillips wrote:
I can't find a way to create descending Indexes in PG. Is this possible?
You can do it, but it's a bit difficult.


Do you really *need* a descending index? In most cases a backwards scan
on a regular index gets the job done.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 11 '05 #3
Yes, I really *need* a descending index.

How do you do a backward scan on an index?

"Tom Lane" <tg*@sss.pgh.pa.us> wrote in message
news:17**************@sss.pgh.pa.us...
Stephan Szabo <ss****@megazone.bigpanda.com> writes:
On Thu, 4 Sep 2003, Bupp Phillips wrote:
I can't find a way to create descending Indexes in PG. Is this
possible?
You can do it, but it's a bit difficult.


Do you really *need* a descending index? In most cases a backwards scan
on a regular index gets the job done.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 11 '05 #4
A long time ago, in a galaxy far, far away, "Relaxin" <no****@spam.com> wrote:
Yes, I really *need* a descending index.

How do you do a backward scan on an index?


Normally, your query would look like:

"... order by field14 descending;"

That will scan backwards based on the index, assuming that the
optimizer decided to use an index on field14.
--
let name="cbbrowne" and tld="cbbrowne.com" in String.concat "@" [name;tld];;
http://www.ntlug.org/~cbbrowne/oses.html
"What this list needs is a good five-dollar plasma weapon."
--paraphrased from `/usr/bin/fortune`
Nov 11 '05 #5
On Thu, Sep 04, 2003 at 18:24:01 -0700,
Relaxin <no****@spam.com> wrote:
Yes, I really *need* a descending index.


Can you go into more detail about this?

Generally you only need a descending index if it has more than one part
and one part needs to be ascending and the other needs to be descending.
If this case then general solution is to create a new operator class.
In 7.4, you will be able to get around this is some cases by using a
functional index on - whatever and using - whatever in the query. (This
will only work on datatypes that have a unary - defined, so is pretty much
limited to numeric types.)

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 11 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Tuhin Kumar | last post by:
Hi, Oracle give the error ORA-01418 when I try to do the following; Create unique index t1_pk on TABLE1(EntryId DESC) ; If the I try to add primary key Contraint using the above index t1_pk...
0
by: Talis | last post by:
I have a reasonably large table (over 2 million rows) and my select results need to be sorted in descending order. I've noticed, however, that my queries ORDER'ed by DESC are at least twice as...
2
by: Trevor Best | last post by:
I have a unique index based on the following columns: ProjectID (int) MaterialCatalogID (int) Material catalogues are pretty much static but projects are dynamic and people are most likely to...
7
by: Luigi Napolitano | last post by:
Hello, I use this algorithm to sort an array "v" in the descending order. void quickSort(float v, int lo0, int hi0) { int lo = lo0; int hi = hi0; if (lo >= hi) return; float mid = v;
3
by: Leszek | last post by:
Hello, I guess it should be easy. I need to iterate through the XML node list using foreach in descending order: string XML_DOCUMENT = Server.MapPath("members.xml"); XmlDocument myXmlDoc =...
2
by: phillip.s.powell | last post by:
SELECT s.id, s.first_name, s.last_name, IF(s.school_year_id = 0, s.school_year_other, y.school_year_alt_display) AS school_year_name FROM student s LEFT OUTER JOIN school_year y ON...
2
by: Richard Hollenbeck | last post by:
I have the following query in a combo box: SELECT courses.courseCode, courses.courseDescription FROM courses ORDER BY courseDescription; I want to change the "ORDER BY" to display in...
11
by: dwelden | last post by:
I have successfully used the sort lambda construct described in http://mail.python.org/pipermail/python-list/2006-April/377443.html. However, how do I take it one step further such that some values...
5
by: subramanian100in | last post by:
In the ISO document www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf in the detail of the qsort library function in 7.20.5.2, the description says that, the contents of the array are sorted...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.