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

From Merlin Moncure
Subject Re: Use cases for lateral that do not involve a set returning function
Date
Msg-id CAHyXU0wSp23EyDjKB4_yKJpwodettR9R964BanFmx67NYMpuOw@mail.gmail.com
Whole thread Raw
In response to Re: Use cases for lateral that do not involve a set returning function  (Albe Laurenz <laurenz.albe@wien.gv.at>)
List pgsql-general
On Tue, Dec 9, 2014 at 4:24 AM, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
> SELECT ...
> FROM people p
>      LEFT JOIN LATERAL (SELECT * FROM names n
>                         WHERE n.people_id = p.people_id
>                         AND current_timestamp > n.validfrom
>                         ORDER BY n.validfrom DESC LIMIT 1) n
>         ON TRUE
> WHERE p.id = ...
>
> With the correct index this touched fewer blocks and worked faster.
> Also, though this is of course a matter of taste, it is more readable.
>
> Of course this forces a nested loop, but that is not bad as such.
> In my case it was not problem (I tried to hint at that with the WHERE clause).

I don't know...forcing a nestloop is a dealbreaker for many
distributions of data.

merlin


pgsql-general by date:

Previous
From: "Jack Douglas"
Date:
Subject: Re: new index type with clustering in mind.
Next
From: Adrian Klaver
Date:
Subject: Re: invalid memory alloc request size