From ba919ebf30f17976ca9c5b88e78a34ab78907d35 Mon Sep 17 00:00:00 2001 From: ichn-hu Date: Tue, 17 Aug 2021 16:08:17 +0800 Subject: [PATCH] use conn instead of db enable projection push down add projection Signed-off-by: ichn-hu --- push-down-test/config/with_push_down/tidb.toml | 3 +++ push-down-test/prepare/1_proj.sql | 2 ++ push-down-test/sql/projection/1_basic_1.sql | 3 +++ push-down-test/src/main.go | 9 +++++++++ 4 files changed, 17 insertions(+) create mode 100644 push-down-test/prepare/1_proj.sql create mode 100644 push-down-test/sql/projection/1_basic_1.sql diff --git a/push-down-test/config/with_push_down/tidb.toml b/push-down-test/config/with_push_down/tidb.toml index 37405d0..1343384 100644 --- a/push-down-test/config/with_push_down/tidb.toml +++ b/push-down-test/config/with_push_down/tidb.toml @@ -4,3 +4,6 @@ path = "127.0.0.1:4479" [status] report-status = false + +[performance] +projection-push-down = true diff --git a/push-down-test/prepare/1_proj.sql b/push-down-test/prepare/1_proj.sql new file mode 100644 index 0000000..9c95fd7 --- /dev/null +++ b/push-down-test/prepare/1_proj.sql @@ -0,0 +1,2 @@ +CREATE TABLE proj_t0 (i int, t timestamp, s varchar(30)); +INSERT into proj_t0 VALUES (1, '2021-08-19 12:53:05', 'good good study, day day up'); diff --git a/push-down-test/sql/projection/1_basic_1.sql b/push-down-test/sql/projection/1_basic_1.sql new file mode 100644 index 0000000..598fab0 --- /dev/null +++ b/push-down-test/sql/projection/1_basic_1.sql @@ -0,0 +1,3 @@ +SELECT i + 1 FROM proj_t0; +SELECT DATE_FORMAT(t, '%Y-%m-%d %H') FROM proj_t0; +SELECT MD5(s) FROM proj_t0; diff --git a/push-down-test/src/main.go b/push-down-test/src/main.go index e328efc..2ebce05 100644 --- a/push-down-test/src/main.go +++ b/push-down-test/src/main.go @@ -148,6 +148,8 @@ func runTestCase(testCasePath string) bool { func runStatements(logChan chan *statementLog, connString string, statements []string) { db := mustDBOpen(connString, *dbName) + v := getSessionVariable(db, "tidb_opt_projection_push_down") + log.Printf("for %s tidb_opt_projection_push_down=%s\n", connString, v) connID := getConnectionID(db) for i, stmt := range statements { runSingleStatement(stmt, i, db, connID, logChan) @@ -163,6 +165,13 @@ func getConnectionID(db *sql.DB) uint64 { return v } +func getSessionVariable(db *sql.DB, varname string) string { + var v string + err := db.QueryRow(fmt.Sprintf("select @@%s;", varname)).Scan(&v) + expectNoErr(err) + return v +} + func runQuery(db *sql.DB, sql string) (string, error) { rows, err := db.Query(sql) buf := new(bytes.Buffer)