Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable projection pushdown #145

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions push-down-test/config/with_push_down/tidb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ socket = ""

[status]
report-status = false

[performance]
projection-push-down = true
2 changes: 2 additions & 0 deletions push-down-test/prepare/1_proj.sql
Original file line number Diff line number Diff line change
@@ -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');
3 changes: 3 additions & 0 deletions push-down-test/sql/projection/1_basic_1.sql
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 9 additions & 0 deletions push-down-test/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down