pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Keith Gray <keith@heart.com.au>
To: Ludwig Lim <lud_nowhere_man@yahoo.com>
Cc: PostgreSQL Mailing List <pgsql-sql@postgresql.org>
Subject: Re: Slow performance on MAX(primary_key)
Date: Tue, 15 Oct 2002 17:47:13 +1000
Message-ID: <3DABC801.8060902@heart.com.au> (raw)
References: <20021015071628.57518.qmail@web80304.mail.yahoo.com>

Ludwig Lim wrote:

>>I have just been comparing some large table
>>performance under 7.1 using the
>>
>>	select max(primary key)from table;
>>
> 
>   Try using the following as alternative :
>   
>   SELECT primary_key
>   FROM table
>   ORDER BY primary_key desc
>   LIMIT 1;
> 
>   This should work if primary_key is indexes.
> 
>   As of now, Max() doesn't utilizes the indices hence
> it always do a sequential scan.

Thanks Ludwig,

That does help performance, but I was using a "standard"
SQL command wrapped in a VB6 ADO ODBC program.

Is this likely to be sorted in 7.2 ?
Is anyone looking at this?

-- 

Keith Gray
Technical Services Manager
Heart Consulting Services




view thread (7+ messages)  latest in thread

Message-ID: <3DABC801.8060902@heart.com.au>
Permalink:  ../3DABC801.8060902@heart.com.au/
Also on:    postgresql.org/message-id/3DABC801.8060902@heart.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: keith@heart.com.au, lud_nowhere_man@yahoo.com
  Subject: Re: Slow performance on MAX(primary_key)
  In-Reply-To: <3DABC801.8060902@heart.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox