Re: CREATE INDEX .. ON table1 (field1 asc, field2 desc)

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Timur <itvthor(at)sdf(dot)lonestar(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: CREATE INDEX .. ON table1 (field1 asc, field2 desc)
Date: 2002-09-02 02:50:30
Message-ID: 200209020250.g822oU121626@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Is this a TODO item?

---------------------------------------------------------------------------

Bruno Wolff III wrote:
> On Sun, Aug 25, 2002 at 10:00:56 +1000,
> Martijn van Oosterhout <kleptog(at)svana(dot)org> wrote:
> > On Sat, Aug 24, 2002 at 08:18:25PM +0500, Timur wrote:
> > > Hello!
> > >
> > > I am new to PostgreSQL and databases in general, and I have this
> > > question: why it is not possible to specify ordering when creating an
> > > index?
> > >
> > > Let's say I have a query which looks like this:
> > > SELECT * FROM table1
> > > ORDER BY field1, field2 DESC
> > > LIMIT 100;
> > >
> > > Apparently, system won't use index ON (field1, field2) ..
> >
> > It will if you do:
> > SELECT * FROM table1
> > ORDER BY field1 DESC, field2 DESC
> > LIMIT 100;
> >
> > Time to go read that SQL book again?
>
> That may or may not be his problem. If the order he wants is
> order by field1 ASC, fiels2 DESC there isn't a simple way to create
> a matching index.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-general by date

  From Date Subject
Next Message wlj 2002-09-02 03:01:21
Previous Message Joe Conway 2002-09-02 01:58:19 Re: bytea operator bugs (was Re: [GENERAL] BYTEA, indexes