X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D778C475AA9 for ; Sat, 3 May 2003 08:06:10 -0400 (EDT) Received: from acheron.rime.com.au (acheron.rhyme.com.au [203.208.66.49]) by postgresql.org (Postfix) with ESMTP id EAD66475AA9 for ; Sat, 3 May 2003 08:05:09 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by acheron.rime.com.au (Postfix on SuSE Linux 8.0 (i386)) with ESMTP id 43335356550; Sat, 3 May 2003 22:05:01 +1000 (EST) Received: by acheron.rime.com.au (Postfix on SuSE Linux 8.0 (i386), from userid 527) id 40E7B3570C1; Sat, 3 May 2003 22:05:00 +1000 (EST) Received: from hephaestus.rhyme.com.au (unknown [203.8.195.124]) by acheron.rime.com.au (Postfix on SuSE Linux 8.0 (i386)) with ESMTP id 7BF50356550; Sat, 3 May 2003 22:04:59 +1000 (EST) Message-Id: <5.1.0.14.0.20030503220308.02bcfe68@mail.rhyme.com.au> X-Sender: pjw@mail.rhyme.com.au X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Sat, 03 May 2003 22:04:59 +1000 To: pginfo , "pgsql-sql@postgresql.org" From: Philip Warner Subject: Re: problem with max and not using index on PK In-Reply-To: <3EB387F6.F3230162@t1.unisoftbg.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Virus-Scanned: by AMaViS 0.3.12pre8 X-Spam-Status: No, hits=-14.2 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,NO_DNS_FOR_FROM 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/45 X-Sequence-Number: 13210 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 |/