Re: [GENERAL] Simple Query not using Primary Key Index - Mailing list pgsql-general

From Aron Podrigal
Subject Re: [GENERAL] Simple Query not using Primary Key Index
Date
Msg-id CANJp-ygggWVt3JJEzJaP-qund9zBH2EZG_-Y=G3Nj4unuY1o-Q@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] Simple Query not using Primary Key Index  (Aron Podrigal <aronp@guaranteedplus.com>)
Responses Re: [GENERAL] Simple Query not using Primary Key Index  (Vitaly Burovoy <vitaly.burovoy@gmail.com>)
List pgsql-general

In general, I do not understand why a PK index should not be used when the query can be satisfied by the index itself. Can anyone give some reason to this?

On Mon, Feb 6, 2017, 6:29 PM Aron Podrigal <aronp@guaranteedplus.com> wrote:

EXPLAIN ANALYZE does not tell me much. It doesn't say why the planner opts for not using the Primary key index.

On Mon, Feb 6, 2017, 6:23 PM Alban Hertroys <haramrae@gmail.com> wrote:

> On 7 Feb 2017, at 0:16, Podrigal, Aron <aronp@guaranteedplus.com> wrote:
>
> Hi,
>
> I noticed when I do a simple SELECT id FROM mytable WHERE id = 'cb81d070-4213-465f-b32e-b8db43b83a25'::UUID  Postgres does not use the primary key index and opts for a Seq Scan.
>
> I of course did VACUUM ANALYZE and I have reset statistics But no sign. Is there any particular thing I should be looking at?

An EXPLAIN ANALYZE would be a good start.

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.

pgsql-general by date:

Previous
From: Aron Podrigal
Date:
Subject: Re: [GENERAL] Simple Query not using Primary Key Index
Next
From: Vitaly Burovoy
Date:
Subject: Re: [GENERAL] Simple Query not using Primary Key Index