问:游标不共享,经过查询发现多数原因指向哈希不匹配,请问什么原因,如何解决?
回:不知道,没遇到过
查查资料吧,先看看这个视图都有哪些,哈希什么的列是叫啥?
SQL> desc V$SQL_SHARED_CURSOR
Name Null? Type
----------------------------------------- -------- ----------------------------
SQL_ID VARCHAR2(13)
ADDRESS RAW(8)
CHILD_ADDRESS RAW(8)
CHILD_NUMBER NUMBER
UNBOUND_CURSOR VARCHAR2(1)
SQL_TYPE_MISMATCH VARCHAR2(1)
OPTIMIZER_MISMATCH VARCHAR2(1)
OUTLINE_MISMATCH VARCHAR2(1)
STATS_ROW_MISMATCH VARCHAR2(1)
LITERAL_MISMATCH VARCHAR2(1)
FORCE_HARD_PARSE VARCHAR2(1)
EXPLAIN_PLAN_CURSOR VARCHAR2(1)
BUFFERED_DML_MISMATCH VARCHAR2(1)
PDML_ENV_MISMATCH VARCHAR2(1)
INST_DRTLD_MISMATCH VARCHAR2(1)
SLAVE_QC_MISMATCH VARCHAR2(1)
TYPECHECK_MISMATCH VARCHAR2(1)
AUTH_CHECK_MISMATCH VARCHAR2(1)
BIND_MISMATCH VARCHAR2(1)
DESCRIBE_MISMATCH VARCHAR2(1)
LANGUAGE_MISMATCH VARCHAR2(1)
TRANSLATION_MISMATCH VARCHAR2(1)
BIND_EQUIV_FAILURE VARCHAR2(1)
INSUFF_PRIVS VARCHAR2(1)
INSUFF_PRIVS_REM VARCHAR2(1)
REMOTE_TRANS_MISMATCH VARCHAR2(1)
LOGMINER_SESSION_MISMATCH VARCHAR2(1)
INCOMP_LTRL_MISMATCH VARCHAR2(1)
OVERLAP_TIME_MISMATCH VARCHAR2(1)
EDITION_MISMATCH VARCHAR2(1)
MV_QUERY_GEN_MISMATCH VARCHAR2(1)
USER_BIND_PEEK_MISMATCH VARCHAR2(1)
TYPCHK_DEP_MISMATCH VARCHAR2(1)
NO_TRIGGER_MISMATCH VARCHAR2(1)
FLASHBACK_CURSOR VARCHAR2(1)
ANYDATA_TRANSFORMATION VARCHAR2(1)
PDDL_ENV_MISMATCH VARCHAR2(1)
TOP_LEVEL_RPI_CURSOR VARCHAR2(1)
DIFFERENT_LONG_LENGTH VARCHAR2(1)
LOGICAL_STANDBY_APPLY VARCHAR2(1)
DIFF_CALL_DURN VARCHAR2(1)
BIND_UACS_DIFF VARCHAR2(1)
PLSQL_CMP_SWITCHS_DIFF VARCHAR2(1)
CURSOR_PARTS_MISMATCH VARCHAR2(1)
STB_OBJECT_MISMATCH VARCHAR2(1)
CROSSEDITION_TRIGGER_MISMATCH VARCHAR2(1)
PQ_SLAVE_MISMATCH VARCHAR2(1)
TOP_LEVEL_DDL_MISMATCH VARCHAR2(1)
MULTI_PX_MISMATCH VARCHAR2(1)
BIND_PEEKED_PQ_MISMATCH VARCHAR2(1)
MV_REWRITE_MISMATCH VARCHAR2(1)
ROLL_INVALID_MISMATCH VARCHAR2(1)
OPTIMIZER_MODE_MISMATCH VARCHAR2(1)
PX_MISMATCH VARCHAR2(1)
MV_STALEOBJ_MISMATCH VARCHAR2(1)
FLASHBACK_TABLE_MISMATCH VARCHAR2(1)
LITREP_COMP_MISMATCH VARCHAR2(1)
PLSQL_DEBUG VARCHAR2(1)
LOAD_OPTIMIZER_STATS VARCHAR2(1)
ACL_MISMATCH VARCHAR2(1)
FLASHBACK_ARCHIVE_MISMATCH VARCHAR2(1)
LOCK_USER_SCHEMA_FAILED VARCHAR2(1)
REMOTE_MAPPING_MISMATCH VARCHAR2(1)
LOAD_RUNTIME_HEAP_FAILED VARCHAR2(1)
HASH_MATCH_FAILED VARCHAR2(1) <--说的应该是这个
PURGED_CURSOR VARCHAR2(1)
BIND_LENGTH_UPGRADEABLE VARCHAR2(1)
USE_FEEDBACK_STATS VARCHAR2(1)
REASON CLOB
那就按着往下百度(此工具 快)
Hash mismatch. Set to "Y" if sharing fails due to a hash mismatch,
such as the case with mismatched histogram data or a range predicate marked
as unsafe by literal replacement (See Bug 3461251)
翻译一下就是:
哈希不匹配。如果共享因哈希不匹配而失败,则设置为“Y”,例如直方图数据不匹配或范围谓词被文字替换标记为不安全的情况(参见Bug 3461251)
然后去mos上搜搜
ORA-00600 [17059]: Script to determine reason(s) for high Child Cursor Count - V$SQL_SHARED_CURSOR (Doc ID 1422573.1)
-- Determine Top-5 child cursors
select * from
(select sql_id, count(child_number)
from v$sql_shared_cursor
group by sql_id
order by count(child_number) desc)
where rownum <=5;
Execute the PLSQL script to determine reason(s) for child cursors:
-- Script Code
set serveroutput on
DECLARE
v_count number;
v_sql varchar2(500);
v_sql_id varchar2(30) := '&sql_id';
BEGIN
v_sql_id := lower(v_sql_id);
dbms_output.put_line(chr(13)||chr(10));
dbms_output.put_line('sql_id: '||v_sql_id);
dbms_output.put_line('------------------------');
FOR c1 in
(select column_name
from dba_tab_columns
where table_name ='V_$SQL_SHARED_CURSOR'
and column_name not in ('SQL_ID', 'ADDRESS', 'CHILD_ADDRESS', 'CHILD_NUMBER', 'REASON', 'CON_ID')
order by column_id)
LOOP
v_sql := 'select count(*) from V_$SQL_SHARED_CURSOR
where sql_id='||''''||v_sql_id||''''||'
and '||c1.column_name||'='||''''||'Y'||'''';
execute immediate v_sql into v_count;
IF v_count > 0
THEN
dbms_output.put_line(' - '||rpad(c1.column_name,30)||' count: '||v_count);
END IF;
END LOOP;
END;
/
Above PL/SQL code contains 'CON_ID' for the not-in list. This is required for Oracle 12c to prevent an ORA-01722: "invalid number".
The column 'CON_ID' does not exist for 11.2 and below. However, the addition of the column as above, does not pose a problem for these earlier versions.
Troubleshooting: High Version Count Issues (Doc ID 296377.1)(内容很丰富)
so,我觉得,应该是统计信息不准或者发生了隐式转换?