Re: Should we optimize the `ORDER BY random() LIMIT x` case? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Should we optimize the `ORDER BY random() LIMIT x` case?
Date
Msg-id 99515.1747430468@sss.pgh.pa.us
Whole thread Raw
In response to Re: Should we optimize the `ORDER BY random() LIMIT x` case?  (Vik Fearing <vik@postgresfriends.org>)
Responses Re: Should we optimize the `ORDER BY random() LIMIT x` case?
List pgsql-hackers
Vik Fearing <vik@postgresfriends.org> writes:
> On 16/05/2025 15:01, Tom Lane wrote:
>> Seems to me the obvious answer is to extend TABLESAMPLE (or at least, some
>> of the tablesample methods) to allow it to work on a subquery.

> Isn't this a job for <fetch first clause>?
> FETCH SAMPLE FIRST 10 ROWS ONLY

How is that an improvement on TABLESAMPLE?  Or did the committee
forget that they already have that feature?

TABLESAMPLE seems strictly better to me here because it affords
the opportunity to specify one of several methods, which seems
like it would be useful in this context.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Vik Fearing
Date:
Subject: Re: Should we optimize the `ORDER BY random() LIMIT x` case?
Next
From: Vik Fearing
Date:
Subject: Re: Should we optimize the `ORDER BY random() LIMIT x` case?