Re: BUG #17189: Index not created when primary key created - Mailing list pgsql-bugs

From hubert depesz lubaczewski
Subject Re: BUG #17189: Index not created when primary key created
Date
Msg-id 20210913103631.GB23362@depesz.com
Whole thread Raw
In response to BUG #17189: Index not created when primary key created  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
On Mon, Sep 13, 2021 at 05:27:00AM +0000, PG Bug reporting form wrote:
> I have created the composite primary key which is created successfully but i
> am not getting the index against the primary key.

That's rather impossible. Please show create table statement, and output
of `\d table_name` after creation.

> When i created a select query and includes the primary key column it is
> going with full table scan. Even i am creating an index on the columns it is
> also going with full table scan.

Index will be used only when it makes sense.

If you'd do: select * from table; - that is select all rows - there is
no point in using index, as it will be slower than getting seq scan.

Plus - your table can be too small to effectively use index.

Consider reading:
https://www.depesz.com/2010/09/09/why-is-my-index-not-being-used/

Best regards,

depesz




pgsql-bugs by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: BUG #17189: Index not created when primary key created
Next
From: PG Bug reporting form
Date:
Subject: BUG #17191: Docker / buildx issue - An image created with buildx requires to set custom PGDATA location