LANGUAGE_MISMATCH - shared cursor

Create a Function-based Index with NLSSORT

I’ve noticed that a SQL statement in one of our production databases is encountering performance fluctuations. I’ve been investigating to pinpoint the root cause of this issue. Interestingly, the query seems to be employing two distinct SQL plans, with one performing adequately and the other falling short of acceptable performance levels.

I have used query provided below to see how different plans perform.

select plan_hash_value
inst_id,
SUM (executions) as total_exec_count,
SUM (elapsed_time) as total_elapsed,
SUM (elapsed_time) / SUM (executions) as elapsed_perexec
FROM gv$sql
WHERE sql_id = '36av371yyctxf'
GROUP BY plan_hash_value, inst_id;
PLAN_HASH_VALUE INST_ID total_exec_count total_elapsed ELAPSED_PEREXEC
2495358432 1 65 768785522 11827469.5692308
1751229217 1 112444 41895314 372.588257265839
1751229217 2 36477 11051569 302.973627217151
2495358432 2 65 767930057 11814308.5692308

The query executes at an average of 300 milliseconds when utilizing the plan_hash_value – 1751229217. I’ve raised the question of whether it selects different plans based on the bind value, which might vary across data and could potentially be associated with Adaptive Cursor Sharing and bind peeking mechanisms. But when i checked gv$sql is_bind_aware column, it was flagged as ‘N’. Performance fluctuation was not related with ACS.

Query was a very simple one.

The provided execution plan utilizes an index scan.

Child number 16 was using Full Table Scan, I have detected filtering gv$sql with the plan_hash_value=2495358432. The execution plan utilizing from a full table scan, is as provided.

We observed a discrepancy in the predicate information within the predicate information section of the execution plan choosing full table scan. Upon closer inspection, we found that when the query arrives with different NLS (National Language Support) values, it generates a separate child and follows a different plan. This separation into different child processes is caused by the mismatch in language settings (different NLS values).

Although the query is primarily executed with consistent NLS settings matching those of the database, a few executions occur with varying NLS settings. Upon contacting the application team, we learned that they are invoking different NLS settings for certain specific cases, which are not universally applicable to all sessions.

I have observed the same behavior using the following SQL statements.

Now i will create a functional index to fix the issue.

Now here is the results.

Hope it helps.


Discover More from Osman DİNÇ


Comments

Leave your comment