From: hubert depesz lubaczewski <depesz@depesz.com>
To: puneet.orcl@gmail.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17189: Index not created when primary key created
Date: Mon, 13 Sep 2021 12:36:31 +0200
Message-ID: <20210913103631.GB23362@depesz.com> (raw)
In-Reply-To: <17189-521a1b29d9727929@postgresql.org>
References: <17189-521a1b29d9727929@postgresql.org>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: depesz@depesz.com, puneet.orcl@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17189: Index not created when primary key created
In-Reply-To: <20210913103631.GB23362@depesz.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox