Skip to content

Commit

Permalink
executor: avoid allocating a lot of memory at first in topn. (pingcap…
Browse files Browse the repository at this point in the history
  • Loading branch information
hanfei1991 authored and coocood committed Jun 7, 2017
1 parent 7ae996c commit 1c5ad42
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion executor/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ func (e *TopnExec) Next() (*Row, error) {
if !e.fetched {
e.Idx = int(e.limit.Offset)
e.totalCount = int(e.limit.Offset + e.limit.Count)
e.Rows = make([]*orderByRow, 0, e.totalCount+1)
cap := e.totalCount + 1
if cap > 1024 {
cap = 1024
}
e.Rows = make([]*orderByRow, 0, cap)
e.heapSize = 0
for {
srcRow, err := e.children[0].Next()
Expand Down

0 comments on commit 1c5ad42

Please sign in to comment.