Re: Select max(primary_key) taking a long time

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Francisco Reyes <lists(at)stringsutils(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Select max(primary_key) taking a long time
Date: 2010-05-22 15:25:29
Message-ID: AANLkTikXvscy5qkI3Nlt0rGiw2JcIYevb4LPiCcBf-5N@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, May 21, 2010 at 1:48 PM, Francisco Reyes <lists(at)stringsutils(dot)com> wrote:
> Tom Lane writes:
>
>> Francisco Reyes <lists(at)stringsutils(dot)com> writes:
>>>
>>> I am trying to do
>>> select max(primary_key) from some_table;
>>
>> Are there a whole lot of nulls in that column?
>
>
> Zero nulls. It is a primary key.

do a big delete recently? any other open transactions? since you are
i/o waiting, I'm guessing either hint bits or you have another
transaction in play which established tons of rows that your query has
to wade through...

the remedy for the former is to simply eat it (one time penalty) or
rebuild the table. for the latter you simply have to resolve the
other transaction.

how big is your table according to pg_relation_size()?

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message erobles 2010-05-22 16:03:33 Re: NOTICE: ignoring incomplete trigger group for constraint
Previous Message Merlin Moncure 2010-05-22 15:08:13 Re: Help reqd on azimuth finction