On Mon, Feb 5, 2018 at 8:18 PM, Tatsuo Ishii <is...@sraoss.co.jp> wrote: > We have: CREATE VIEW v1 AS SELECT * FROM t1 WHERE i = (SELECT i FROM t2); > > 1. Session A tries to lock v1 (I suppose it tries to acquire lock in > the order of t1, then t2). A acquires lock on t1 but yet on t2. > > 2. Another session B acquires lock on t2. > > 3. A continues to try to acquire lock on t2 (blocked). > > 4. B tries to acquire lock on t1. Deadlock occurs.
True. But the same exact analysis also applies to this definition, which contains no subquery: CREATE VIEW v1 AS SELECT t1.* FROM t1, t2 WHERE t1.i = t2.i; -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company