fix(perf): Fixed performance

* Performance are better when you write columns byte by
byte rather than string generation
This commit is contained in:
sagarafr
2018-11-03 00:05:57 +01:00
committed by Michal Matczuk
parent ec81eea1fc
commit a503f75a9c
2 changed files with 11 additions and 4 deletions

View File

@@ -10,7 +10,6 @@ package qb
import (
"bytes"
"fmt"
"strings"
)
// Order specifies sorting order.
@@ -54,7 +53,11 @@ func (b *SelectBuilder) ToCql() (stmt string, names []string) {
cql.WriteString("DISTINCT ")
b.distinct.writeCql(&cql)
case len(b.groupBy) > 0:
cql.WriteString(strings.Join(append(b.groupBy, b.columns...), ","))
b.groupBy.writeCql(&cql)
if len(b.columns) != 0 {
cql.WriteByte(',')
b.columns.writeCql(&cql)
}
case len(b.columns) == 0:
cql.WriteByte('*')
default: