cockroachdb / cockroachdb/cockroach

sql/opt: push Lock below ProjectSet

Open
#159,493 0 comments 0 reactions 0 assignees View on GitHub
A-read-committed A-sql-optimizer C-performance T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

When using the new lock operator, we add locking at the top of the query tree. One case where we should push locking down is when a project-set is between the lock op and the rest of the plan. For example:

```sql
CREATE TABLE ab (
a INT PRIMARY KEY,
b INT
);

INSERT INTO ab VALUES (2, 2);

-- when using the old lock plan, locking is on the initial scan
EXPLAIN
SELECT generate_series(0, b)
FROM ab WHERE a = 2
FOR UPDATE OF ab;

SET optimizer_use_lock_op_for_serializable = on;

-- when using the new lock plan, locking happens after the project set
EXPLAIN
SELECT generate_series(0, b)
FROM ab WHERE a = 2
FOR UPDATE OF ab;

Jira issue: CRDB-57890

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.