Commit efdbe38d authored by Matt Jibson's avatar Matt Jibson

opt: initial implementation of costing geo lookup joins

parent 284d3855
......@@ -473,8 +473,19 @@ func (c *coster) computeLookupJoinCost(
}
func (c *coster) computeGeoLookupJoinCost(join *memo.GeoLookupJoinExpr) memo.Cost {
// TODO(rytaft): add a real cost here.
return 0
lookupCount := join.Input.Relational().Stats.RowCount
// The rows in the (left) input are used to probe into the (right) table.
// Since the matching rows in the table may not all be in the same range, this
// counts as random I/O.
perLookupCost := memo.Cost(randIOCostFactor)
cost := memo.Cost(lookupCount) * perLookupCost
// TODO: support GeoLookupJoinExpr in c.mem.RowsProcessed. See
// computeLookupJoinCost.
cost += c.computeFiltersCost(join.On, util.FastIntMap{})
return cost
}
func (c *coster) computeFiltersCost(filters memo.FiltersExpr, eqMap util.FastIntMap) memo.Cost {
......
......@@ -1693,16 +1693,16 @@ memo (optimized, ~23KB, required=[presentation: name:13,popn_per_sqkm:16])
├── G1: (project G2 G3 name)
│ └── [presentation: name:13,popn_per_sqkm:16]
│ ├── best: (project G2 G3 name)
│ └── cost: 5102.53
│ └── cost: 5110.53
├── G2: (group-by G4 G5 cols=(13,14))
│ └── []
│ ├── best: (group-by G4 G5 cols=(13,14))
│ └── cost: 5102.48
│ └── cost: 5110.48
├── G3: (projections G6)
├── G4: (inner-join G7 G8 G9) (inner-join G8 G7 G9) (lookup-join G10 G9 nyc_census_blocks,keyCols=[1],outCols=(3,9,10,12-14))
│ └── []
│ ├── best: (lookup-join G10 G9 nyc_census_blocks,keyCols=[1],outCols=(3,9,10,12-14))
│ └── cost: 4895.53
│ └── cost: 4903.53
├── G5: (aggregations G11)
├── G6: (div G12 G13)
├── G7: (scan c,cols=(3,9,10))
......@@ -1717,7 +1717,7 @@ memo (optimized, ~23KB, required=[presentation: name:13,popn_per_sqkm:16])
├── G10: (geo-lookup-join G8 G18 [email protected]_census_blocks_geo_idx)
│ └── []
│ ├── best: (geo-lookup-join G8 G18 [email protected]_census_blocks_geo_idx)
│ └── cost: 139.36
│ └── cost: 147.36
├── G11: (sum G19)
├── G12: (variable sum)
├── G13: (div G20 G21)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment