[docs] revise ORDER BY documentation

From: "Dian Fay" <di(at)nmfay(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: [docs] revise ORDER BY documentation
Date: 2024-03-03 04:13:12
Message-ID: CZJTMBYACP97.2RN8B7OBOYXVJ@nmfay.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I recently encountered some odd behavior with a query both selecting and
sorting by `random()`. When I posted about it on pgsql-bugs ^1, David
Johnston and Tom Lane provided some very detailed explanations as to
what was happening, but weren't sure whether or where information about
it could live comfortably in the docs. I think it's a useful addition;
it's not an everyday occurrence but I'm very much not the first person
to run into it. After a bit of looking, I think I've found a reasonable
location.

This patch revises
https://www.postgresql.org/docs/current/queries-order.html to discuss
sort expressions and options separately, and fits a caveat based on
Tom's suggested language (with an example) into the former section.

There are a few other minor tweaks included here:

- note that `*` is not an expression
- consolidate output column examples
- mention non-column sort expressions

I did write a query demonstrating the `group by` case Tom mentioned, but
expect that one's a lot less common.

1: https://www.postgresql.org/message-id/CZHAF947QQQO.27MAUK2SVMBXW%40nmfay.com

Attachment Content-Type Size
0001-Revise-ORDER-BY-documentation.patch text/x-patch 9.3 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2024-03-03 05:43:05 Re: [PoC] Improve dead tuple storage for lazy vacuum
Previous Message Amit Kapila 2024-03-03 04:03:19 Re: Documentation: warn about two_phase when altering a subscription