Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
opt: compute filters cost in select
This will account for expensive geo function executions in WHERE clauses.
  • Loading branch information
madelynnblue committed May 18, 2020
commit cd40b95e32b867a4a358488144ded4e57f9f9fe5
2 changes: 1 addition & 1 deletion pkg/sql/logictest/testdata/logic_test/prepare
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ EXECUTE e
select
├── columns: k:1 str:2
├── stats: [rows=333.333333]
├── cost: 1050.03
├── cost: 1050.04
├── key: (1)
├── fd: (1)-->(2)
├── prune: (2)
Expand Down
12 changes: 6 additions & 6 deletions pkg/sql/opt/exec/execbuilder/testdata/explain
Original file line number Diff line number Diff line change
Expand Up @@ -987,22 +987,22 @@ EXPLAIN (OPT, VERBOSE) SELECT * FROM tc WHERE a + 2 * b > 1 ORDER BY a*b
sort
├── columns: a:1 b:2 [hidden: column4:4]
├── stats: [rows=333.333333]
├── cost: 1179.25548
├── cost: 1179.26548
├── fd: (1,2)-->(4)
├── ordering: +4
├── prune: (1,2,4)
├── interesting orderings: (+1)
└── project
├── columns: column4:4 a:1 b:2
├── stats: [rows=333.333333]
├── cost: 1116.70667
├── cost: 1116.71667
├── fd: (1,2)-->(4)
├── prune: (1,2,4)
├── interesting orderings: (+1)
├── select
│ ├── columns: a:1 b:2
│ ├── stats: [rows=333.333333]
│ ├── cost: 1110.03
│ ├── cost: 1110.04
│ ├── interesting orderings: (+1)
│ ├── scan tc
│ │ ├── columns: a:1 b:2
Expand All @@ -1021,22 +1021,22 @@ EXPLAIN (OPT, TYPES) SELECT * FROM tc WHERE a + 2 * b > 1 ORDER BY a*b
sort
├── columns: a:1(int) b:2(int) [hidden: column4:4(int)]
├── stats: [rows=333.333333]
├── cost: 1179.25548
├── cost: 1179.26548
├── fd: (1,2)-->(4)
├── ordering: +4
├── prune: (1,2,4)
├── interesting orderings: (+1)
└── project
├── columns: column4:4(int) a:1(int) b:2(int)
├── stats: [rows=333.333333]
├── cost: 1116.70667
├── cost: 1116.71667
├── fd: (1,2)-->(4)
├── prune: (1,2,4)
├── interesting orderings: (+1)
├── select
│ ├── columns: a:1(int) b:2(int)
│ ├── stats: [rows=333.333333]
│ ├── cost: 1110.03
│ ├── cost: 1110.04
│ ├── interesting orderings: (+1)
│ ├── scan tc
│ │ ├── columns: a:1(int) b:2(int)
Expand Down
24 changes: 12 additions & 12 deletions pkg/sql/opt/memo/testdata/format
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ SELECT a + 1, min(b) FROM t WHERE k + a > b GROUP BY a ORDER BY a
sort
├── columns: "?column?":5(int) min:4(int!null) [hidden: t.public.t.a:1(int)]
├── stats: [rows=98.1771622]
├── cost: 1097.87224
├── cost: 1097.88224
├── key: (1)
├── fd: (1)-->(4,5)
├── ordering: +1
├── prune: (1,4,5)
└── project
├── columns: "?column?":5(int) t.public.t.a:1(int) min:4(int!null)
├── stats: [rows=98.1771622]
├── cost: 1082.90531
├── cost: 1082.91531
├── key: (1)
├── fd: (1)-->(4,5)
├── prune: (1,4,5)
├── group-by
│ ├── columns: t.public.t.a:1(int) min:4(int!null)
│ ├── grouping columns: t.public.t.a:1(int)
│ ├── stats: [rows=98.1771622, distinct(1)=98.1771622, null(1)=1]
│ ├── cost: 1080.93177
│ ├── cost: 1080.94177
│ ├── key: (1)
│ ├── fd: (1)-->(4)
│ ├── prune: (4)
│ ├── select
│ │ ├── columns: t.public.t.a:1(int) t.public.t.b:2(int!null) t.public.t.k:3(int!null)
│ │ ├── stats: [rows=330, distinct(1)=98.1771622, null(1)=3.3, distinct(2)=100, null(2)=0]
│ │ ├── cost: 1070.03
│ │ ├── cost: 1070.04
│ │ ├── key: (3)
│ │ ├── fd: (3)-->(1,2)
│ │ ├── interesting orderings: (+3)
Expand Down Expand Up @@ -63,21 +63,21 @@ SELECT a + 1, min(b) FROM t WHERE k + a > b GROUP BY a ORDER BY a
sort
├── columns: "?column?":5(int) min:4(int!null) [hidden: t.public.t.a:1(int)]
├── stats: [rows=98.1771622]
├── cost: 1097.87224
├── cost: 1097.88224
├── ordering: +1
└── project
├── columns: "?column?":5(int) t.public.t.a:1(int) min:4(int!null)
├── stats: [rows=98.1771622]
├── cost: 1082.90531
├── cost: 1082.91531
├── group-by
│ ├── columns: t.public.t.a:1(int) min:4(int!null)
│ ├── grouping columns: t.public.t.a:1(int)
│ ├── stats: [rows=98.1771622, distinct(1)=98.1771622, null(1)=1]
│ ├── cost: 1080.93177
│ ├── cost: 1080.94177
│ ├── select
│ │ ├── columns: t.public.t.a:1(int) t.public.t.b:2(int!null) t.public.t.k:3(int!null)
│ │ ├── stats: [rows=330, distinct(1)=98.1771622, null(1)=3.3, distinct(2)=100, null(2)=0]
│ │ ├── cost: 1070.03
│ │ ├── cost: 1070.04
│ │ ├── scan t.public.t
│ │ │ ├── columns: t.public.t.a:1(int) t.public.t.b:2(int) t.public.t.k:3(int!null)
│ │ │ ├── stats: [rows=1000, distinct(1)=100, null(1)=10, distinct(2)=100, null(2)=10]
Expand Down Expand Up @@ -257,25 +257,25 @@ SELECT a + 1, min(b) FROM t WHERE k + a > b GROUP BY a ORDER BY a
----
sort
├── stats: [rows=98.1771622]
├── cost: 1097.87224
├── cost: 1097.88224
├── key: (1)
├── fd: (1)-->(4,5)
├── prune: (1,4,5)
└── project
├── stats: [rows=98.1771622]
├── cost: 1082.90531
├── cost: 1082.91531
├── key: (1)
├── fd: (1)-->(4,5)
├── prune: (1,4,5)
├── group-by
│ ├── stats: [rows=98.1771622, distinct(1)=98.1771622, null(1)=1]
│ ├── cost: 1080.93177
│ ├── cost: 1080.94177
│ ├── key: (1)
│ ├── fd: (1)-->(4)
│ ├── prune: (4)
│ ├── select
│ │ ├── stats: [rows=330, distinct(1)=98.1771622, null(1)=3.3, distinct(2)=100, null(2)=0]
│ │ ├── cost: 1070.03
│ │ ├── cost: 1070.04
│ │ ├── key: (3)
│ │ ├── fd: (3)-->(1,2)
│ │ ├── interesting orderings: (+3)
Expand Down
30 changes: 15 additions & 15 deletions pkg/sql/opt/memo/testdata/memo
Original file line number Diff line number Diff line change
Expand Up @@ -123,37 +123,37 @@ memo (optimized, ~18KB, required=[presentation: y:2,x:3,c:6] [ordering: +2])
├── G1: (project G2 G3 y x)
│ ├── [presentation: y:2,x:3,c:6] [ordering: +2]
│ │ ├── best: (project G2="[ordering: +2]" G3 y x)
│ │ └── cost: 1722.59
│ │ └── cost: 1722.60
│ └── []
│ ├── best: (project G2 G3 y x)
│ └── cost: 1722.59
│ └── cost: 1722.60
├── G2: (limit G4 G5 ordering=+2)
│ ├── [ordering: +2]
│ │ ├── best: (limit G4="[ordering: +2] [limit hint: 10.00]" G5 ordering=+2)
│ │ └── cost: 1722.38
│ │ └── cost: 1722.39
│ └── []
│ ├── best: (limit G4="[ordering: +2] [limit hint: 10.00]" G5 ordering=+2)
│ └── cost: 1722.38
│ └── cost: 1722.39
├── G3: (projections G6)
├── G4: (inner-join G7 G8 G9) (inner-join G8 G7 G9) (lookup-join G7 G10 b,keyCols=[5],outCols=(2,3,5)) (merge-join G8 G7 G10 inner-join,+3,+5)
│ ├── [ordering: +2] [limit hint: 10.00]
│ │ ├── best: (lookup-join G7="[ordering: +2] [limit hint: 100.00]" G10 b,keyCols=[5],outCols=(2,3,5))
│ │ └── cost: 1722.27
│ │ └── cost: 1722.28
│ └── []
│ ├── best: (inner-join G8 G7 G9)
│ └── cost: 2108.40
│ └── cost: 2108.41
├── G5: (const 10)
├── G6: (plus G11 G12)
├── G7: (project G13 G14 y)
│ ├── [ordering: +2] [limit hint: 100.00]
│ │ ├── best: (sort G7)
│ │ └── cost: 1119.26
│ │ └── cost: 1119.27
│ ├── [ordering: +5]
│ │ ├── best: (sort G7)
│ │ └── cost: 1119.26
│ │ └── cost: 1119.27
│ └── []
│ ├── best: (project G13 G14 y)
│ └── cost: 1056.71
│ └── cost: 1056.72
├── G8: (scan b,cols=(3))
│ ├── [ordering: +3]
│ │ ├── best: (scan b,cols=(3))
Expand All @@ -168,10 +168,10 @@ memo (optimized, ~18KB, required=[presentation: y:2,x:3,c:6] [ordering: +2])
├── G13: (select G16 G17)
│ ├── [ordering: +2] [limit hint: 100.00]
│ │ ├── best: (sort G13)
│ │ └── cost: 1112.58
│ │ └── cost: 1112.59
│ └── []
│ ├── best: (select G16 G17)
│ └── cost: 1050.03
│ └── cost: 1050.04
├── G14: (projections G18)
├── G15: (eq G19 G20)
├── G16: (scan a)
Expand All @@ -198,11 +198,11 @@ memo (optimized, ~4KB, required=[presentation: a:3,b:4,c:5,d:6])
├── G1: (project G2 G3)
│ └── [presentation: a:3,b:4,c:5,d:6]
│ ├── best: (project G2 G3)
│ └── cost: 1050.21
│ └── cost: 1050.23
├── G2: (select G4 G5)
│ └── []
│ ├── best: (select G4 G5)
│ └── cost: 1050.03
│ └── cost: 1050.05
├── G3: (projections G6 G7 G8 G9)
├── G4: (scan b)
│ └── []
Expand Down Expand Up @@ -233,11 +233,11 @@ memo (optimized, ~5KB, required=[presentation: x:1])
├── G1: (project G2 G3 x)
│ └── [presentation: x:1]
│ ├── best: (project G2 G3 x)
│ └── cost: 1.09
│ └── cost: 1.10
├── G2: (select G4 G5) (select G6 G7)
│ └── []
│ ├── best: (select G6 G7)
│ └── cost: 1.07
│ └── cost: 1.08
├── G3: (projections)
├── G4: (scan a)
│ └── []
Expand Down
Loading