Re: Is there any chance to get some kind of a result set sifting mechanism in Postgres?

From: Isaac Morland <isaac(dot)morland(at)gmail(dot)com>
To: aa <ghevge(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Is there any chance to get some kind of a result set sifting mechanism in Postgres?
Date: 2024-05-13 14:37:27
Message-ID: CAMsGm5c+-F8WUSnV+vqFLTck+g_6Vr+b7qZEbAooWdHgag-A8w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 13 May 2024 at 04:40, aa <ghevge(at)gmail(dot)com> wrote:

> Hello Everyone!
>
> Is there any chance to get some kind of a result set sifting mechanism in
> Postgres?
>
> What I am looking for is a way to get for example: "nulls last" in a
> result set, without having to call "order by" or having to use UNION ALL,
> and if possible to get this in a single result set pass.
>
> Something on this line: SELECT a, b, c FROM my_table WHERE a nulls last
> OFFSET 0 LIMIT 25
>
> I don't want to use order by or union all because these are time consuming
> operations, especially on large data sets and when comparations are done
> on dynamic values (eg: geolocation distances in between a mobile and a
> static location)
>

This already exists: ORDER BY a IS NULL

I've found it to be more useful than one might initially expect to order by
a boolean expression.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthias van de Meent 2024-05-13 14:52:49 Re: WAL_LOG CREATE DATABASE strategy broken for non-standard page layouts
Previous Message Jelte Fennema-Nio 2024-05-13 14:19:36 Re: Direct SSL connection with ALPN and HBA rules