Skip to content

Commit

Permalink
opt: (DEBUG) don't prune cols for delete
Browse files Browse the repository at this point in the history
This change makes it so the PruneMutationReturnCols norm rule
doesn't apply to the DELETE operator. This is because, DELETE isn't
playing well with it right now. I suspect it's because of the way
the optbuilder creates projections over the DELETE mutation.

Release note: None
  • Loading branch information
Ridwan Sharif committed Jul 3, 2019
1 parent e300764 commit 2fac7f2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
21 changes: 12 additions & 9 deletions pkg/sql/opt/exec/execbuilder/testdata/delete
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,18 @@ count · ·
· spans ALL
· limit 10

# TODO(andyk): Prune columns so that index-join is not necessary.
query TTT
EXPLAIN DELETE FROM indexed WHERE value = 5 LIMIT 10 RETURNING id
----
render · ·
└── run · ·
└── delete · ·
│ from indexed
│ strategy deleter
└── scan · ·
· table indexed@indexed_value_idx
· spans /5-/6
· limit 10
render · ·
└── run · ·
└── delete · ·
│ from indexed
│ strategy deleter
└── index-join · ·
│ table indexed@primary
└── scan · ·
· table indexed@indexed_value_idx
· spans /5-/6
· limit 10
2 changes: 1 addition & 1 deletion pkg/sql/opt/exec/execbuilder/testdata/orderby
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ render · · (b) ·
└── delete · · (a, b, c) ·
│ from t · ·
│ strategy deleter · ·
└── scan · · (a, b) ·
└── scan · · (a, b, c) ·
· table t@primary · ·
· spans /3-/3/# · ·

Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/norm/rules/prune_cols.opt
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@
# conservative with the fetch columns.
[PruneMutationReturnCols, Normalize]
(Project
$input: (Insert | Update | Upsert | Delete
$input: (Insert | Update | Upsert
$innerInput:*
$checks:*
$mutationPrivate:* & (CanPruneMutationReturnCols $mutationPrivate))
Expand Down
15 changes: 8 additions & 7 deletions pkg/sql/opt/norm/testdata/rules/prune_cols
Original file line number Diff line number Diff line change
Expand Up @@ -1879,25 +1879,26 @@ delete mutation
├── key: (6)
└── fd: (6)-->(7,9,10)

# Prune all columns not needed by the RETURNING clause.
# TODO(ridwanmsharif): Fix PruneMutationReturnCols with DELETE.
# TODO(andyk): Need to prune output columns.
opt expect=(PruneMutationFetchCols,PruneMutationInputCols)
opt expect-not=(PruneMutationFetchCols,PruneMutationInputCols)
DELETE FROM a RETURNING k, s
----
project
├── columns: k:1(int!null) s:4(string)
├── side-effects, mutations
├── key: (1)
├── fd: (1)-->(4)
└── delete a
├── columns: k:1(int!null) i:2(int) f:3(float) s:4(string)
├── fetch columns: k:5(int) s:8(string)
├── fetch columns: k:5(int) i:6(int) f:7(float) s:8(string)
├── side-effects, mutations
├── key: (1-3)
├── fd: (1)-->(4)
├── key: (1)
├── fd: (1)-->(2-4)
└── scan a
├── columns: k:5(int!null) s:8(string)
├── columns: k:5(int!null) i:6(int) f:7(float) s:8(string)
├── key: (5)
└── fd: (5)-->(8)
└── fd: (5)-->(6-8)

# Prune secondary family column not needed for the update.
opt expect=(PruneMutationFetchCols,PruneMutationInputCols)
Expand Down

0 comments on commit 2fac7f2

Please sign in to comment.