有两个数据库服务器:S1 S2   现在S1上的A表添加一个createtime字段。并要求对其插入值。
   值来源于服务器S2上的B表(含有createtime字段),两个表的关联字段为contentid!   要求效率要高点!
  
   问题我自己已经解决了!但效率很差!
   

解决方案 »

  1.   

    貌似可以用merge into 
    merge into A
    using B@Url
    on (a.contentid = b.contentid)
    when matched then
      update set a.createtime = b.createtime
    when not matched then
      insert values (b.contentid, b.createtime)
      

  2.   


    ----没测试
    merge into A 
    using B@Url 
    on (a.contentid = b.contentid) 
    when matched then 
      update set a.createtime = b.createtime 
    when not matched then 
      insert values (b.contentid, b.createtime) 
      

  3.   

    .如果表上有索引,使用nologging选项不能明显提高速度,也不能   
            减小重做日志,因为维护索引需要产生大量的重做日志.   
        
        2.   beckhamboo和我提出的方案都是可行的,只是角度不同而已。   
              对表进行分区是处理大数据的好方案之一。单纯从sql的角度   
              来看问题,虽然能解决目前的问题,但是随着表的数据量的增长,   
              肯定会引发新的问题。因此,我个人认为解决诸如大数据量的更新,   
              删除等比较现实的问题时,先优化存储结构是必须要考虑的。   
        
        3.   "写from的时候,数据量大的表要放在前,小的放在后"这条原则     
              只是在优化器模式为rbo时有效,如果为cbo,它会自己评估查询代价.