cockroachdb / cockroachdb/cockroach

opt: include index recommendations for FK cascades

Open
#101,679 1 comment 0 reactions 0 assignees View on GitHub
A-sql-explain C-enhancement T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Consider the tables:

```sql
CREATE TABLE p (id INT PRIMARY KEY);

CREATE TABLE c (id INT PRIMARY KEY, p_id INT REFERENCES p(id) ON DELETE CASCADE);
```

CRDB should recommend `CREATE INDEX ON c(p_id)` to speed up the FK cascade when deleting a row from `p`. It currently makes no recommendation:

```
defaultdb> EXPLAIN DELETE FROM p WHERE id = 1;
info
--------------------------
distribution: local
vectorized: true

• root

├── • delete range
│ from: p
│ spans: [/1 - /1]

└── • fk-cascade
fk: c_p_id_fkey
(11 rows)
```

Jira issue: CRDB-27088

gz#18371

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.