mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 13:32:13 +00:00
b3f3a0c75c
Rewrite the following AST of `sum(column + literal)` sum(column + literal) -> sum(column) + literal * count(column) sum(literal + column) -> sum(column) + literal * count(column) Test the patch on 2 x 80 vCPUs system, Q29 of ClickBench has got a huge 11.5x performance improvement. Signed-off-by: Jiebin Sun <jiebin.sun@intel.com>
26 lines
613 B
C++
26 lines
613 B
C++
#pragma once
|
|
|
|
#include <Interpreters/DatabaseAndTableWithAlias.h>
|
|
#include <Interpreters/InDepthNodeVisitor.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class ASTFunction;
|
|
|
|
class RewriteSumFunctionWithSumAndCountMatcher
|
|
{
|
|
public:
|
|
struct Data
|
|
{
|
|
const TablesWithColumns & tables;
|
|
};
|
|
|
|
static void visit(ASTPtr & ast, const Data & data);
|
|
static void visit(const ASTFunction &, ASTPtr & ast, const Data & data);
|
|
static bool needChildVisit(const ASTPtr &, const ASTPtr &) { return true; }
|
|
};
|
|
|
|
using RewriteSumFunctionWithSumAndCountVisitor = InDepthNodeVisitor<RewriteSumFunctionWithSumAndCountMatcher, true>;
|
|
}
|