Re: Simple Query not using Primary Key Index

From: Vitaly Burovoy <vitaly(dot)burovoy(at)gmail(dot)com>
To: "Podrigal, Aron" <aronp(at)guaranteedplus(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Simple Query not using Primary Key Index
Date: 2017-02-06 23:33:20
Message-ID: CAKOSWNkhGqm6wWuAcrjjJYL0eKNQ6odFREXjgnki9bwA0Hb-6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/6/17, Podrigal, Aron <aronp(at)guaranteedplus(dot)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?

Postgres uses specified access methods according to table's statistics.
If you have a small table, it is likely that Postgres uses SeqScan
because it is similar or cheaper than IndexScan. That's why it can
ignore existing indexes.

--
Best regards,
Vitaly Burovoy

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Aron Podrigal 2017-02-06 23:43:29 Re: Simple Query not using Primary Key Index
Previous Message Aron Podrigal 2017-02-06 23:33:05 Re: Simple Query not using Primary Key Index