Re: Left lateral join with for update and skip locked

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Benjamin Börngen-Schmidt <benjamin(at)boerngen-schmidt(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Left lateral join with for update and skip locked
Date: 2015-03-18 13:15:23
Message-ID: 20150318131523.GU3636@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Benjamin Börngen-Schmidt wrote:

> The Lateral statement does return a result, which I do not expect. I returns
> an end point multiple times for diverent start points. Why? I thought, that
> the selected point by the lateral is locked by the FOR UPDATE and if the
> lateral selects a point that is already locked it will be skipped by the
> SKIP LOCKED.

So you want the LATERAL to lock a row, such that that row is not
returned by the "s" arm of the left join in the same query because of
SKIP LOCKED? That seems flawed to me: the row lock is considered
automatically granted if the would-be locker is the same transaction as
the lock holder.

I am too lazy to reverse engineer your schema. Are de_sim_points_end
and de_sim_points_start views on the same table(s), or something like
that?

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Devrim Gündüz 2015-03-18 13:19:22 Help needed for PL/Ruby
Previous Message Benjamin Börngen-Schmidt 2015-03-18 12:55:38 Left lateral join with for update and skip locked