日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle差异收集明细,Oracle收集表的数据与统计信息差异

發布時間:2025/3/15 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle差异收集明细,Oracle收集表的数据与统计信息差异 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

有時候有這樣的煩惱,由于dmp增量到數據庫中,或是大批量數據操作后沒有收集表的統計信息,導致數據庫性能慢。要手工寫腳本檢查。

drop table gather_tcount;

create table gather_tcount

(

TABLE_NAME ?VARCHAR2(30) not null,

gather_time date,

num_rows ? ?number,

user_table_num_rows number

);

comment on table GATHER_TCOUNT

is '統計表的數據量,差距太大的需要收集統計信息';

alter table GATHER_TCOUNT

add constraint pk_gt_name_t primary key (TABLE_NAME, GATHER_TIME);

create or replace procedure p_gather_tcount

as

--統計實際表中數據量和統計信息表中數據量差異

--如果是重新統計,需要先清空gather_tcount的內容

--如果是斷點續統計,不需要清空gather_tcount的內容

v_count number;

v_temp number;

v_tabname_temp varchar2(30);

begin

for c_rows in(select s.table_name,s.num_rows

from user_tables s ?where s.table_name not like '%BAK%'

and s.table_name not like 'BK%' and

s.table_name not like '%TEMP')--過濾掉備份表

loop

v_tabname_temp := c_rows.table_name;

select count(1) into v_temp from gather_tcount where table_name = c_rows.table_name;

--如果是斷點續統計,則不需要重新count表

if(v_temp =0) then

execute immediate 'select count(1) from '||c_rows.table_name into v_count;

execute immediate 'insert into gather_tcount(TABLE_NAME,gather_time,

num_rows,user_table_num_rows) values(:1,:2,:3,:4)'

using c_rows.table_name,sysdate,v_count,c_rows.num_rows;

commit;

end if;

end loop;

exception when others then

execute immediate 'insert into gather_tcount(TABLE_NAME,gather_time,

num_rows,user_table_num_rows) values(:1,:2,:3,:4)'

using v_tabname_temp,sysdate,sqlcode,sqlcode; --錯誤的先中斷

commit;

end;

call p_gather_tcount(); select * from gather_tcount;

總結

以上是生活随笔為你收集整理的oracle差异收集明细,Oracle收集表的数据与统计信息差异的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。