CockroachDB Videos
← Back to all videos

Locking Reads Explained | Consistency in CockroachDB

2024-07-08

Consistency in CockroachDB Demos & Tutorials

Description

Cockroach Labs Technical Evangelist Rob Reid walks through Locking Reads, comparing the differences between SELECT FOR UPDATE vs SELECT FOR SHARE locking mechanisms in CockroachDB users can harness to gain different levels of locking strength for your queries. SELECT FOR UPDATE and SELECT FOR SHARE both fall into the category of read locks, and they are often used in conjunction with SELECT queries to express intent. (What do you plan on doing with that data after you've selected it?) Further reading: [Docs] FOR UPDATE and FOR SHARE: https://cockroa.ch/45SyoDn [Blog] What is SELECT FOR UPDATE in SQL (With examples)? https://cockroa.ch/3tbsHlb Locking Reads Explained | Consistency in CockroachDB 00:00 Introduction 00:13 What are read locks? 00:50 How do SELECT FOR UPDATE and SELECT FOR SHARE differ? 01:31 DEMO: Setting up a CockroachDB 24.1 cluster and enabling Read Committed 02:00 DEMO: SELECT FOR UPDATE 03:29 DEMO: SELECT FOR SHARE 04:20 DEMO: Simulating long-running transactions 05:56 Why these locking mechanisms are important to use in read-committed isolation