Re: Planing edge case for sorts with limit on non null column - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Planing edge case for sorts with limit on non null column
Date
Msg-id 1615618.1770306397@sss.pgh.pa.us
Whole thread Raw
In response to Planing edge case for sorts with limit on non null column  (Mayrom Rabinovich <mayromrabinovich@gmail.com>)
List pgsql-hackers
Mayrom Rabinovich <mayromrabinovich@gmail.com> writes:
> -- same deal query by the reverse order of the index, but also specify the
> wrong null order
> -- from my understanding this should not matter because we don't have any
> nulls on the table
> -- due to the constraint.

No, that is not taken into account.  The planner's notion of a
concrete sort order always includes a nulls first/last flag, and this
index doesn't match what the query asks for.  If you want this query
to use an index you'll need to make an index that puts nulls at the
other end (either ASC NULLS FIRST or DESC NULLS LAST will do).

I'm not really excited about poking holes in the PathKey concept to
make this work the way you want.  I think the odds of introducing bugs
would be high.  Also, the question could be turned around: if you know
that the table contains no nulls, why are you going out of your way to
specify the "wrong" null order?

            regards, tom lane



pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: [PATCH] Support reading large objects with pg_read_all_data
Next
From: Andres Freund
Date:
Subject: Re: pg_upgrade: transfer pg_largeobject_metadata's files when possible