diff --git a/push-down-test/config/with_push_down/tidb.toml b/push-down-test/config/with_push_down/tidb.toml index 51587b0..de36222 100644 --- a/push-down-test/config/with_push_down/tidb.toml +++ b/push-down-test/config/with_push_down/tidb.toml @@ -5,3 +5,6 @@ socket = "" [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)