[20231212]impdp content=metadata_only locks the stats.txt
[20231212]impdp content=metadata_only locks the stats.txt
--//以前的測試[20170917]impdp content=metadata_only locks the stats.txt,在12.1.0.1.0 for windows下不存在這個問題.
--//最近在最佳化一個專案時遇到的問題,全部應用表的統計資訊都是lock的,再分析時必須加入force=>true,最後我先寫指令碼unlock.
--//在我記憶裡這個問題在於開始匯入是選擇CONTENT=METADATA_ONLY引起的,在12c重複測試塊看看,加強記憶.
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.2.0.1.0 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
create table demo as select * from dual;
create index demo on demo(dummy);
exec dbms_stats.gather_table_stats(user,'DEMO');
CREATE OR REPLACE DIRECTORY TMP_EXPDP AS 'D:\tmp\expdp\';
GRANT READ, WRITE ON DIRECTORY TMP_EXPDP TO SCOTT;
GRANT EXECUTE, READ, WRITE ON DIRECTORY TMP_EXPDP TO SYSTEM WITH GRANT OPTION;
SCOTT@test01p> select count(*) from DEMO;
COUNT(*)
----------
1
SCOTT@test01p> select object_name,object_type from dba_objects where owner=user and object_name='DEMO';
OBJECT_NAME OBJECT_TYPE
-------------------- --------------------
DEMO TABLE
DEMO INDEX
SCOTT@test01p> select owner,table_name,last_analyzed,stattype_locked,num_rows from dba_tab_statistics where owner=user and table_name='DEMO';
OWNER TABLE_NAME LAST_ANALYZED STATT NUM_ROWS
-------------------- -------------------- ------------------- ----- ----------
SCOTT DEMO 2023-12-11 20:54:38 1
SCOTT@test01p> select owner,table_name,last_analyzed,stattype_locked,num_rows from dba_tab_statistics where owner=user and table_name='DEMO';
OWNER TABLE_NAME LAST_ANALYZED STATT NUM_ROWS
------ ---------- ------------------- ----- ----------
SCOTT DEMO 2017-09-17 22:15:03 1
2.匯出:
d:\tmp\expdp>expdp scott/btbtms@test01p DIRECTORY=TMP_EXPDP DUMPFILE=demo.dmp tables=demo
Export: Release 12.2.0.1.0 - Production on Mon Dec 11 20:56:40 2023
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Starting "SCOTT"."SYS_EXPORT_TABLE_01": scott/a*****@test01p DIRECTORY=TMP_EXPDP DUMPFILE=demo.dmp tables=demo
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
. . exported "SCOTT"."DEMO" 5.054 KB 1 rows
Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
D:\TMP\EXPDP\DEMO.DMP
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at Mon Dec 11 21:02:32 2023 elapsed 0 00:05:30
--//機器記憶體太小很慢..
SCOTT@test01p> alter table demo rename to demo1;
Table altered.
SCOTT@test01p> alter index demo rename to i_demo1_dummy;
Index altered.
3.匯入:
d:\tmp\expdp>impdp scott/btbtms@test01p DIRECTORY=TMP_EXPDP DUMPFILE=demo.dmp tables=demo CONTENT=METADATA_ONLY
Import: Release 12.2.0.1.0 - Production on Mon Dec 11 21:04:13 2023
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Master table "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_TABLE_01": scott/a*****@test01p DIRECTORY=TMP_EXPDP DUMPFILE=demo.dmp tables=demo CONTENT=METADATA_ONLY
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at Mon Dec 11 21:05:05 2023 elapsed 0 00:00:46
SELECT table_name
,global_stats
,user_stats
,stattype_locked
,stale_stats
,last_analyzed
FROM DBA_TAB_STATISTICS
WHERE owner = USER AND table_name IN ('DEMO', 'DEMO1');
TABLE_NAME GLO USE STATT STA LAST_ANALYZED
-------------------- --- --- ----- --- -------------------
DEMO1 YES NO NO 2023-12-11 20:54:38
DEMO YES NO ALL NO 2023-12-11 20:54:38
---//可以發現這樣匯入會導致表demo的統計資訊被鎖住.
SCOTT@test01p> exec dbms_stats.gather_table_stats(user,'DEMO');
BEGIN dbms_stats.gather_table_stats(user,'DEMO'); END;
*
ERROR at line 1:
ORA-20005: object statistics are locked (stattype = ALL)
ORA-06512: at "SYS.DBMS_STATS", line 36873
ORA-06512: at "SYS.DBMS_STATS", line 36507
ORA-06512: at "SYS.DBMS_STATS", line 8582
ORA-06512: at "SYS.DBMS_STATS", line 9461
ORA-06512: at "SYS.DBMS_STATS", line 35836
ORA-06512: at "SYS.DBMS_STATS", line 36716
ORA-06512: at line 1
--//無法正常的分析表.
來自 “ ITPUB部落格 ” ,連結:https://blog.itpub.net/267265/viewspace-3000030/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- PostgreSQL DBA(158) - Locks(tuple locks)SQL
- PostgreSQL DBA(85) - Locks(lightweight locks)SQL
- PostgreSQL DBA(76) - Locks(Advisory Locks):What You Should KnowSQL
- PostgreSQL DBA(78) - Locks(When Postgres blocks 7 tips for dealing with locks)SQLBloC
- PostgreSQL 原始碼解讀(238)- Locks(OOM & max_locks_per_transaction)SQL原始碼OOM
- PostgreSQL 原始碼解讀(239)- Locks(OOM & max_locks_per_transaction#2)SQL原始碼OOM
- Oracle OCP(57):IMPDPOracle
- SCSS @contentCSS
- CSS contentCSS
- PostgreSQL DBA(77) - Locks(Lock Monitoring)SQL
- PostgreSQL DBA(81) - Locks(FOR UPDATE SKIP LOCKED)SQL
- CSS content character ACSS
- Content Security Policy
- android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetAndroidXMLIDE
- PostgreSQL 原始碼解讀(219)- Locks(Overview)SQL原始碼View
- PostgreSQL DBA(79) - Locks(pg_blocking_pids)SQLBloC
- Android中Content ProviderAndroidIDE
- Android Content Provider SecurityAndroidIDE
- file_get_content
- CSS align-contentCSS
- CSS justify-contentCSS
- expdp/impdp變慢 (Doc ID 2469587.1)
- [20200620]expdp impdp exclude引數.txt
- 【Data Pump】expdp/impdp Job基本管理
- oracle資料庫的impdp,expdpOracle資料庫
- IMPDP分割槽表注意事項
- PostgreSQL 原始碼解讀(220)- Locks(LOCK Struct)SQL原始碼Struct
- PostgreSQL 原始碼解讀(221)- Locks(PROCLOCK Struct)SQL原始碼Struct
- [20200620]IMPDP TRANSFORM引數再探究.txtORM
- expdp/impdp 詳細引數解釋
- Oracle 12.1.0.2 impdp匯入慢診斷Oracle
- [Bash] Append the content at the beginning of the fileAPP
- read content in a text file in pythonPython
- PostgreSQL 原始碼解讀(223)- Locks(Fast Path Locking)SQL原始碼AST
- PostgreSQL 原始碼解讀(224)- Locks(The Deadlock Detection Algorithm)SQL原始碼Go
- PostgreSQL DBA(75) - Locks(locktype:transactionid):What You Should KnowSQL
- PostgreSQL DBA(157) - pgAdmin(OOM & max_locks_per_transaction )SQLOOM
- impdp導致主鍵索引的變化索引