Re: Should we optimize the `ORDER BY random() LIMIT x` case?
Nico Williams <nico@cryptonector.com>
From: Nico Williams <nico@cryptonector.com>
To: Aleksander Alekseev <aleksander@timescale.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Tom Lane <tgl@sss.pgh.pa.us>, Andrei Lepikhov <lepihov@gmail.com>, wenhui qiu <qiuwenhuifx@gmail.com>, Vik Fearing <vik@postgresfriends.org>
Date: 2025-05-19T15:38:19Z
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 --