Re: problem with max and not using index on PK

From: pginfo <pginfo(at)t1(dot)unisoftbg(dot)com>
To: Philip Warner <pjw(at)rhyme(dot)com(dot)au>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: problem with max and not using index on PK
Date: 2003-05-03 12:36:48
Message-ID: 3EB3B7E0.5E6030AE@t1.unisoftbg.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

It is working in this case.
I see that using "order by" make the query slower by 25% if I start it on
another column.

Alse as I wrote in oracle the max use indexes.

regards,
ivan.

Philip Warner wrote:

> At 11:12 AM 3/05/2003 +0200, pginfo wrote:
> >I do not know the reason for not using index in this case.
>
> PostgreSQL does not know that it can use the index, and the query example
> you gave is about the only case in which it can use the index. You can get
> it to use an index by rewriting it as:
>
> select IDS from t_sk10 order by IDS desc limit 1;
>
> ...nowhere near as nice, but it works.
>
> ----------------------------------------------------------------
> Philip Warner | __---_____
> Albatross Consulting Pty. Ltd. |----/ - \
> (A.B.N. 75 008 659 498) | /(@) ______---_
> Tel: (+61) 0500 83 82 81 | _________ \
> Fax: (+61) 03 5330 3172 | ___________ |
> Http://www.rhyme.com.au | / \|
> | --________--
> PGP key available upon request, | /
> and from pgp5.ai.mit.edu:11371 |/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rajesh Kumar Mallah 2003-05-04 10:47:04 Re: timeofday() and now() issue..
Previous Message Philip Warner 2003-05-03 12:04:59 Re: problem with max and not using index on PK