X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 12E9F476237 for ; Sat, 3 May 2003 09:40:03 -0400 (EDT) Received: from unimm.unisoftbg.com (mail.unisoftbg.com [194.12.229.207]) by postgresql.org (Postfix) with ESMTP id 7B6E3476237 for ; Sat, 3 May 2003 09:38:59 -0400 (EDT) Received: (qmail 20813 invoked by uid 507); 3 May 2003 13:41:27 -0000 Received: from unknown (HELO t1.unisoftbg.com) (pginfo%t1.unisoftbg.com@194.12.229.193) by 0 with SMTP; 3 May 2003 13:41:27 -0000 Message-ID: <3EB3B7E0.5E6030AE@t1.unisoftbg.com> Date: Sat, 03 May 2003 14:36:48 +0200 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: Philip Warner Cc: "pgsql-sql@postgresql.org" Subject: Re: problem with max and not using index on PK References: <5.1.0.14.0.20030503220308.02bcfe68@mail.rhyme.com.au> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-27.2 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,NO_DNS_FOR_FROM, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/46 X-Sequence-Number: 13211 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 |/