zoukankan      html  css  js  c++  java
  • Oracle 插入数据效率对比

    oracle插入数据有多种方式:

    将从多个表中查出来的数据插入到临时表中

    数据行数 5189597

    1.传统方式:直接将数据插入到表中

     1 insert into LLB_BASIC_USER_D_TEMP_TEST
     2     select t.serv_id,
     3            t.phone_id,
     4            a1.loc_imei t,
     5            region_code,
     6            t.county_code,
     7            t.payment_mode_cd,
     8            t.plan_id,
     9            t.productflux,
    10            t.allflux,
    11            t.netuse / 1024 / 1024,
    12            t.lj_sn_roam_flux / 1024 / 1024,
    13            t.lj_sj_roam_flux / 1024 / 1024,
    14            a.llb_jcb,
    15            a.llb_jcb_flux,
    16            a.llb_bd,
    17            a.llb_bd_flux,
    18            a.llb_gn,
    19            a.llb_gn_flux,
    20            a.llb_xs,
    21            a.llb_xs_flux,
    22            a.llb_xy,
    23            a.llb_xy_flux
    24       From llb_basic_temp1           t,
    25            LLB_BASIC_PACK_ORDER_info a,
    26            llb_phone_imei            a1
    27      where t.phone_id = a.phone_id(+)
    28        and t.phone_id = a1.accs_nbr(+);
    View Code


    耗时41秒

    2.用Hint 提示减少操作时间

     1 insert /*+ Append*/ into LLB_BASIC_USER_D_TEMP_TEST
     2     select t.serv_id,
     3            t.phone_id,
     4            a1.loc_imei t,
     5            region_code,
     6            t.county_code,
     7            t.payment_mode_cd,
     8            t.plan_id,
     9            t.productflux,
    10            t.allflux,
    11            t.netuse / 1024 / 1024,
    12            t.lj_sn_roam_flux / 1024 / 1024,
    13            t.lj_sj_roam_flux / 1024 / 1024,
    14            a.llb_jcb,
    15            a.llb_jcb_flux,
    16            a.llb_bd,
    17            a.llb_bd_flux,
    18            a.llb_gn,
    19            a.llb_gn_flux,
    20            a.llb_xs,
    21            a.llb_xs_flux,
    22            a.llb_xy,
    23            a.llb_xy_flux
    24       From llb_basic_temp1           t,
    25            LLB_BASIC_PACK_ORDER_info a,
    26            llb_phone_imei            a1
    27      where t.phone_id = a.phone_id(+)
    28        and t.phone_id = a1.accs_nbr(+);
    View Code

    耗时33秒

    3.采用不写日志及使用Hint提示减少数据操作的时间

    alter table [table_name] nologging;

    alter table [table_name] logging;

    耗时32秒

    对比一下,使用hint提示是时间最快的方式,但是append会锁表,再插入期间不能使用该表。

  • 相关阅读:
    Redundant Paths 分离的路径(边双连通分量)
    bzoj2208 [Jsoi2010] 连通数(tarjan点双连通分量 // dfs)
    [bzoj3331] [BeiJing2013] 压力(tarjan 点双连通分量)
    [ BZOJ1123 ] BLO(tarjan点双连通分量)
    bitset小总结
    牛客328B Rabbit的工作(1)
    # Codeforces Round #529(Div.3)个人题解
    HDU5957 Query on a graph(拓扑找环,BFS序,线段树更新,分类讨论)
    istringstream()函数的用法
    codeforces 1077F1
  • 原文地址:https://www.cnblogs.com/SUN-PH/p/3988786.html
Copyright © 2011-2022 走看看