总结教训,不要想抄近路,不要搞偏门,不要以为自己很聪明,不要听rd,不要相信测试
SYMPTOMS
- You are executing a query using bind variables.
- The binding occurs via an application (eg. .NET, J2EE ) using a “string” variable to bind.
- The query is incorrectly performing a full table/index scan instead of an unique/range index scan.
- When looking at advanced explain plan, sqltxplain or 10053 trace, you notice that the “Predicate Information” shows is doing a “filter(SYS_OP_C2C)”.
e.g select * from table(dbms_xplan.display_cursor(&sql_id,null,‘ADVANCED’));
Predicate Information (identified by operation id):
1 - filter(SYS_OP_C2C(“COL1”)=:B1) <=== filter operation occurring
CHANGES
CAUSE
The bind variable “string” is using a different datatype to the column that is being queried.
This means that an implicit conversion of the data is required to execute the query. SYS_OP_C2C is the implicit function which is used to convert the column between nchar and char.
SOLUTION
- Create a function based index on the column.
e.g create index <index_name> on <table_name> (SYS_OP_C2C());
OR
2. Ensure that your bind “string” datatype and column datatype are the same.
A java example where this can occurs is when defaultNChar=TRUE. This will cause strings to bind as NVARCHAR2 causing the predicate that are subset datatypes to be converted to NVARCHAR2.
e.g. -Doracle.jdbc.defaultNChar=true
true
修改后的问题,如果你只是修改1,2个字段,那么你可以通过加索引方式解决,如果你修改的是全部的字段,你可以通过设置参数,解决,否则,你就不应该修改为nvarchar2()。