Optimize by collapsing trees into single SQL queries
This commit is contained in:
parent
185e236f15
commit
621acae945
7 changed files with 501 additions and 50 deletions
|
|
@ -103,6 +103,7 @@ func (it *And) Optimize() (graph.Iterator, bool) {
|
|||
newReplacement, hasOne := it.qs.OptimizeIterator(newAnd)
|
||||
if hasOne {
|
||||
newAnd.Close()
|
||||
glog.V(3).Infoln(it.UID(), "became", newReplacement.UID(), "from quadstore")
|
||||
return newReplacement, true
|
||||
}
|
||||
}
|
||||
|
|
@ -330,7 +331,7 @@ func materializeIts(its []graph.Iterator) []graph.Iterator {
|
|||
out = append(out, its[0])
|
||||
for _, it := range its[1:] {
|
||||
stats := it.Stats()
|
||||
if stats.Size*stats.NextCost < (stats.ContainsCost * (1 + (stats.Size / (allStats.Size + 1)))) {
|
||||
if false && stats.Size*stats.NextCost < (stats.ContainsCost*(1+(stats.Size/(allStats.Size+1)))) {
|
||||
if graph.Height(it, graph.Materialize) > 10 {
|
||||
out = append(out, NewMaterialize(it))
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -105,6 +105,14 @@ func (it *HasA) Optimize() (graph.Iterator, bool) {
|
|||
return it.primaryIt, true
|
||||
}
|
||||
}
|
||||
// Ask the graph.QuadStore if we can be replaced. Often times, this is a great
|
||||
// optimization opportunity (there's a fixed iterator underneath us, for
|
||||
// example).
|
||||
newReplacement, hasOne := it.qs.OptimizeIterator(it)
|
||||
if hasOne {
|
||||
it.Close()
|
||||
return newReplacement, true
|
||||
}
|
||||
return it, false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -140,6 +140,7 @@ func (it *Not) Optimize() (graph.Iterator, bool) {
|
|||
if optimized {
|
||||
it.primaryIt = optimizedPrimaryIt
|
||||
}
|
||||
it.primaryIt = NewMaterialize(it.primaryIt)
|
||||
return it, false
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue