V$sqlarea and plan_hash_value

If I have a query with multiple child cursors, I can have more than 1 plan_hash_value for the same sql_id.
how does oracle decide which plan_hash_value to put into v$sqlarea which is a rollup to the sql_id level?

Guess2 wrote:
If I have a query with multiple child cursors, I can have more than 1 plan_hash_value for the same sql_id.
how does oracle decide which plan_hash_value to put into v$sqlarea which is a rollup to the sql_id level?Let's try a bit of an experiment (in 11.2.0.2) to determine which child cursor's PLAN_HASH_VALUE appears in V$SQLAREA. First, we will create a test table with skewed data:
CREATE TABLE T1 AS
SELECT
  ROWNUM C1,
  DECODE(ROWNUM,1,1,0) C2,
  LPAD('A',255,'A') C3
FROM
  DUAL
CONNECT BY
  LEVEL<=10000;
CREATE UNIQUE INDEX IND_T1_C1 ON T1(C1);
CREATE INDEX IND_T1_C2 ON T1(C2);
ALTER TABLE T1 MODIFY (C1 NOT NULL, C2 NOT NULL);
EXEC DBMS_STATS.GATHER_TABLE_STATS(OWNNAME=>USER,TABNAME=>'T1',CASCADE=>TRUE,ESTIMATE_PERCENT=>100,METHOD_OPT=>'FOR ALL INDEXED COLUMNS SIZE 254')The initial test:
SET LINESIZE 120
SET PAGESIZE 1000
VARIABLE V1 NUMBER
EXEC :V1:=1
SELECT /*+ BIND_AWARE */
  C1,
  C2,
  C3
FROM
  T1
WHERE
  C2=:V1;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL,NULL,'TYPICAL'));
SQL_ID  7p4yxrzwwuybt, child number 0
SELECT /*+ BIND_AWARE */   C1,   C2,   C3 FROM   T1 WHERE   C2=:V1
Plan hash value: 236868917
| Id  | Operation                   | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT            |           |       |       |     2 (100)|          |
|   1 |  TABLE ACCESS BY INDEX ROWID| T1        |     1 |   136 |     2   (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN          | IND_T1_C2 |     1 |       |     1   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   2 - access("C2"=:V1)
SELECT
  PLAN_HASH_VALUE
FROM
  V$SQLAREA
WHERE
  SQL_ID='7p4yxrzwwuybt';
PLAN_HASH_VALUE
      236868917As shown above, the PLAN_HASH_VALUE was set to 236868917, which is the most recently executed child number.
Trying again with a different bind variable value:
EXEC :V1:=0
SELECT /*+ BIND_AWARE */
  C1,
  C2,
  C3
FROM
  T1
WHERE
  C2=:V1;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL,NULL,'TYPICAL'));
SQL_ID  7p4yxrzwwuybt, child number 1
SELECT /*+ BIND_AWARE */   C1,   C2,   C3 FROM   T1 WHERE   C2=:V1
Plan hash value: 3617692013
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT  |      |       |       |    33 (100)|          |
|*  1 |  TABLE ACCESS FULL| T1   |  9999 |  1327K|    33   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   1 - filter("C2"=:V1)
SELECT
  PLAN_HASH_VALUE
FROM
  V$SQLAREA
WHERE
  SQL_ID='7p4yxrzwwuybt';
PLAN_HASH_VALUE
     3617692013As shown above, the PLAN_HASH_VALUE changed to the value 3617692013, which is the most recently executed child number.
TRying again without changing the bind variable value:
SELECT /*+ BIND_AWARE */
  C1,
  C2,
  C3
FROM
  T1
WHERE
  C2=:V1;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL,NULL,'TYPICAL'));
SQL_ID  7p4yxrzwwuybt, child number 1
SELECT /*+ BIND_AWARE */   C1,   C2,   C3 FROM   T1 WHERE   C2=:V1
Plan hash value: 3617692013
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT  |      |       |       |    33 (100)|          |
|*  1 |  TABLE ACCESS FULL| T1   |  9999 |  1327K|    33   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   1 - filter("C2"=:V1)
SELECT
  PLAN_HASH_VALUE
FROM
  V$SQLAREA
WHERE
  SQL_ID='7p4yxrzwwuybt';
PLAN_HASH_VALUE
     3617692013As shown above, the PLAN_HASH_VALUE remained at the value 3617692013, which is the most recently executed child number.
Switching back to the original bind variable value:
EXEC :V1:=1
SELECT /*+ BIND_AWARE */
  C1,
  C2,
  C3
FROM
  T1
WHERE
  C2=:V1;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR(NULL,NULL,'TYPICAL'));
SQL_ID  7p4yxrzwwuybt, child number 0
SELECT /*+ BIND_AWARE */   C1,   C2,   C3 FROM   T1 WHERE   C2=:V1
Plan hash value: 236868917
| Id  | Operation                   | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT            |           |       |       |     2 (100)|          |
|   1 |  TABLE ACCESS BY INDEX ROWID| T1        |     1 |   136 |     2   (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN          | IND_T1_C2 |     1 |       |     1   (0)| 00:00:01 |
Predicate Information (identified by operation id):
   2 - access("C2"=:V1)
SELECT
  PLAN_HASH_VALUE
FROM
  V$SQLAREA
WHERE
  SQL_ID='7p4yxrzwwuybt';
PLAN_HASH_VALUE
      236868917 As shown above, the PLAN_HASH_VALUE switched back to the original value.
In 11.2.0.2, V$SQLAREA is based on GV$SQLAREA, which is based on the X$KGLCURSOR_CHILD_SQLID structure. You can execute the following SQL statement to show the columns that are retrieved and the corresponding names of those columns in GV$SQLAREA:
SELECT
  VIEW_DEFINITION
FROM
  V$FIXED_VIEW_DEFINITION
WHERE
  VIEW_NAME='GV$SQLAREA';
DESC GV$SQLAREAWe are able to confirm that the most recently executed child cursor number will appear in V$SQLAREA with the following SQL statement (I suggest not running this on a very busy database instance):
SET LINESIZE 120
SET PAGESIZE 1000
SELECT
  X.KGLOBT03 SQL_ID,
  X.KGLOBT30 PLAN_HASH_VALUE,
  TO_CHAR(X.KGLOBCLA,'HH24:MI:SS') LAST_ACTIVE_TIME,
  S.CHILD_NUMBER,
  S.PLAN_HASH_VALUE S_PLAN_HASH_VALUE,
  TO_CHAR(S.LAST_ACTIVE_TIME,'HH24:MI:SS') S_LAST_ACTIVE_TIME,
  DECODE(X.KGLOBCLA,S.LAST_ACTIVE_TIME,NULL,'DIFFERENT') TIMESTAMP
FROM
  X$KGLCURSOR_CHILD_SQLID X,
  V$SQL S
WHERE
  X.KGLOBT02 != 0
  AND X.KGLOBT03=S.SQL_ID
ORDER BY
  S.SQL_ID,
  S.CHILD_NUMBER;
SQL_ID        PLAN_HASH_VALUE LAST_ACT CHILD_NUMBER S_PLAN_HASH_VALUE S_LAST_A TIMESTAMP
fz2htd7p723p5      3775029212 13:01:24            0        3775029212 13:01:24
fzrshwabvtwc0      3637245398 13:21:28            0        3637245398 13:21:28
fzt8s1f6kmk5k               0 12:58:30            0                 0 12:58:30
g00cj285jmgsw       315182377 13:06:24            0         315182377 12:58:30 DIFFERENT
g00cj285jmgsw       315182377 13:06:24            1         315182377 13:06:24
g3wrkmxkxzhf2       749386351 13:21:24            0         749386351 13:21:24
g3wrkmxkxzhf2       749386351 13:21:24            1         749386351 12:51:27 DIFFERENT
ga9j9xk5cy9s0      1697022209 13:01:24            0        1697022209 13:01:24
ga9j9xk5cy9s0      1697022209 13:01:24            1        1697022209 12:51:27 DIFFERENT
grwydz59pu6mc      3684871272 13:21:24            0        3684871272 13:21:24
grwydz59pu6mc      3684871272 13:21:24            1        3684871272 12:51:27 DIFFERENT
gx4mv66pvj3xz      2570921597 13:21:24            0        1932954096 12:51:27 DIFFERENT
gx4mv66pvj3xz      2570921597 13:21:24            1        2570921597 13:21:24
gzyt498gtbgt5      2826905927 12:51:23            0        2826905927 12:51:23As shown above, the child with the most recent LAST_ACTIVE_TIME timestamp appears in V$SQLAREA.
Charles Hooper
http://hoopercharles.wordpress.com/
IT Manager/Oracle DBA
K&M Machine-Fabricating, Inc.

Similar Messages

  • V$sql, v$sqlarea and v$sqltext

    Hello,
    Any idea how to isolate PLSQL objects calls from SQL statement in following views?
    v$sql,
    v$sqlarea,
    v$sqltext
    For e.g. I ran following query but it would also include SELECT statements. Whereas I only need PLSQL Calls.
    select * from v$sql where upper(sql_text) like 'BEGIN%.%'
    Is there any better way?
    Thank you in advance for reading this post.
    R

    A select statement can include a pl/sql function call so you cannot exclude selects and search only the begin keyword.
    You could join with DBA_OBJECTS, but is not very precise:
    select *
    from v$sql, dba_objects 
    where upper(sql_text) like '%'||object_name||'%'
    and object_type in ('PACKAGE','PROCEDURE','FUNCTION');Max
    http://oracleitalia.wordpress.com

  • V$sqlarea and ROWS_PROCESSED

    Hii all
    when I looking v$sqlare for a statement that is I suspect to create so much redo, the Statement is updating a table row (there is not index on table)but ROWS PROCESSED' value is almost 138 million but table has only 15.000 row  also executions value is 13000 How it could be possible ? Pls explain what is the exact mean is ROW PROCESSED and EXECUTIONS colums in the v$sqlarea ? if there is index on table when updating a table, row_processed could be higher than actual updated rows ?
    10.2.0.4 On AIX
    Best Regards

    These values are totals across all executions of the statement whilst it has been in the SQL area:
    executions:- Total number of executions, totalled over all the child cursors
    rows_processed:- Total number of rows processed on behalf of this SQL statement
    You could try looking in the AWR data (dba_hist_sqlstat - 10G and above) to view more granular information about this SQL_ID after each snapshot (it records the values for the snapshot period i.e. delta's), if it really is executed so often it will more than likely have been captured by AWR.
    Thanks
    Paul

  • V$SQLAREA AND HIGH RESOURCE QUERY IN EXADATA

    Hello everyone.
    I write for information regarding V$SQLAREA.
    On this view, it is possibile to check which queries consume more resources.
    I need to highlight the query with highest execution time, and highest use of disk resources.
    Respect to DISK_READS field, is it possible to do the same analysis that is done on non-Exadata DB?
    Since the storage is entrusted to the cells, should this field be seen differently?
    Or, could it have a different meaning?
    Thanks a lot,
    Greetings,
    Sandro

    I need to highlight the query with highest execution time, and highest use of disk resources.
    You can easily get above from AWR.
    Please explain what exactly you are trying to do? Do you want to manage runaway queries in Exadata? or Just want to tell Top queries by execution time in given time-frame (say in last 1 hour or last 1 day etc.) ?
    Thanks,
    Abhi

  • Join V$SQLAREA and V$Session

    hi all,
    which column i need to use to join V$session and V$sqlarea?
    My main aim is to find top 5 queries with most disk_reads and generate a report containing relevant information.
    Thanks

    i use to check active queries like this from both tables
    select
         substr(sid || ',' || serial#,0,15) sid,
         USERNAME,
         PROGRAM,
         MACHINE,
         OSUSER,
         LOGON_TIME,
         TERMINAL,
         sql_text Query
    from
         v$sqltext,
         v$session
    where
         address=sql_address
         and hash_value=sql_hash_value
         and status='ACTIVE'
    order by LOGON_TIME,sid,piece

  • V$sqlarea and cumulative values

    hi gurus,
    does v$sqlarea provide cumulative values for a SQL?
    for eg:
    Step 1
    SQL=select * from emp where empid=1
    elapsed_time = 2829
    Step 2
    SQL=select * from emp where empid=1
    elapsed_time = 2980
    1) if the values are cumulative, is there a way to find the elapsed_time for the last executed SQL as in step 2?
    2) is there any limit for the number of rows returned by v$sqlarea,(or when would be a particular SQL cleared from v$sqlarea)?
    thanks,
    charles

    SELECT sql_text,
          executions,
          CEIL (cpu_time / GREATEST (executions, 1)) ave_cpu_time,
          CEIL (elapsed_time / GREATEST (executions, 1)) ave_elapsed_time,
          CEIL (disk_reads / GREATEST (executions, 1)) ave_disk_reads,
          persistent_mem per_mem,
          runtime_mem run_mem,
          CEIL (sorts / GREATEST (executions, 1)) ave_sorts,
          CEIL (parse_calls / GREATEST (executions, 1)) ave_parse_calls,
          CEIL (buffer_gets / GREATEST (executions, 1)) ave_buffer_gets,
          CEIL (rows_processed / GREATEST (executions, 1)) ave_row_proc
    FROM v$sqlarea
    WHERE sql_text = 'select * from emp where empid=1'Regards,
    Mahesh Kaila

  • V$sqlarea !!

    Hi, the following is my question :
    1) I know that oracle can keep track each update to the database table like the update command.
    e.g. update tableA
    set block = 'Y'
    where user_id = 'XXX';
    But is there any other table i can select the cached SQL other than v$sqlarea and v$sql.
    I am able to select update command from 5 days ago using the v$sqlarea. But if i would like to select the SQL command which i executed more than 5 days ago then what should i do ? Is it any parameter that can be set to configure the no of day to store the old sql text in v$sqlarea.
    regards,
    Kong

    Maybe you can look at auditing?
    see http://technet.oracle.com/docs/products/oracle9i/doc_library/release2/server.920/a96521/audit.htm#1108

  • High invalidations in v$sqlarea for 1 query tag with "SQL Analyze"

    Hi All,
    Hopefully post to the right forum, if not please do let me know. Thanks
    I have one pre-production issue still don't have any clue how to move forward.
    This is 2 RAC nodes in linux platform with Oracle 11.2.0.2
    In the begininng this environment having a lot of performance issue, as huge "cursor: pin S wait on X", "latch: shared pool"
    and "library cache:Mutex X" causing very bad performance in this environment. After oracle support suggest to disable few hidden paramter
    and adjust some parameter, then it help to stablized the environment (according to oracle, the initial issue was caused by high version count).
    But we still can find minimal "latch:shared pool" and "library cache:Mutex X" on top 5 wait event list on hourly AWR report.
    This time oracle was saying it might caused by high reload and high invalidatiosn in sqlarea (not sure how true it is), luckily the event
    did not caused the performance issue at this moment, but we're asking support how can we get rid of the "mutex/latch" event.
    They give me one query to check the invalidations in v$sqlarea, and they suspect the high validation is causing by application.
      select *
      from v$sqlarea
      order by invalidations DESC;
      Weird thing is, there have one SQL tag with "SQL Analyze" always causing high invalidations. But we're not able to get more detail (base on SQL_ID)
    in v$sql or v$session table. This SQL insert into v$sqlarea and remove within 1 or 2 seconds, hard to get more information.
    And the statement is exactly the same, but don't know why SQL Analyze always checking on it.
    This SQL is triggering by SYS user, and it is inserting into MLOG$ table (one of the application materialized log file)
      insert into "test"."MLOG$_test1" select * from "test"."MLOG$_test1"
      The v$sqlarea information as below, sometime the invalidations can hit more than 10,000
      SQL_ID              SQL_TEXT                                                                                        LOADS  INVALIDATIONS
      0m6dhq90rg82x /* SQL Analyze(632,0) */ insert into "test"."MLOG$_test" select * from "test"."MLOG$_test  7981    7981
      {code}
      Anyone have any idea how can i move forward for this issue? As Oracle is asking me to use SQLTXPLAIN get the detail?
      Please share with me if you have any idea. Thanks in advance.
      Regards,
      Klng                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Dom,
    We have checked there have no SQL Tuning enable for this SQL_ID. Below is the optimizer parameter in this environment, the hidden parameter was changed which suggest by oracle support.
    NAME                                 TYPE        VALUE
    _optimizer_adaptive_cursor_sharing   boolean     FALSE
    _optimizer_extended_cursor_sharing_r string      NONE
    el
    object_cache_optimal_size            integer     102400
    optimizer_capture_sql_plan_baselines boolean     FALSE
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      11.2.0.2
    optimizer_index_caching              integer     90
    optimizer_index_cost_adj             integer     10
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    optimizer_use_invisible_indexes      boolean     FALSE
    optimizer_use_pending_statistics     boolean     FALSE
    optimizer_use_sql_plan_baselines     boolean     TRUE
    plsql_optimize_level                 integer     2
    SQL> select * from dba_sql_plan_baselines;
    no rows selected
    SQL>yeah we did run the ash, but the high invalidation did not caputre in the report. Actually this SQL tag with sql analyze it gone from v$sqlarea very fast (only 1 or 2 seconds only).
    Thanks.
    Regards,
    Klng

  • Which user/schema executed query in V$SQLAREA

    I am looking on one row/query in view "V$SQLAREA" and want to which user/schema was used to log in to the database when that one query was executed. How i can get that schema name?
    Should i look this column maybe:
    V$SQLAREA
    PARSING_SCHEMA_NAME             VARCHAR2(30)      Schema name that was used to parse this child cursor( http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2129.htm )
    I have Java software that uses different database schemas/users to make connections to my database. And i want to know for one query which schema/user was used to connect to database before running the query.
    I think i need to join "V$SQLAREA" to view V$SESSION and there the column "USERNAME" tells me the connection user name for the executed query.
    V$SESSION
    USERNAME      VARCHAR2(30)      Oracle username
    ( http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2088.htm )Seems like i fail to join "V$SQLAREA" to view V$SESSION:
    select q.SQL_TEXT, q.sql_id, q.PARSING_SCHEMA_NAME, q.ADDRESS, q.last_active_time, s.USERNAME, s.SCHEMANAME from v$sqlarea q, v$session s
    where q.last_active_time > sysdate - 1
    and q.sql_text like 'DELETE FROM casino.lgngameoperationlog WHERE sessionCode%'
    and s.sql_address=q.address
    order by last_active_time desc
    no rows found
    select q.SQL_TEXT, q.sql_id, q.PARSING_SCHEMA_NAME, q.ADDRESS, q.last_active_time from v$sqlarea q
    where q.last_active_time > sysdate - 1
    and q.sql_text like 'DELETE FROM casino.lgngameoperationlog WHERE sessionCode%'
    order by last_active_time desc
    'DELETE FROM casino.lgngameoperationlog WHERE sessionCode = :1 and sessionType = :2';     51thfgbubkkg6;     JAVA;     0000000392523658;     28.10.2010 18:09:14;
    */

    I have Java software that uses different database schemas/users to make connections to my database. And i want to know for one query which schema/user was used to connect to database before running the query.If the SQL-text sits inside your Java code, that is the text does not sit inside some stored pl/sql program unit, then you can use parsing_schema_id, yes.
    If the SQL-text sits inside a stored procedure, then depending on how that procedure is defined (invoker rights or definer rights), you could use parsing_schema_id too (in the first case (invoker rights)).

  • Missingf SQL Statements in v$sqlarea

    Hi,
    i´m tracing some sql statements and from time to time they disapear very quickly from the shared pool.
    i´m looking into v$sqlarea and the funny thing is, i thought "all" historical statments will be copied to dba_hist_sqltext. But thery are missing there too.
    Some statments are away after a couple of minutes, but the shared pool is quit large enough.
    I had the same problem inside the em (10g) many (historical) statements can´t be seen after a couple of minutes.
    Are some other views for that ?
    Thanks
    Marco

    select * from v$sgastat where name like '%free%'
    shared pool     ksuloi: long op free list     16
    shared pool     message pool freequeue     700592
    shared pool     kghx free lists     19008
    shared pool     free memory     129955780 <=========== !!!!
    shared pool     kglsim free obj list     204
    shared pool     sim kghx free lists     4
    shared pool     kglsim free heap list     204
    large pool     free memory     3458568
    java pool     free memory     4194304
    streams pool     free memory     8388608

  • How to find sid,serial# for sql in v$sqlarea

    Hi,
    10gR2
    in order to dig down the session which is running particular sql
    say querying v$sqlarea and getting sql_id
    now how to map it to v$session

    thanks for the reponse
    Join v$sqlarea's address with v$session's sql_address.
    does this always mapped, even if sql has completed execution
    say i have made a session of user scott
    and ran this statement
    ===================================
    SQL> create table my_obj as select * from obj;
    Table created.
    now i jhave another session of sys to find session details
    ============================================
    SQL> select SQL_ID,EXECUTIONS,DISK_READS,BUFFER_GETS,ADDRESS,CPU_TIME,PROGRAM_ID,SQL_TEXT
    FROM GV$SQLAREA WHERE SQL_TEXT LIKE ' 2 %MY_OBJ%';
    SQL_ID     EXECUTIONS DISK_READS BUFFER_GETS ADDRESS      CPU_TIME
    PROGRAM_ID
    SQL_TEXT
    4hshv4csmh7d8     1     0     14 000000007ECDF248 2899
         0
    select SQL_ID,EXECUTIONS,DISK_READS,BUFFER_GETS,ADDRESS,CPU_TIME,PROGRAM_ID,SQL_
    TEXT FROM GV$SQLAREA WHERE SQL_TEXT LIKE '%MY_OBJ%'
    SQL> select sql_address ,sid,serial#,username from v$session where sql_address='000000007ECDF248';
    no rows selected
    SQL> select sql_id ,prev_sql_id ,sql_address ,sid,serial#,username from v$session where sql_id='4hshv4csmh7d8';
    no rows selected
    SQL> select sql_id ,prev_sql_id ,sql_address ,sid,serial#,username from v$session where prev_sql_id='4hshv4csmh7d8';
    no rows selected
    please suggest
    another other view
    or there may be two cases of this
    case1 sql is running
    case 2 sql is completed

  • Sql statements in v$sqlarea

    Hi
    When I get the sqls from v$sqlarea, does these sqls already executed, or currently runnıng?

    I suggest you check the Oracle Document,
    While showing similar content, you might also note there are difference between V$SQLAREA and V$SQL view
    V$SQL
    V$SQL lists statistics on shared SQL area without the GROUP BY clause and contains one row for each child of the original SQL text entered. Statistics displayed in V$SQL are normally updated at the end of query execution. However, for long running queries, they are updated every 5 seconds. This makes it easy to see the impact of long running SQL statements while they are still in progress.
    V$SQLAREA
    V$SQLAREA lists statistics on shared SQL area and contains one row per SQL string. It provides statistics on SQL statements that are in memory, parsed, and ready for execution.

  • Relations between Views  v$sqlarea,v$sqltext

    Hi
    What relations between the views v$sqlarea,v$sqltext , v$session
    tia
    using oracle 9.2.02

    Hello,
    You'll find below a few links about these dynamics views.
    v$sqlarea:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96536/ch3204.htm#1126299
    v$sqltext:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96536/ch3205.htm#1126509
    v$session:
    http://download.oracle.com/docs/cd/B10501_01/server.920/a96536/ch3171.htm#1122127
    You can join v$sqlarea and v$sqltext with the columns ADDRESS and HASH_VALUE.
    You can also use the columns SQL_ADDRESS and SQL_HASH_VALUE to join with v$session.
    Hope this help.
    Best regards,
    Jean-Valentin

  • Buffer_gets and 'session logical reads'

    When I compare the following values:
    select sum(buffer_gets) from v$sqlarea
    and
    select value from v$sysstat where name='session logical reads'
    it usually happens that sum(buffer_gets) > 'session logical reads'.
    Does buffer_gets include logical and physical reads? As long as the SGA keeps all the SQL statments, I guess sum(buffer_gets) will be bigger than 'session logical reads'. Is this correct?
    Thxs

    Hi,
    buffer gets = number of times a block was requested from buffer cache. A buffer get always request in a logical read. Depending on whether or not a copy of the block is available in the buffer cache, a logical read may or may not involve a physical read. So "buffer gets" and "logical reads" are basically synonyms and are often used interchangeably.
    Oracle doesn't have a special "undo buffer". Undo blocks are stored in rollback segments in UNDO tablespace, and are managed in the same way data blocks are (they're even protected by redo). If a consistent get requires reading from UNDO tablespace, then statistics counters will show that, i.e. there will be one more consistent get in your autotrace.
    For more information and some examples, see a thread at askTom:
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:549546900346542976
    Best regards,
    Nikolay

  • Dbms_output size limit in child report?

    Is there a hard limit on the size of the DBMS_OUTPUT that can be displayed in a CHILD report? If so, can it be increased in a future version?
    I have a user defined report that shows active sessions in the top (i.e. master/parent) report. The report has a child tab that show the EXPLAIN plan for the selected SQL statement using DBMS_OUTPUT. It works great unless the Explain Plan is too large, in which case I get an error.
    I just tried to duplicate the problem but nothing that is running now generates a plan large enough to hit the limit, which isn't surprising because the limit was pretty large.
    The SQL for the Child report is below. Note that is it all in one line because at one time it didn't work if there were embedded newlines in the SQL (I don't know if that is still the case). So, it is ugly, but like I said it works well and is very useful.
    DECLARE v_predicate VARCHAR2(200) ; v_sql_hash_value VARCHAR2(100) := :SQL_HASH_VALUE ; v_plan_hash_value VARCHAR2(100) := :PLAN_HASH_VALUE ; v_inst_id VARCHAR2(2) := :INST_ID ; v_child_number VARCHAR2(3) := :SQL_CHILD_NUMBER ; BEGIN v_predicate := 'HASH_VALUE = ' || v_sql_hash_value || ' and PLAN_HASH_VALUE = ' || v_plan_hash_value || ' and INST_ID = ' || v_inst_id || ' and CHILD_NUMBER = ' || v_child_number ; dbms_output.put_line( '<pre>' ) ; FOR nxt IN ( SELECT substr(plan_table_output, 1, 255) as rec FROM table (DBMS_XPLAN.DISPLAY( 'GV$SQL_PLAN', null, 'ALL', v_predicate ) ) ) LOOP dbms_output.put_line( nxt.rec ) ; END LOOP ; dbms_output.put_line( '</pre>' ) ; END ;

    What database version?
    The default size of the buffer for dbms_output used to be limited in the database. it may be that you are hitting that.
    What is the error message?

Maybe you are looking for