From b948875f322c8d142ff2dce581bfed8513bbb62f Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Thu, 2 Jan 2025 18:28:01 +0530 Subject: [PATCH] test: added join query with simple route Signed-off-by: Harshit Gangal --- .../endtoend/preparestmt/benchmark_test.go | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/go/test/endtoend/preparestmt/benchmark_test.go b/go/test/endtoend/preparestmt/benchmark_test.go index 925068f17cc..fcf10a6948a 100644 --- a/go/test/endtoend/preparestmt/benchmark_test.go +++ b/go/test/endtoend/preparestmt/benchmark_test.go @@ -39,6 +39,22 @@ func BenchmarkPreparedStmt(b *testing.B) { updateStmt := `update sks.t1 set is_active = ? where id = ?` deleteStmt := `delete from sks.t1 where is_active = ? and age = ?` + joinStmt := `SELECT + user.id AS user_id +FROM + sks.t1 AS user +LEFT JOIN + sks.t1 AS parent ON user.id = parent.id AND parent.age = ? +LEFT JOIN + sks.t1 AS manager ON user.id = manager.id AND manager.is_active = ? +LEFT JOIN + sks.t1 AS child ON user.id = child.id +WHERE + user.is_active = ? + AND user.id = ? + AND parent.id = ? + AND manager.id = ?` + iStmt, err := dbo.Prepare(insertStmt) if err != nil { b.Fatal(err) @@ -73,6 +89,26 @@ func BenchmarkPreparedStmt(b *testing.B) { } }) + jStmt, err := dbo.Prepare(joinStmt) + if err != nil { + b.Fatal(err) + } + defer jStmt.Close() + + b.Run("Join Select:Simple Route", func(b *testing.B) { + b.ResetTimer() + for i := 0; i < b.N; i++ { + age := rand.IntN(80) + active := rand.IntN(2) + id := rand.IntN(2000) + r, err := jStmt.Query(age, active, active, id, id, id) + if err != nil { + b.Fatal(err) + } + r.Close() + } + }) + uStmt, err := dbo.Prepare(updateStmt) if err != nil { b.Fatal(err)