面对亿级数据,MySQL硬的起来么???

在面对1亿数据时,MySQL无条件查询耗时24秒,但使用索引后查询速度达到毫秒级。对于更复杂的表结构,即使数据量大,只要利用索引,查询性能依旧出色。结论是,MySQL在处理亿级数据时,如果合理使用索引,性能表现良好。
摘要由CSDN通过智能技术生成
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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值