zoukankan      html  css  js  c++  java
  • mysql插入多条数据时间复杂度比较

    • SQL脚本

    select * from users;

    • 方式一:

    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");
    insert into users(name, age, course_id) VALUES("test",1, "0");

    • 方式二:

    insert into users(name, age, course_id) VALUES("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0"),

    ("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0"),
    ("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0"),
    ("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0"),
    ("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0"),
    ("test",1, "0"),("test",1, "0"),("test",1, "0"),("test",1, "0")


    • 时间损耗

    在插入上面24条数据的时候发现两者的执行效率相差比较大(近10倍的)

      方式一:

      方式二:


    •  扩展:

    那么jdbc中的批处理的内部实现是不是采用方式二的形式来实现呢?感兴趣的朋友可以查看下该部分的源码...

      

  • 相关阅读:
    PostgreSQL 模式(SCHEMA)
    PostgreSQL学习---模式schema
    psql 工具详细使用介绍
    CentOS 下 VNC Server 的配置与使用
    如何处理/boot/efi/EFI/cento from install of fwupdate-efi
    uGUI练习(二) Animate UI
    uGUI练习(一) Anchor
    uGUI练习 开篇
    Fix "Missing Scripts"
    用uGUI开发自定义Toggle Slider控件
  • 原文地址:https://www.cnblogs.com/imaikce/p/6141032.html
Copyright © 2011-2022 走看看