Re: [GENERAL] Why so long? - Mailing list pgsql-general

From Jeff Janes
Subject Re: [GENERAL] Why so long?
Date
Msg-id CAMkU=1xdO_wJK0YQCouxdoRZBSrzjZmw76_u158e6H=C1HSS6g@mail.gmail.com
Whole thread Raw
In response to [GENERAL] Why so long?  (Steve Clark <steve.clark@netwolves.com>)
Responses Re: [GENERAL] Why so long?  (Steve Clark <steve.clark@netwolves.com>)
List pgsql-general
On Wed, Apr 19, 2017 at 8:24 AM, Steve Clark <steve.clark@netwolves.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

pgsql-general by date:

Previous
From: Vick Khera
Date:
Subject: Re: [GENERAL] Recover corrupted data
Next
From: Moreno Andreo
Date:
Subject: Re: [GENERAL] Recover corrupted data