Skip to content

Instantly share code, notes, and snippets.

@juzi214032
Last active February 23, 2021 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juzi214032/17c0f7a51bd8d1c0ab39fa203f930c60 to your computer and use it in GitHub Desktop.
Save juzi214032/17c0f7a51bd8d1c0ab39fa203f930c60 to your computer and use it in GitHub Desktop.
MySQL Index Merge 测试
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