Thread: WITH and exclusive locks

WITH and exclusive locks

From
Jayadevan M
Date:
Hi,

When conducting performance tests of our application, I saw quite a few exclusive locks in SELECTs with WITH clause. So I created a big table and executed a query which takes time.
with x as (select * from emp where first_name like 'Sco%')
select * from x;   
I got 2 locks - one accesshare lock against the table and one ExclusiveLock with out  any database/relation.
2417            postgres    10/95    10/95    ExclusiveLock    Yes    2013-11-23 17:38:58+05:30   

My guess is that the Exclusive lock is against some in-memory structure (the temp table created by the WITH clause) and hence is not an issue. Is that correct?
Regards,
Jayadevan