Oracle11g Performance 노트 3
6669 단어 performance
The table partitions where there is data in the table partition but the corresponding index partition does not contain any rows.
select table_name , high_value , num_rows , last_analyzed
from dba_tab_partitions
where table_name = '&P_TABLE_NAME' ;
select index_name , high_value , num_rows , last_analyzed
from dba_ind_partitions
where index_name = '&P_INDEX_NAME' ;
If the TAB_PARTITIONS HIGH_VALUE has a NON-ZERO value but the corresponding INDEX_PARTITION has a 0 VALUE (exception is index: XLA_AE_LINES_N1), then there is the corruption in the index statistics.
In this case use the solution below to get the performance issue resolved.
a. Compile the below function(getPartitionHighValue) which is used in the query (step b).
CREATE OR REPLACE function getPartitionHighValue(
p_partition_type in varchar2,
p_owner in varchar2,
p_name in varchar2,
p_partition_name in varchar2) RETURN VARCHAR2 AS
l_cursor integer default dbms_sql.open_cursor;
l_len number;
l_long_val varchar2(4000);
l_long_len number;
l_n number ;
l_table_name varchar2(50);
BEGIN
IF upper(p_partition_type) = 'TABLE' THEN
dbms_sql.parse(l_cursor,
'select high_value_length , high_value from dba_tab_partitions ' ||
'where table_owner = :1 ' ||
'and table_name = :2 ' ||
'and partition_name = :3 ',
dbms_sql.native );
ELSE
dbms_sql.parse(l_cursor,
'select high_value_length , high_value from dba_ind_partitions ' ||
'where index_owner = :1 ' ||
'and index_name = :2 ' ||
'and partition_name = :3 ',
dbms_sql.native );
END IF;
dbms_sql.bind_variable( l_cursor, ':1', p_owner );
dbms_sql.bind_variable( l_cursor, ':2', p_name );
dbms_sql.bind_variable( l_cursor, ':3', p_partition_name );
dbms_sql.define_column(l_cursor, 1 , l_len);
dbms_sql.define_column_long(l_cursor, 2 );
l_n := dbms_sql.execute(l_cursor);
IF (dbms_sql.fetch_rows(l_cursor)>0) THEN
dbms_sql.column_value(l_cursor, 1 , l_len );
dbms_sql.column_value_long(l_cursor, 2, l_len, 0 ,
l_long_val, l_long_len );
END IF;
dbms_sql.close_cursor(l_cursor);
return l_long_val;
END getPartitionHighValue;
/
b.Run the below sql to check the table partitions where there is data in the table partition but the corresponding index partition does not contain any rows. The only exception should be the index: XLA_***
SELECT tab.table_name ,
getPartitionHighValue('TABLE',tab.table_owner, tab.table_name,
tab.partition_name) "TABLE_HIGH_VALUE" ,
ind.index_name ,
getPartitionHighValue('INDEX',ind.index_owner, ind.index_name,
ind.partition_name) "INDEX_HIGH_VALUE" ,
tab.num_rows "TABLE_NUM_ROWS",
ind.num_rows "INDEX_NUM_ROWS"
FROM dba_tab_partitions tab,
dba_indexes i,
dba_ind_partitions ind
WHERE tab.table_name = i.table_name
AND tab.table_owner = i.table_owner
AND i.index_name = ind.index_name
AND i.owner = ind.index_owner
AND tab.table_name IN
('XLA_AE_HEADERS','XLA_AE_LINES',
'XLA_DISTRIBUTION_LINKS','XLA_EVENTS',
'XLA_TRANSACTION_ENTITIES')
AND getPartitionHighValue('TABLE',tab.table_owner,
tab.table_name, tab.partition_name) =
getPartitionHighValue('INDEX',ind.index_owner,
ind.index_name, ind.partition_name)
AND tab.num_rows <> 0
AND ind.num_rows = 0;
Run the below SQL to check the table partitions where there is data in the table partition but the corresponding index partition does not contain any rows.
SELECT tab.table_name ,
getPartitionHighValue('TABLE',tab.table_owner, tab.table_name,
tab.partition_name) "TABLE_HIGH_VALUE" ,
ind.index_name ,
getPartitionHighValue('INDEX',ind.index_owner, ind.index_name,
ind.partition_name) "INDEX_HIGH_VALUE" ,
tab.num_rows "TABLE_NUM_ROWS",
ind.num_rows "INDEX_NUM_ROWS"
FROM dba_tab_partitions tab,
dba_indexes i,
dba_ind_partitions ind
WHERE tab.table_name = i.table_name
AND tab.table_owner = i.table_owner
AND i.index_name = ind.index_name
AND i.owner = ind.index_owner
AND tab.table_name IN
('XLA_AE_HEADERS','XLA_AE_LINES','XLA_DISTRIBUTION_LINKS',
'XLA_EVENTS','XLA_TRANSACTION_ENTITIES')
AND getPartitionHighValue('TABLE',tab.table_owner,
tab.table_name, tab.partition_name) =
getPartitionHighValue('INDEX',ind.index_owner,
ind.index_name, ind.partition_name)
AND tab.num_rows <> 0
AND ind.num_rows = 0;
This time after the patch application, nothing should be shown except for the index XLA_AE_LINES_N1 in the sql.
Should the issue persist, please provide a TKPROF and SQLTXPLAIN output of the program as well the output of the below SQL's:
SELECT * FROM dba_tab_partitions
WHERE table_owner = 'XLA'
AND table_name IN ('XLA_AE_HEADERS','XLA_AE_LINES',
'XLA_DISTRIBUTION_LINKS','XLA_EVENTS',
'XLA_TRANSACTION_ENTITIES')
ORDER BY table_name, partition_position;
SELECT * FROM dba_ind_partitions
WHERE index_owner = 'XLA'
AND (index_name LIKE 'XLA_AE_HEADERS%' OR
index_name LIKE 'XLA_AE_LINES%' OR
index_name LIKE 'XLA_DISTRIBUTION_LINKS%' OR
index_name LIKE 'XLA_EVENTS%' OR
index_name LIKE 'XLA_TRANSACTION_ENTITIES%')
ORDER BY index_name, partition_position;
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
.NET 6 - AutoMapper 및 데이터 전송 개체(DTO) 🗺YouTube에서 전체 동영상을 볼 수 있습니다. 오늘 AutoMapper가 무엇이고 왜 필요한지 설명하는 것으로 시작할 수 있습니다. 이제 nuget 패키지가 설치되었으므로 automapper 구현 및 활용을 시작...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.