偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

一次去重 80w 數(shù)據(jù)時夯死臨時處理實例

數(shù)據(jù)庫 Oracle
近日,博主在對一張百萬數(shù)據(jù)的業(yè)務表進行去重時,去重操作竟然夯住了。下面就讓我們跟隨博主來簡單回憶一下。

近日,在對一張百萬數(shù)據(jù)的業(yè)務表進行去重時,去重操作竟然夯住了。下面就來簡單回憶一下。

1、查詢業(yè)務表數(shù)據(jù)量,查看到總共有200多w條

SQL> select count(*) from tb_bj_banker_etl;

2552381

2、查詢表內應該去掉的重復數(shù)據(jù)量,共80多w條

SQL> select count(*) from tb_bj_banker_etl where (id) in (select id from tb_bj_banker_etl group by id having count(*)>1) and rowid not in(select max(rowid) from tb_bj_banker_etl group by id having count(*)>1);

830099

3、于是,在晚上下班前,執(zhí)行了下面的語句腳本,為了去重

SQL> delete from tb_bj_banker_etl where(id) in (select id from tb_bj_banker_etl group by id having count(*)>1) and rowid not in(select max(rowid) from tb_bj_banker_etl group by id having count(*)>1);

SQL> commit;

4、第二天,到達現(xiàn)場時,發(fā)現(xiàn)PL/SQL Developer工具中昨天晚上執(zhí)行的語句仍在執(zhí)行中

首先察覺,80多w的去重數(shù)據(jù)跑了一個晚上也沒跑完?這肯定是哪里出了問題?

懷疑有鎖表。

于是查詢是否有鎖表的用戶。

 

  1. SELECT 
  2.   A.OWNER,                        --OBJECT所屬用戶 
  3.   A.OBJECT_NAME,                  --OBJECT名稱 
  4.   B.XIDUSN, 
  5.   B.XIDSLOT, 
  6.   B.XIDSQN, 
  7.   B.SESSION_ID,                   --鎖表用戶的session 
  8.   B.ORACLE_USERNAME,              --鎖表用戶的Oracle用戶名 
  9.   B.OS_USER_NAME,                 --鎖表用戶的操作系統(tǒng)登陸用戶名 
  10.   B.PROCESS, 
  11.   B.LOCKED_MODE,  
  12.   C.MACHINE,                      --鎖表用戶的計算機名稱 
  13.   C.STATUS,                       --鎖表狀態(tài) 
  14.   C.SERVER, 
  15.   C.SID, 
  16.   C.SERIAL#, 
  17.   C.PROGRAM                       --鎖表用戶所用的數(shù)據(jù)庫管理工具 
  18. FROM 
  19.   ALL_OBJECTS A, 
  20.   V$LOCKED_OBJECT B, 
  21.   SYS.GV_$SESSION C  
  22. WHERE 
  23.   A.OBJECT_ID = B.OBJECT_ID 
  24.   AND B.PROCESS = C.PROCESS 
  25. ORDER BY 1,2 

 

在下面結果中可以看到,鎖表的只是去重語句的發(fā)起會話,并沒有其它用戶造成鎖表,這說明語句仍然在執(zhí)行嘛?帶著疑問,開始嘗試解決。

1 BJHYL tb_bj_banker_ETL 15 18 9000 913 BJHYL Administrator 4036:972 3 WORKGROUP\BACKDB ACTIVE DEDICATED 913 3381 plsqldev.exe

2 BJHYL tb_bj_banker_ETL 15 18 9000 913 BJHYL Administrator 4036:972 3 WORKGROUP\BACKDB INACTIVE DEDICATED 649 41791 plsqldev.exe

3 BJHYL tb_bj_banker_ETL 15 18 9000 913 BJHYL Administrator 4036:972 3 WORKGROUP\BACKDB INACTIVE DEDICATED 817 27777 plsqldev.exe

4 BJHYL tb_bj_banker_ETL 15 18 9000 913 BJHYL Administrator 4036:972 3 WORKGROUP\BACKDB INACTIVE DEDICATED 841 1981 plsqldev.exe

5、采用分批次,解決去重夯住問題

由于直接去重無法順利進行,于是想到了分批次去重的方法,試一下。

 

  1. ***次: 
  2. delete from tb_bj_banker_etl where(id) in (select id from tb_bj_banker_etl  group by id  having count(*)>1) and rowid not in(select max(rowid) from tb_bj_banker_etl group by id having count(*)>1) and rownum<=100000; 
  3. commit
  4.  
  5. 第二次: 
  6. delete from tb_bj_banker_etl where(id) in (select id from tb_bj_banker_etl  group by id  having count(*)>1) and rowid not in(select max(rowid) from tb_bj_banker_etl group by id having count(*)>1) and rownum<=100000; 
  7. commit
  8.  
  9. 。。。。。。。 
  10. 。。。。。。。 
  11. 。。。。。。。 
  12.  
  13. 第八次: 
  14. delete from tb_bj_banker_etl where(id) in (select id from tb_bj_banker_etl  group by id  having count(*)>1) and rowid not in(select max(rowid) from tb_bj_banker_etl group by id having count(*)>1); 
  15. commit

 

結果:通過將80多萬數(shù)據(jù)劃分成以10w數(shù)據(jù)為單次進行去重操作,總共用時140多秒,完成了去重80萬數(shù)據(jù)的目的。但為何直接處理出現(xiàn)夯死情況,有待后續(xù)跟蹤分析。

博文出處:http://blog.csdn.net/huangyanlong/article/details/46041735
 

責任編輯:Ophira 來源: 個人博客
相關推薦

2011-08-18 17:36:04

愛普生噴墨打印機

2020-11-16 07:19:17

線上函數(shù)性能

2012-06-06 14:56:29

愛普生噴墨打印機

2018-09-26 17:12:16

Chrome瀏覽器cookie

2020-08-19 11:02:39

系統(tǒng)ssh登錄

2009-05-22 17:05:52

2023-11-06 07:45:42

單據(jù)圖片處理

2021-03-18 23:47:18

MySQLselect索引

2020-10-27 10:35:38

優(yōu)化代碼項目

2021-02-01 09:00:34

Ceph octopu集群運維

2011-06-28 10:41:50

DBA

2021-12-27 10:08:16

Python編程語言

2020-10-24 13:50:59

Python編程語言

2023-09-07 13:32:00

MySQL數(shù)據(jù)庫

2010-09-07 15:31:20

SQL語句事務

2022-09-03 18:29:49

開發(fā)技術

2009-11-06 10:49:53

2022-01-10 09:31:17

Jetty異步處理seriesbaid

2022-04-07 07:30:47

InnoDBMySQL數(shù)據(jù)

2022-07-27 10:30:49

后端前端
點贊
收藏

51CTO技術棧公眾號