Use cases for lateral that do not involve a set returning function - Mailing list pgsql-general

From AJ Welch
Subject Use cases for lateral that do not involve a set returning function
Date
Msg-id CAO-RzR+yEFGdi8CLgqyrfm77c9D5Ttk2ErpKnBPqkWO9w8WGPA@mail.gmail.com
Whole thread Raw
Responses Re: Use cases for lateral that do not involve a set returning function
List pgsql-general
I was reading this post the other day:

http://blog.heapanalytics.com/postgresqls-powerful-new-join-type-lateral/

I suspected some of the claims in the post may not have been accurate. This one in particular:

"Without lateral joins, we would need to resort to PL/pgSQL to do this analysis. Or, if our data set were small, we could get away with complex, inefficient queries."

The sum(1) and order by time limit 1 approach seemed less than ideal to me and I thought this analysis could be done with normal left joins instead of lateral left joins. So I came up with a proof of concept:


Is my conclusion in the README correct? Does anything beyond select...from...where force a nested loop? In that case, is lateral really only useful with set returning functions as the docs suggest? Does anyone know of any use cases for lateral that do not involve a set returning function?

Thanks,
AJ

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: I did some testing of GIST/GIN vs BTree indexing…
Next
From: Sérgio Saquetim
Date:
Subject: Strange behavior in generate_series(date, date, interval) with DST