Merge pull request #6662 from influxdata/js-6661-disable-limit-optimization-for-aggregate

Remove limit optimization when using an aggregate
pull/6621/head
Jonathan A. Sternberg 2016-05-19 10:54:04 -04:00
commit 0f0e9bb96b
2 changed files with 8 additions and 11 deletions

View File

@ -33,6 +33,7 @@
- [#6557](https://github.com/influxdata/influxdb/issues/6557): Overwriting points on large series can cause memory spikes during compactions - [#6557](https://github.com/influxdata/influxdb/issues/6557): Overwriting points on large series can cause memory spikes during compactions
- [#6611](https://github.com/influxdata/influxdb/issues/6611): Queries slow down hundreds times after overwriting points - [#6611](https://github.com/influxdata/influxdb/issues/6611): Queries slow down hundreds times after overwriting points
- [#6641](https://github.com/influxdata/influxdb/issues/6641): Fix read tombstones: EOF - [#6641](https://github.com/influxdata/influxdb/issues/6641): Fix read tombstones: EOF
- [#6661](https://github.com/influxdata/influxdb/issues/6661): Disable limit optimization when using an aggregate.
## v0.13.0 [2016-05-12] ## v0.13.0 [2016-05-12]

View File

@ -846,7 +846,7 @@ func (e *Engine) CreateIterator(opt influxql.IteratorOptions) (influxql.Iterator
if call, ok := opt.Expr.(*influxql.Call); ok { if call, ok := opt.Expr.(*influxql.Call); ok {
refOpt := opt refOpt := opt
refOpt.Expr = call.Args[0].(*influxql.VarRef) refOpt.Expr = call.Args[0].(*influxql.VarRef)
inputs, err := e.createVarRefIterator(refOpt) inputs, err := e.createVarRefIterator(refOpt, true)
if err != nil { if err != nil {
return nil, err return nil, err
} else if len(inputs) == 0 { } else if len(inputs) == 0 {
@ -869,7 +869,7 @@ func (e *Engine) CreateIterator(opt influxql.IteratorOptions) (influxql.Iterator
return influxql.NewParallelMergeIterator(inputs, opt, runtime.GOMAXPROCS(0)), nil return influxql.NewParallelMergeIterator(inputs, opt, runtime.GOMAXPROCS(0)), nil
} }
itrs, err := e.createVarRefIterator(opt) itrs, err := e.createVarRefIterator(opt, false)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -882,7 +882,9 @@ func (e *Engine) CreateIterator(opt influxql.IteratorOptions) (influxql.Iterator
} }
// createVarRefIterator creates an iterator for a variable reference. // createVarRefIterator creates an iterator for a variable reference.
func (e *Engine) createVarRefIterator(opt influxql.IteratorOptions) ([]influxql.Iterator, error) { // The aggregate argument determines this is being created for an aggregate.
// If this is an aggregate, the limit optimization is disabled temporarily. See #6661.
func (e *Engine) createVarRefIterator(opt influxql.IteratorOptions, aggregate bool) ([]influxql.Iterator, error) {
ref, _ := opt.Expr.(*influxql.VarRef) ref, _ := opt.Expr.(*influxql.VarRef)
var itrs []influxql.Iterator var itrs []influxql.Iterator
@ -905,14 +907,8 @@ func (e *Engine) createVarRefIterator(opt influxql.IteratorOptions) ([]influxql.
return err return err
} }
if len(inputs) > 0 && (opt.Limit > 0 || opt.Offset > 0) { if !aggregate && len(inputs) > 0 && (opt.Limit > 0 || opt.Offset > 0) {
var itr influxql.Iterator itrs = append(itrs, newLimitIterator(influxql.NewSortedMergeIterator(inputs, opt), opt))
if opt.MergeSorted() {
itr = influxql.NewSortedMergeIterator(inputs, opt)
} else {
itr = influxql.NewMergeIterator(inputs, opt)
}
itrs = append(itrs, newLimitIterator(itr, opt))
} else { } else {
itrs = append(itrs, inputs...) itrs = append(itrs, inputs...)
} }