91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Oracle優化:千萬級大表邏輯判斷的累贅

發布時間:2020-10-26 02:44:56 來源:網絡 閱讀:1695 作者:dbapower 欄目:關系型數據庫

insert into pntmall_point_detail(PNTMALL_PNT_ID,PNTMALL_PNT_DT,PNTMALL_VALIDITY,PNTMALL_LASTUPDATEDT,

                           PNTMALL_RPTPNT_ID,PNTMALL_HAIERUID,

                   PNTMALL_OPTYPE_ID,PNTMALL_OPTYPE_DESC,

                         PNTMALL_NUM,PNTMALL_EXPDT,HPT_REDEMPT_POINT,

                         HPT_LEFT_POINT,HPT_FULLREDEMPT_STATUS)

  SELECT PNTMALL_PNT_ID,PNTMALL_PNT_DT,PNTMALL_VALIDITY,PNTMALL_LASTUPDATEDT,

                           PNTMALL_RPTPNT_ID,PNTMALL_HAIERUID,

                   PNTMALL_OPTYPE_ID,PNTMALL_OPTYPE_DESC,

                         PNTMALL_NUM,PNTMALL_EXPDT,0 as HPT_REDEMPT_POINT,PNTMALL_NUM,0

    FROM pntmall_point_detail_tmp a

          WHERE NOT EXISTS (SELECT b.PNTMALL_PNT_ID
            FROM pntmall_point_detail b
           WHERE a.PNTMALL_PNT_ID = b.PNTMALL_PNT_ID);



PNTMALL_POINT_DETAIL包含3800萬條數據,cost 6 hours。


優化后

 

delete from pntmall_point_detail_tmp a where exists (select 1 from pntmall_point_detail b where a.PNTMALL_PNT_ID = b.PNTMALL_PNT_ID);


insert into pntmall_point_detail(PNTMALL_PNT_ID,PNTMALL_PNT_DT,PNTMALL_VALIDITY,PNTMALL_LASTUPDATEDT,

                           PNTMALL_RPTPNT_ID,PNTMALL_HAIERUID,

                   PNTMALL_OPTYPE_ID,PNTMALL_OPTYPE_DESC,

                         PNTMALL_NUM,PNTMALL_EXPDT,HPT_REDEMPT_POINT,

                         HPT_LEFT_POINT,HPT_FULLREDEMPT_STATUS)

  SELECT PNTMALL_PNT_ID,PNTMALL_PNT_DT,PNTMALL_VALIDITY,PNTMALL_LASTUPDATEDT,

                           PNTMALL_RPTPNT_ID,PNTMALL_HAIERUID,

                   PNTMALL_OPTYPE_ID,PNTMALL_OPTYPE_DESC,

                         PNTMALL_NUM,PNTMALL_EXPDT,0 as HPT_REDEMPT_POINT,PNTMALL_NUM,0

    FROM pntmall_point_detail_tmp a;



cost 5 minutes。


其實還可以進一步優化

drop indexBER.INDEX_POD_PNTMALL_HAIERUID;

drop indexBER.PNTMALL_POINT_ID_HAIERUID;

delete from pntmall_point_detail_tmp a where exists (select 1from pntmall_point_detailb where a.PNTMALL_PNT_ID =b.PNTMALL_PNT_ID);

insert/*+append*/into pntmall_point_detail(PNTMALL_PNT_ID,PNTMALL_PNT_DT,PNTMALL_VALIDITY,PNTMALL_LASTUPDATEDT,

                           PNTMALL_RPTPNT_ID,PNTMALL_HAIERUID,

                   PNTMALL_OPTYPE_ID,PNTMALL_OPTYPE_DESC,

                         PNTMALL_NUM,PNTMALL_EXPDT,HPT_REDEMPT_POINT,

                         HPT_LEFT_POINT,HPT_FULLREDEMPT_STATUS)

  SELECT PNTMALL_PNT_ID,PNTMALL_PNT_DT,PNTMALL_VALIDITY,PNTMALL_LASTUPDATEDT,

                           PNTMALL_RPTPNT_ID,PNTMALL_HAIERUID,

                   PNTMALL_OPTYPE_ID,PNTMALL_OPTYPE_DESC,

                         PNTMALL_NUM,PNTMALL_EXPDT,0 as HPT_REDEMPT_POINT,PNTMALL_NUM,0

    FROM pntmall_point_detail_tmp a; 

commit;

WHERE NOT EXISTS (SELECT b.PNTMALL_PNT_ID

            FROMpntmall_point_detail b

           WHEREa.PNTMALL_PNT_ID = b.PNTMALL_PNT_ID);


create index BER.INDEX_POD_PNTMALL_HAIERUIDon BER.PNTMALL_POINT_DETAIL (PNTMALL_HAIERUID) online nologing;

create unique indexBER.PNTMALL_POINT_ID_HAIERUID on BER.PNTMALL_POINT_DETAIL (PNTMALL_PNT_ID) online nologing;



總體優化思路,不要在insert中加入過多的判斷語句,刪索引,append,重建索引,如果是歸檔模式,alter table nologing;append 只適用于insert select 這種方式,而且insert后要加commit,否則無法進行其他DML操作。


實測 append 1600萬條數據,cost 8s

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

会昌县| 潼南县| 根河市| 九龙县| 珲春市| 弋阳县| 永年县| 紫阳县| 朝阳县| 抚顺县| 云阳县| 同仁县| 东辽县| 丹江口市| 巴马| 利川市| 登封市| 德阳市| 江达县| 浑源县| 二连浩特市| 含山县| 当阳市| 罗定市| 蒙城县| 右玉县| 灵寿县| 崇信县| 保山市| 周口市| 池州市| 昔阳县| 丘北县| 长乐市| 金昌市| 平昌县| 呼和浩特市| 扎赉特旗| 芦山县| 多伦县| 马尔康县|