I have query that takes a lot time to execute (distinct operation). But that query is not listed in v$session_longops. How can I force query to be put to v$session_longop开发者_JAVA百科s.
Unfortunately, if you're talking about a single SQL query, you probably can't force it to show up in V$SESSION_LONGOPS
. Oracle writes a query to V$SESSION_LONGOPS
when one step takes more than 6 seconds. But you can have a very long-running query that is composed of many very short steps. A nested loop join where both inner and outer queries are using an index to fetch the data, for example, can run for a long time but no individual operation may take more than a small fraction of a second. If that's the case, it is generally worth comparing the optimizer's estimated cardinality against the actual cardinality. It is quite possible that Oracle is executing a large number of short operations because it is underestimating the cardinality of various steps of the operation. Getting better estimates for the optimizer may result both in a more efficient query plan and the longer operations being tracked in V$SESSION_LONGOPS
.
If you are talking about a PL/SQL process that happens to issue one or more SQL queries, Rajesh's comment is spot on. You can use the DBMS_APPLICATION_INFO.SET_SESSION_LONGOPS method to have the progress of your PL/SQL process tracked in V$SESSION_LONGOPS
.
精彩评论