Re: Query optimiser is not using 'not null' constraint when 'order by nulls last' clause is used

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Nandakumar M <m(dot)nanda92(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, PostgreSQL mailing lists <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Query optimiser is not using 'not null' constraint when 'order by nulls last' clause is used
Date: 2018-02-02 15:58:42
Message-ID: CAKFQuwZsXmhUdOoyjM4muydFym1PwaLsP+bHe2nXAbMX3SUC7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Feb 2, 2018 at 8:49 AM, Nandakumar M <m(dot)nanda92(at)gmail(dot)com> wrote:

> But, for the PK column we are not in control of the index that is created.
>

​You probably can (I assume the nulls aspect of the index doesn't prevent
PK usage), but you must add the PK to the table after creating the index
and not let the system auto-generate the index for you.​

https://www.postgresql.org/docs/10/static/sql-altertable.html

​ALTER TABLE name ADD ​PRIMARY KEY USING INDEX index_name;

David J.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Nandakumar M 2018-02-02 17:01:27 Re: Query optimiser is not using 'not null' constraint when 'order by nulls last' clause is used
Previous Message Nandakumar M 2018-02-02 15:49:50 Re: Query optimiser is not using 'not null' constraint when 'order by nulls last' clause is used