1亿数据查询速度
创建表test1
test1表,结构比较简单,2个字段,都有索引。
DROP TABLE IF EXISTS test1;
CREATE TABLE test1(
id int PRIMARY KEY COMMENT '编号' auto_increment,
order_num bigint comment '订单号'
)COMMENT '用户表';
/*order_num分别加索引*/
create index idx1 on test1(order_num);
插入1亿数据
@Test
public void test1() throws SQLException, ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/testdb?characterEncoding=UTF-8",
"root",
"密码");
StringBuilder sql = new StringBuilder("insert into test1(order_num) values ");
for (int i = 1; i <= 100000000; i++) {
sql.append(String.format("(%s),", i