cockroachdb / cockroachdb/cockroach

opt: use buffered writes lock elision with SFU subquery

Open
#146,611 1 comment 0 reactions 0 assignees View on GitHub
A-buffered-writes branch-master branch-release-25.2 C-performance O-qa T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

When using buffered writes, the optimizer is sometimes able to elide the locking on Puts or Dels when the initial scan of the mutation was locked. For example:

```sql
SET CLUSTER SETTING kv.transaction.write_buffering.enabled = on;
CREATE TABLE ab (a INT PRIMARY KEY, b INT);
INSERT INTO ab VALUES (6, 6), (7, 7);
\set auto_trace=kv
UPDATE ab SET b = 16 WHERE a = 6;
-- Put /Table/104/1/6/0 -> /TUPLE/2:2:Int/16
```

It would be nice if the optimizer could also elide locking when a SFU subquery is used, for example:

```sql
UPDATE ab SET b = 17 WHERE a IN (SELECT a FROM ab WHERE a = 7 FOR UPDATE);
-- Put (locking) /Table/104/1/7/0 -> /TUPLE/2:2:Int/17
```

Jira issue: CRDB-50615

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.