Re: Index ordering after IS NULL

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Index ordering after IS NULL
Date: 2022-09-10 22:00:08
Message-ID: CAH2-Wz=iDDL7H=rbgEiaHTXGEMTJ0Nhu8c4q9ZgOP1KfNna6Dg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Sep 10, 2022 at 2:28 PM Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
> explain analyze select * from j where b is null order by c limit 10;
> explain analyze select * from j where b =8 order by c limit 10;
>
> The first uses a sort despite it being disabled.

The first/is null query seems to give the result and plan you're
looking for if the query is rewritten to order by "b, c", and not just
"c".

That in itself doesn't make your complaint any less valid, of course.
You don't have to do this with the second query, so why should you
have to do it with the first?

--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2022-09-10 23:17:44 Re: why can't a table be part of the same publication as its schema
Previous Message Michael Banck 2022-09-10 21:43:11 Re: Support load balancing in libpq