Re: Why so long?

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Steve Clark <steve(dot)clark(at)netwolves(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why so long?
Date: 2017-04-19 15:57:54
Message-ID: CAMkU=1xdO_wJK0YQCouxdoRZBSrzjZmw76_u158e6H=C1HSS6g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Apr 19, 2017 at 8:24 AM, Steve Clark <steve(dot)clark(at)netwolves(dot)com>
wrote:

> Hello,
>
> I am confused. I have a table that has an incrementing primary key id.
>
> When I select max(id) from table is returns almost instantly but
> when I select min(id) from table it takes longer than I want to wait.
>
> Shouldn't postgresql be able to quickly find the minimum id value in the
> index?
>

Not if the low end of the index is stuffed full of obsolete entries, which
haven't been cleaned up because it is not being vacuumed often enough.

Do you have autovacuum on? Have you manually vacuumed the table recently?

Cheers,

Jeff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Moreno Andreo 2017-04-19 16:11:28 Re: Recover corrupted data
Previous Message Vick Khera 2017-04-19 15:49:28 Re: Recover corrupted data