-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathmain.go
52 lines (45 loc) · 776 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"context"
"fmt"
"time"
"github.com/uptrace/go-clickhouse/ch"
)
const query = `
SELECT
number
, randomString(25)
, array(1, 2, 3, 4, 5)
, now()
FROM system.numbers LIMIT 1000000
`
func benchmark(ctx context.Context, db *ch.DB) error {
rows, err := db.QueryContext(ctx, query)
if err != nil {
return err
}
for rows.Next() {
var (
col1 uint64
col2 string
col3 []uint8
col4 time.Time
)
if err := rows.Scan(&col1, &col2, &col3, &col4); err != nil {
return err
}
}
return nil
}
func main() {
ctx := context.Background()
db := ch.Connect(
ch.WithDatabase("test"),
ch.WithCompression(false),
)
start := time.Now()
if err := benchmark(ctx, db); err != nil {
panic(err)
}
fmt.Println(time.Since(start))
}