All Postgres Locks Explained | A Deep Dive

The Backend Engineering Show with Hussein Nasser

Episode | Podcast

Date: Sun, 19 Mar 2023 12:30:09 GMT

<p>Get my database engineering course https://database.husseinnasser.com</p> <p><br /></p> <p>In this video I do a deep dive in all locks obtained by postgres, I learned a lot while making this video and hope you enjoy it. </p> <p><br /></p> <p>0:00 Intro </p> <p>2:30 What are Locks? </p> <p>5:30 Overview of Postgres Locks</p> <p>9:10 Table-Level Locks</p> <p>11:40 ACCESS EXCLUSIVE</p> <p>17:40 ACCESS SHARE</p> <p>19:00 ROW SHARE<br /> 20:15 ROW EXCLUSIVE</p> <p>21:15 SHARE UPDATE EXCLUSIVE</p> <p>23:30 SHARE</p> <p>24:50 SHARE ROW EXCLUSIVE</p> <p>25:18 EXCLUSIVE</p> <p>25:30 Table Lock Conflict Matrix</p> <p>28:30 Row-Level Locks</p> <p>30:00 FOR UPDATE</p> <p>33:00 FOR NO KEY UPDATE</p> <p>34:00 FOR SHARE</p> <p>34:40 FOR KEY SHARE<br /> 35:10 Row Lock Conflict Matrix</p> <p>39:25 Page-Level Locks</p> <p>42:00 Deadlocks</p> <p>46:00 Advistory Locks</p> <p>47:20 Summary</p> <p><br /></p> <p><br /><a href="https://www.postgresql.org/docs/current/explicit-locking.html">https://www.postgresql.org/docs/current/explicit-locking.html</a></p> <p><br /></p>