From 41871e0c8e5e4b0601dd94d09342bc0317cbb8cb Mon Sep 17 00:00:00 2001 From: ti-srebot <66930949+ti-srebot@users.noreply.github.com> Date: Tue, 20 Apr 2021 17:21:53 +0800 Subject: [PATCH] executor: accelerate TestUpdateScanningHandles and TestIssue20658 and TestParallelStreamAggGroupConcat (#24132) (#24145) --- executor/aggregate_test.go | 24 ++++++++++++++++++++---- executor/union_scan_test.go | 12 ++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/executor/aggregate_test.go b/executor/aggregate_test.go index 18ace69b8e976..3b6a591ff6d25 100644 --- a/executor/aggregate_test.go +++ b/executor/aggregate_test.go @@ -1236,10 +1236,18 @@ func (s *testSuiteAgg) TestParallelStreamAggGroupConcat(c *C) { tk.MustExec("use test;") tk.MustExec("drop table if exists t;") tk.MustExec("CREATE TABLE t(a bigint, b bigint);") + tk.MustExec("set tidb_init_chunk_size=1;") + tk.MustExec("set tidb_max_chunk_size=32;") - for i := 0; i < 10000; i++ { - tk.MustExec("insert into t values(?, ?);", rand.Intn(100), rand.Intn(100)) + var insertSQL string + for i := 0; i < 1000; i++ { + if i == 0 { + insertSQL += fmt.Sprintf("(%d, %d)", rand.Intn(100), rand.Intn(100)) + } else { + insertSQL += fmt.Sprintf(",(%d, %d)", rand.Intn(100), rand.Intn(100)) + } } + tk.MustExec(fmt.Sprintf("insert into t values %s;", insertSQL)) sql := "select /*+ stream_agg() */ group_concat(a, b) from t group by b;" concurrencies := []int{1, 2, 4, 8} @@ -1283,9 +1291,17 @@ func (s *testSuiteAgg) TestIssue20658(c *C) { tk.MustExec("drop table if exists t;") tk.MustExec("CREATE TABLE t(a bigint, b bigint);") - for i := 0; i < 10000; i++ { - tk.MustExec("insert into t values (?, ?);", rand.Intn(100), rand.Intn(100)) + tk.MustExec("set tidb_init_chunk_size=1;") + tk.MustExec("set tidb_max_chunk_size=32;") + var insertSQL string + for i := 0; i < 1000; i++ { + if i == 0 { + insertSQL += fmt.Sprintf("(%d, %d)", rand.Intn(100), rand.Intn(100)) + } else { + insertSQL += fmt.Sprintf(",(%d, %d)", rand.Intn(100), rand.Intn(100)) + } } + tk.MustExec(fmt.Sprintf("insert into t values %s;", insertSQL)) concurrencies := []int{1, 2, 4, 8} for _, sql := range sqls { diff --git a/executor/union_scan_test.go b/executor/union_scan_test.go index 48a5768a10be8..31f9cc6b98670 100644 --- a/executor/union_scan_test.go +++ b/executor/union_scan_test.go @@ -14,6 +14,8 @@ package executor_test import ( + "fmt" + . "github.com/pingcap/check" "github.com/pingcap/tidb/util/testkit" ) @@ -339,9 +341,15 @@ func (s *testSuite7) TestUpdateScanningHandles(c *C) { tk.MustExec("drop table if exists t;") tk.MustExec("create table t(a int primary key, b int);") tk.MustExec("begin") - for i := 2; i < 100000; i++ { - tk.MustExec("insert into t values (?, ?)", i, i) + var insertSQL string + for i := 2; i < 10000; i++ { + if i == 2 { + insertSQL += fmt.Sprintf("(%d, %d)", i, i) + } else { + insertSQL += fmt.Sprintf(",(%d, %d)", i, i) + } } + tk.MustExec(fmt.Sprintf("insert into t values %s;", insertSQL)) tk.MustExec("commit;") tk.MustExec("set tidb_distsql_scan_concurrency = 1;")