Last active
February 23, 2021 13:24
-
-
Save juzi214032/17c0f7a51bd8d1c0ab39fa203f930c60 to your computer and use it in GitHub Desktop.
MySQL Index Merge 测试
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.sql.Connection; | |
import java.sql.DriverManager; | |
import java.sql.SQLException; | |
import java.sql.Statement; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
/** | |
* 测试 merge index | |
* | |
* @author 桔子 | |
* @since 2021/2/17 19:44 | |
*/ | |
public class TestMergeIndex { | |
public static final String URL = "jdbc:mysql://localhost:3306/test"; | |
public static final String USER = "root"; | |
public static final String PASSWORD = "root"; | |
public static void main(String[] args) throws ClassNotFoundException { | |
Class.forName("com.mysql.cj.jdbc.Driver"); | |
ExecutorService executorService = Executors.newFixedThreadPool(300); | |
for (int i = 1; i <= 100; i++) { | |
final int index = i; | |
executorService.submit(() -> { | |
try (Connection conn = DriverManager.getConnection(URL, USER, PASSWORD)) { | |
for (int j = 0; j < 10000; j++) { | |
conn.createStatement().executeUpdate("update student set name = \"xx\" WHERE class_id=" + index + " and teacher_id = " + index + ";"); | |
} | |
} catch (SQLException e) { | |
e.printStackTrace(); | |
} | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment