dbms: lowered memory usage of huge ORDER BY with small LIMIT [#METR-2944].

This commit is contained in:
Alexey Milovidov 2014-12-15 07:13:33 +03:00
parent da86564110
commit f4ea556a30
2 changed files with 6 additions and 1 deletions

View File

@ -11,6 +11,11 @@ Block PartialSortingBlockInputStream::readImpl()
{
Block res = children.back()->read();
sortBlock(res, description, limit);
if (limit && res.rowsInFirstColumn() > limit)
for (size_t i = 0, size = res.columns(); i < size; ++i)
res.getByPosition(i).column = res.getByPosition(i).column->cut(0, limit);
return res;
}