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

From Vik Fearing
Subject Re: Should we optimize the `ORDER BY random() LIMIT x` case?
Date
Msg-id 254d4733-29b6-4152-bd06-c292ee002790@postgresfriends.org
Whole thread Raw
In response to Re: Should we optimize the `ORDER BY random() LIMIT x` case?  (Aleksander Alekseev <aleksander@timescale.com>)
List pgsql-hackers
On 19/05/2025 12:25, Aleksander Alekseev wrote:
> Tom, Nico, Vik,
>
>> TABLESAMPLE is hitched to a <table primary> which can be basically
>> anything resembling a relation.  So it appears the standard already
>> allows this and we just need to implement it.
> Vik, many thanks for sharing this. I don't have a strong opinion on
> `FETCH SAMPLE FIRST 10 ROWS ONLY` but since TABLESAMPLE should / may
> work for subqueries anyway we could focus on it for now.


Yeah, putting this into <fetch first clause> was a dumb idea on my part, 
and Tom correctly corrected me.  I do not yet have the required number 
of years in the sql standards studies to know the whole thing by heart.


I think we (as a community) should work on expanding our <sample clause> 
to work with any <table primary> and not just a base table.  Especially 
since we already have two existing extensions by Petr to the standard 
for that clause.  We can easily make more, which might even make their 
way back into the standard.

-- 

Vik Fearing




pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: strange perf regression with data checksums
Next
From: Peter Geoghegan
Date:
Subject: Re: strange perf regression with data checksums