Re: Should we optimize the `ORDER BY random() LIMIT x` case?

From: Nico Williams <nico(at)cryptonector(dot)com>
To: Aleksander Alekseev <aleksander(at)timescale(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrei Lepikhov <lepihov(at)gmail(dot)com>, wenhui qiu <qiuwenhuifx(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>
Subject: Re: Should we optimize the `ORDER BY random() LIMIT x` case?
Date: 2025-05-19 15:38:19
Message-ID: aCtQa0CzPtHWolXH@ubby
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, May 19, 2025 at 01:25:00PM +0300, Aleksander Alekseev wrote:
> I agree this would be most convenient for the user. Unfortunately this
> will require us to check every SELECT query: "oh, isn't it by any
> chance ORDER BY random() LIMIT x?". I don't think we can't afford such
> a performance degradation, even a small one, for an arguably rare
> case.

Can the detection of such queries be done by the yacc/bison parser
grammar?

Nico
--

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jose Luis Tallon 2025-05-19 15:49:59 Re: Violation of principle that plan trees are read-only
Previous Message Florents Tselai 2025-05-19 15:29:15 Re: Proposal: Make cfbot fail on patches not created by "git format-patch"