Re: disabling seqscan not using primary key index? - Mailing list pgsql-general

From Tom Lane
Subject Re: disabling seqscan not using primary key index?
Date
Msg-id 2312912.1621099035@sss.pgh.pa.us
Whole thread Raw
In response to Re: disabling seqscan not using primary key index?  (Luca Ferrari <fluca1978@gmail.com>)
List pgsql-general
Luca Ferrari <fluca1978@gmail.com> writes:
> On Sat, May 15, 2021 at 4:40 PM David Rowley <dgrowleyml@gmail.com> wrote:
>> The answer is fairly simple, the planner just never considers using
>> the primary key index as there are no possible cases where it would be
>> useful.

> Does this mean that any UNIQUE constraint on the table is subject to
> the same consideration?

David's statement applies to any index.  Per the code in indxpath.c:

     * 4. Generate an indexscan path if there are relevant restriction clauses
     * in the current clauses, OR the index ordering is potentially useful for
     * later merging or final output ordering, OR the index has a useful
     * predicate, OR an index-only scan is possible.

If none of those cases apply, an indexscan is guaranteed to be worse
than a seqscan, so we don't consider it.

            regards, tom lane



pgsql-general by date:

Previous
From: Luca Ferrari
Date:
Subject: Re: disabling seqscan not using primary key index?
Next
From: Venkata B Nagothi
Date:
Subject: Re: Postgres upgrade 12 - issues with OIDs