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

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: 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-08-25 15:07:39
Message-ID: 20020825150739.GA28640@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Engelhart 2002-08-25 20:15:26 mac OS X 10.2 (Jaguar) Build problems
Previous Message Tom Lane 2002-08-25 15:02:01 Re: CREATE INDEX .. ON table1 (field1 asc, field2 desc)