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

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Timur <itvthor(at)sdf(dot)lonestar(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: CREATE INDEX .. ON table1 (field1 asc, field2 desc)
Date: 2002-08-25 00:00:56
Message-ID: 20020825100056.C15448@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mark Stosberg 2002-08-25 00:09:47 Re: audit trail
Previous Message Martijn van Oosterhout 2002-08-24 23:59:25 Re: Why is pgbench suddenly slow?