2011-06-14 3 views
2

나는 필요한 것보다 더 많은 공간을 차지하고있는 것처럼 보이는 테이블을 가지고 있습니다. 데이터를 새 테이블에 복사하고 새 테이블과 이전 테이블의 이름을 바꾸어 바꾼 것이 좋습니다. 현재 테이블이 실제로 조각화되어 있는지 어떻게 확인할 수 있습니까? 동일한 데이터가 포함 된 신선한 테이블의 새 크기를 계산하거나 계산하려면 어떻게합니까?Oracle의 테이블이 조각화되어 있는지 어떻게 알 수 있습니까?

+0

모든 색인, 트리거, 제약 조건 등으로 복사하고 이름을 바꾸면 이전 버전과 계속 연결됩니다. – gpeche

+0

@stuart 다른 사람이 대답을 얻은 경우 대답을 수락하십시오. – amod

답변

2

연결 svrmgrl를 사용하여이 스크립트를 실행 해보십시오 .

select table_name, round((num_rows * avg_row_len) /(8*1024)), blocks 
from user_tables where .... 

이 공간은 나중에 삽입 할 때 사용되므로 반드시 문제는 아닙니다. 대용량 아카이브 또는 데이터 삭제를 수행 한 경우 은 공간을 회수해야합니다 (특히 전체 테이블 스캔을 많이 수행하는 경우). [참고 : 기본값 인 8k 블록을 가정했습니다.]

CREATE/DROP/RENAME을 수행하면 인덱스, 제약 조건, 부여 (사용하는 경우 테이블 주석)가 손실됩니다.

당신은 현재 테이블 스페이스 (USER_SEGMENTS의 모습을) 확인하고 ALTER TABLE tablename MOVE current_tablespace;

당신은 aftwards 너무 인덱스를 다시 작성해야합니다 일을 더 낫다. USER_INDEXES에서 선택하여 수행하십시오 ALTER INDEX ... REBUILD;

0

- 행 데이터의 양이 시사하는 것보다 테이블이 많은 더 많은 블록이있는 경우 통계가 최신이 괜찮은 표시를 제공해야하는 경우 DBA로

set serveroutput on 

DECLARE 
    libcac NUMBER (6, 2); 
    rowcac NUMBER (6, 2); 
    bufcac NUMBER (6, 2); 
    redlog NUMBER (6, 2); 
    spsize NUMBER; 
    blkbuf NUMBER; 
    logbuf NUMBER; 
BEGIN 
    SELECT VALUE 
    INTO redlog 
    FROM v$sysstat 
    WHERE name = 'redo log space requests'; 

    SELECT 100 * (SUM (pins) - SUM (reloads))/SUM (pins) 
    INTO libcac 
    FROM v$librarycache; 

    SELECT 100 * (SUM (gets) - SUM (getmisses))/SUM (gets) 
    INTO rowcac 
    FROM v$rowcache; 

    SELECT 100 * (cur.VALUE con.VALUE - phys.VALUE)/(cur.VALUE con.VALUE) 
into bufcac 
from v$sysstat cur,v$sysstat con,v$sysstat phys, 
v$statname ncu,v$statname nco,v$statname nph 
where cur.statistic# = ncu.statistic# and 
ncu.name = 'db block gets' and 
con.statistic# = nco.statistic# and 
nco.name = 'consistent gets' and 
phys.statistic# = nph.statistic# and 
nph.name = 'physical reads'; 

select VALUE 
into spsize 
from v$parameter 
where name = 'shared_pool_size'; 

select VALUE 
into blkbuf 
from v$parameter 
where name = 'db_block_buffers'; 

select VALUE 
into logbuf 
from v$parameter 
where name = 'log_buffer'; 

DBMS_OUTPUT.put_line('> SGA CACHE STATISTICS'); 
DBMS_OUTPUT.put_line('> ********************'); 
DBMS_OUTPUT.put_line('> SQL Cache Hit rate = '||libcac); 
DBMS_OUTPUT.put_line('> Dict Cache Hit rate = '||rowcac); 
DBMS_OUTPUT.put_line('> Buffer Cache Hit rate = '||bufcac); 
DBMS_OUTPUT.put_line('> Redo Log space requests = '||redlog); 
DBMS_OUTPUT.put_line('> '); 
DBMS_OUTPUT.put_line('> INIT.ORA SETTING'); 
DBMS_OUTPUT.put_line('> ****************'); 
DBMS_OUTPUT.put_line('> Shared Pool Size = '||spsize||' Bytes'); 
DBMS_OUTPUT.put_line('> DB Block Buffer = '||blkbuf||' Blocks'); 
DBMS_OUTPUT.put_line('> Log Buffer = '||logbuf||' Bytes'); 
DBMS_OUTPUT.put_line('> '); 

if libcac < 99 
then 
DBMS_OUTPUT.put_line('*** HINT: Library Cache too low! Increase the Shared Pool Size.'); 
end if; 

if rowcac < 85 
then 
DBMS_OUTPUT.put_line('*** HINT: Row Cache too low! Increase the Shared Pool Size.'); 
end if; 

if bufcac < 90 
then 
DBMS_OUTPUT.put_line('*** HINT: Buffer Cache too low! Increase the DB Block Buffer value.'); 
end if; 

if redlog > 100 
then 
DBMS_OUTPUT.put_line('*** HINT: Log Buffer value is rather low!'); 
end if; 

end; 
/
+1

svrmgrl? 오라클 8i입니다. – DCookie

+0

미래의 파트 IV로 돌아 가기 :-) 실례지만, 생각없이 복사해서 붙여 넣었습니다 ;-) – UltraCommit

관련 문제