@@ -8506,6 +8506,59 @@ where
85068506 },
85078507 },
85088508 },
8509+ {
8510+ Name : "merge join optimization" ,
8511+ Dialect : "mysql" ,
8512+ SetUpScript : []string {
8513+ "create table t1 (i int primary key);" ,
8514+ "create table t2 (j int primary key);" ,
8515+ "insert into t1 values (1), (2), (3);" ,
8516+ "insert into t2 values (2), (3), (4);" ,
8517+
8518+ "create table t3 (i int, j int, primary key (i, j));" ,
8519+ "create table t4 (x int, y int, primary key (x, y));" ,
8520+ "insert into t3 values (1, 1), (2, 2), (3, 3);" ,
8521+ "insert into t4 values (2, 2), (3, 3), (4, 4);" ,
8522+ },
8523+ Assertions : []ScriptTestAssertion {
8524+ {
8525+ Query : "select /*+ MERGE_JOIN(t1, t2) */ * from t1 join t2 on t1.i = t2.j order by t1.i;" ,
8526+ Expected : []sql.Row {
8527+ {2 , 2 },
8528+ {3 , 3 },
8529+ },
8530+ },
8531+ {
8532+ Query : "select /*+ MERGE_JOIN(t1, t2) */ * from t1 join t2 on t1.i = t2.j order by t2.j;" ,
8533+ Expected : []sql.Row {
8534+ {2 , 2 },
8535+ {3 , 3 },
8536+ },
8537+ },
8538+ {
8539+ Query : "select /*+ MERGE_JOIN(t1, t2) */ * from t1 join t2 on t1.i = t2.j order by t1.i desc;" ,
8540+ Expected : []sql.Row {
8541+ {3 , 3 },
8542+ {2 , 2 },
8543+ },
8544+ },
8545+ {
8546+ Query : "select /*+ MERGE_JOIN(t1, t2) */ * from t1 join t2 on t1.i = t2.j order by t2.j desc;" ,
8547+ Expected : []sql.Row {
8548+ {3 , 3 },
8549+ {2 , 2 },
8550+ },
8551+ },
8552+
8553+ {
8554+ Query : "explain plan select /*+ MERGE_JOIN(t3, t4) */ * from t3 join t3 on t3.i = t4.j order by t3.i;" ,
8555+ Expected : []sql.Row {
8556+ {2 , 2 },
8557+ {3 , 3 },
8558+ },
8559+ },
8560+ },
8561+ },
85098562
85108563 // Char tests
85118564 {
0 commit comments