In this Document
Purpose |
Troubleshooting Steps |
What is a 'Cursor: pin S wait on X' wait? |
What causes 'Cursor: pin S wait on X' waits? |
How to diagnose the cause. |
How to Examine the Diagnostics. |
SQL ordered by Parse Calls |
SQL ordered by Version Count |
Potential Solutions |
Troubleshooting Other Issues |
References |
The purpose of this article is to help troubleshoot 'Cursor: pin S wait on X' waits.
A cursor wait is associated with parsing in some form. A session may wait for this event when it is trying to get a mutex pin in Share mode but another session is holding the mutex pin on the same cursor object in exclusive. Frequently, waits for 'Cursor: pin S wait on X' is a symptom and not the cause. There may be underlying tuning requirements or known issues.
Obtain information and diagnostics to help locate the cause.
1. Run AWR and ADDM reports during the time that you see 'Cursor: pin S wait on X' waits and also collect baseline reports when you do not see the waits to make comparisons. The baseline shows us the typical 'background' concurrency and activity going on during the time of both the issue and the baseline and may help identify (for example) culprit SQLs with high version counts.
To gather this it is suggested to run AWR and ADDM for half an hour to an hour interval as follows:
2. Sometimes system state dump is necessary to match known issues. For example, if there is no obvious candidate SQL in AWR, capturing holder or waiter processes in systemstate allows you to focus in on potential problems. Run system state when processes appear hung on 'Cursor: pin S wait on X' waits :
(a) Non-Rac
(b) RAC
3. Errorstacks: Another way to obtain process information is with errorstack. Assuming you can identify a blocker, taking errorstacks will provide much the same information as systemstates but with a much reduced disk footprint for trace. Once the ospid of the blocker has been found, an errorstack can be generated:
In particular, the stack from the resultant trace can be used to match known issues.
The system state and errorstacks are not easily readable; so a Service Request may need to be opened to read the files.
4. It is not always feasible to run system state dump. Thus, this note on finding the blocker can be used as well:
5. Furthermore, the following sqls can be ran to identify the waiters:
6. In 11g RAC, there is another less resource intensive tool that can be used when compared with taking system state dumps:
1. Look for high parsing and high version counts from AWR.
Click on *SQL Statistics under Main Report of AWR:
Then, under SQL Statistics click on 'SQL ordered by Parse Calls' or 'SQL ordered by Version Count' to view that information:
From this list, investigate the top SQLs to determine whether this volume of parse calls is excessive or can be reduced.
From this list, investigate the SQLs with the high version count. What are the reasons that these statements are not shared? Can this be addressed?
2. From systemstate and errorstack, we are looking for stacks to match known issues.
For systemstates/errorstacks to be useful, it relies them being taken "at the right time". On a fast moving system, processes may have moved on so holders and waiters are not shown. In a perfect example the systemstates should show the blocker and processes being blocked or one of these. The stack from blocker may indicate known issues.
1. Tune sqls with high parse count by either investigating the application or the sql.
From AWR, the parse statistics is at the top of the report under load profile:
In this case there are mainly soft parses, however, if there were high hard parses, this may indicate high usage of literals or introduction of many new sqls. In this case consider using bind variables in place of literals.
If there is high percentage of soft parses, then check the application to see if it is using shareable sqls.
Ideally, Execute to Parse should be closer to 100%. The application should parse less and execute many times. See:
Also remember if the shared pool is flushed, then sqls will need to be hard parsed. This also may cause mutex waits. So make sure sqls are in memory once hard parsed and monitor to see if mutex waits are alleviated.
2. High version counts can also cause 'cursor: pin S wait on X' waits.
Check V$SQL_SHARED_CURSOR to see the potential reason for the high version count using:
There are some notable bugs where high version counts have been a factor:
3. For more known defects, please go to following note and click on known bugs:
Click on the version that applies and review bug or bugs with similar scenario.
4. If the database has been migrated from 10g to 11g and mutex performance issue surfaces, please consider the 11.2.0.2.2 psu + fix for Unpublished Bug 12431716. Many mutex fixes are already included in this patch:
For guidance troubleshooting other performance issues see: