Rows_Processed in v$SQL

Hi everybody,
How can you explain that the number of total rows of a table is different from the rows_processed in v$SQL when i execute the sql statement 'count(*) from the <table>'???
O.K. I FOUND WHY THE DIFFERENCE OCCURED.......!!!!
Thanks,
Simon
Message was edited by:
sgalaxy

There is an addition with the previous execution :
SYSTEM@demo102> select count(*) from scott.emp;
  COUNT(*)
        14
SYSTEM@demo102> select sql_text,rows_processed from v$sql where sql_text like '%emp%'
SYSTEM@demo102> /
SQL_TEXT
ROWS_PROCESSED
select count(*) from scott.emp
             1
SYSTEM@demo102> select count(*) from scott.emp;
  COUNT(*)
        14
SYSTEM@demo102> select sql_text,rows_processed from v$sql where sql_text like '%emp%';
SQL_TEXT
ROWS_PROCESSED
select count(*) from scott.emp
             2
SYSTEM@demo102> SYSTEM@demo102> alter system flush shared_pool;
System altered.
SYSTEM@demo102> select count(*) from scott.emp;
  COUNT(*)
        14
SYSTEM@demo102> select sql_text,rows_processed from v$sql where sql_text like '%emp%';
SQL_TEXT
ROWS_PROCESSED
select count(*) from scott.emp
             1
ROWS_PROCESSED      NUMBER      Total number of rows the parsed SQL statement returns
From Reference Doc : http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2113.htm#sthref4036
Nicolas.
Add the reference doc.
Message was edited by:
N. Gasparotto

Similar Messages

  • SQL query slow when issued by app, fast when issued mnaually

    Hi there,
    I have a more general question about a specific Oracle behaviour.
    I update a feature from within an application. The application doesn't respond and I finally have to terminate it. I checked Oracle whether a query is running long using the following statement:
    select s.username,s.sid,s.serial#,s.last_call_et/60 mins_running,q.sql_text from v$session s
    join v$sqltext_with_newlines q
    on s.sql_address = q.address
    where status='ACTIVE'
    and type <>'BACKGROUND'
    and last_call_et> 60
    order by sid,serial#,q.piece
    The result of the above query is:
    WITH CONNECTION AS ( SELECT * FROM WW_CONN C WHERE (C.FID_FROM I
    N (SELECT FID FROM WW_LINE WHERE FID_ATTR=:B1 ) AND C.F_CLASS_ID
    FROM =22) OR (C.FIDTO IN (SELECT FID FROM WW_LINE WHERE FID_AT
    TR=:B1 ) AND C.F_CLASS_ID_TO =22) ) SELECT MIN(P.FID_ATTR) AS FI
    D_FROM FROM CONNECTION C, WW_POINT P WHERE (P.FID = C.FID_FROM A
    ND C.F_CLASS_ID_FROM = 32 AND C.FLOW = 1) OR (P.FID = C.FID_TO A
    ND C.F_CLASS_ID_TO = 32 AND C.FLOW = 2)
    I have a different tool which shows me the binding parameter values. So I know that the value for :B1 is 5011 - the id of the feature being updated. This query runs for 20 mins and longer before it eventually stops. The update process involves multiple sql statements - so this one is not doing the update but is part of the process.
    Here is the bit I do not understand: when I run the query in SQL Developer with value 5011 for :B1 it takes 0.5 secs to return a result.
    Why is it, that the sql statement takes so long when issued by the application but takes less than a second when I run it manually?
    I sent a dump of the data to the application vendor who is not able to reproduce the issue in their environment. Could someone explain to me what happens here or give me some keywords for further research?
    We are using 11gR2, 64bit.
    Many thanks,
    Rob

    Hi Rob,
    at least you should see some differences in the statistics for the different child cursor (the one for the execution in the application should show at least a higher value for ELAPSED_TIME). I would use something like the following query to check the information for the child cursors:
    select sql_id
         , PLAN_HASH_VALUE
         , CHILD_NUMBER
         , EXECUTIONS
         , ELAPSED_TIME
         , USER_IO_WAIT_TIME
         , CONCURRENCY_WAIT_TIME
         , DISK_READS
         , BUFFER_GETS
         , ROWS_PROCESSED
      from v$sql
    where sql_id = your_sql_idRegards
    Martin

  • Query slow when executing using prepared statement compared to sqlDeveloper

    Oracle version is 10.2.0.1.0.
    I have got a query which when submitted from java code using prepared statement and parameter substitutions, takes more than 20 seconds to give results.
    I can see this SELECT sql sitting there when I run Monitor Sessions through sqlDeveloper, with its wait time increasing and then finally getting through. During that time no other SQLs are waiting.
    DURING THAT TIME then I am able to run the same query (with values included) multiple times using sqlDeveloper, and it gives results in no time.
    Sqldeveloper connects using thin client using lib provided by oracle in windows.
    Java code runs from linux and uses the thin client using lib provided by oracle in linux.
    Both are hitting the same DB running on a separate Linux machine.
    What could be the cause of this problem?
    What db parameters, queries should I run to identify the bottleneck?
    Edited by: user10390517 on Jun 14, 2010 3:06 AM

    Hi Rob,
    at least you should see some differences in the statistics for the different child cursor (the one for the execution in the application should show at least a higher value for ELAPSED_TIME). I would use something like the following query to check the information for the child cursors:
    select sql_id
         , PLAN_HASH_VALUE
         , CHILD_NUMBER
         , EXECUTIONS
         , ELAPSED_TIME
         , USER_IO_WAIT_TIME
         , CONCURRENCY_WAIT_TIME
         , DISK_READS
         , BUFFER_GETS
         , ROWS_PROCESSED
      from v$sql
    where sql_id = your_sql_idRegards
    Martin

  • Pre-export    and post-import tasks

    oracle8i/windows 2000 server.
    i would like export my database from my organisation and import into my local
    machine at home.
    what are the precautions,tasks and post tasks
    ,i have to take during import and export.
    c.santhanakrishnan.

    Why are you exporting your organisations db to import at home? Are you aware of the privacy issues this raises? Do you have approval from your organisation?
    Exporting -
    o NLS_LANG is set correctly
    o Available space on disk
    o consistent = y
    o recordlength=65535
    o direct=y
    o log=<logfile_name>
    o do you require grants, indexes?
    o A feedback for progress,
    o But even with consistent = y that is table consistent and there is a probability you may run into a problem with FKs (usually when exporting large amounts of data) and tables in the beginning of the export have child tables near the end of the export which (the child tables) have records inserted during the export which won't have a parent record on import and will be rejected.
    Importing -
    Some depend on the data volume. Do you want to -
    o NLS_LANG is set correctly
    o drop, re-create indexes to speed up import
    o put the database in NOARCHIVELOG (if possible)
    o need to also create public synonyms
    o check triggers and if they will fire?
    o need to create the schema/user to import (if it doesn't exist in the import database and is not a full export) ?
    o do the tablespaces that the export was taken from exist in the import database?
    o disable/enable FK constraints
    o enough UNDO space
    o enough archive log space (if in ARCHIVELOG mode)
    oset a buffer (size depends)
    o set a feedback to monitor progress (or check rows_processed in v$sql)
    o if data already exists in the tables, does it need to be truncated (which raised other issues, constraints etc, take a backup prior to truncate?)
    I probably missed stuff too.

  • My pl/sql procedure works; I'm just looking for someone to review it

    Hi All,
    I wrote the below procedure to be executed via APEX (inside the APEX_PLSQL_JOB.SUBMIT_PROCESS wrapper).
    It works fine, but I'm not a programmer per se and am just curious if one of the veterans on this forum could review it
    and just tell me if it looks like I followed proper standards/procedures etc. or make any suggestions on how I can be more efficient etc.
    The purpose of the procedure is to update Oracle Applications translations tables with language-translated values that we have
    accumulated from our global workforce. It's pretty simple - just a big find and replace exercise - replacing english values in the apps
    tables with translated values. Oracle's '_TL' tables are designed for this purpose and I'm not updating any primary or foriegn keys.
    I don't know the exact update statement or instance at the time of execution and hence the need for dynamic SQL and a DB link.
    Again, there are no issues (yet) - everything is working fine, I'm just interested in having someone review it and offer me some feedback.
    thanks in advance,
    John
    create or replace
    procedure GSE_UPDATE_TL_TABLES (l_instance IN varchar2, l_app_job IN number)
    IS
    l_tname  varchar2(30);
    l_column_name VARCHAR2(30);
    l_col_value VARCHAR2(4000);
    l_eng_value VARCHAR2(4000);
    l_language VARCHAR2(4);
    i number;
    l_query VARCHAR2(4000);
    l_messages dbms_output.chararr;
    l_numlines integer := 1000; -- retrieves max 1000 messages from the buffer
    l_rows_updated number := 0;
    l_rows_processed number;
    CURSOR TABLES_CUR IS
    SELECT TABLE_NAME, COLUMN_NAME, COLUMN_VALUE, eng_value, LANGUAGE FROM GSE_LNG_STRINGS WHERE COMPLETION_STATUS = 'Y'; ---This table is our repository of translations
    and includes the english value, the translated values, the language code and the table and column names that will be updated.
    BEGIN
    DBMS_OUTPUT.ENABLE(1000000);
    delete from gse_update_tracking;  ---I'm using this table to track real-time progress and to update a progress status bar in APEX.
    commit;
    open tables_cur;
    LOOP
    fetch tables_cur into l_tname, l_column_name,l_col_value, l_eng_value, l_language;
    EXIT WHEN tables_cur%NOTFOUND;
    BEGIN
    EXECUTE IMMEDIATE
    'Update ' ||l_tname||'@'||l_instance||' set ' ||l_column_name|| ' = q''['||l_col_value||']''  where ' ||l_column_name|| ' = q''['||l_eng_value||']'' and language = '''||l_language||'''';
    l_rows_updated := (l_rows_updated + sql%rowcount);
    insert into gse_update_tracking (counter) values (1);
    commit;
    exception
      when dup_val_on_index then
    l_query := 'Update ' ||l_tname||'@'||l_instance||' set ' ||l_column_name|| ' = q''['||l_col_value||']''  where ' ||l_column_name|| ' = q''['||l_eng_value||']'' and language = '''||l_language||'''';
    DBMS_OUTPUT.PUT_LINE('This query caused DUP_VAL_ON_INDEX exception: '||l_query);
    when others then
    l_query := 'Update ' ||l_tname||'@'||l_instance||' set ' ||l_column_name|| ' = q''['||l_col_value||']''  where ' ||l_column_name|| ' = q''['||l_eng_value||']'' and language = '''||l_language||'''';
    DBMS_OUTPUT.PUT_LINE('This caused an undefined exception: '||l_query);
    end;
    End Loop;
    l_rows_processed := tables_cur%rowcount;
    update gse_lng_jobs set rows_processed = l_rows_processed, rows_updated = l_rows_updated where job_id = l_app_job;
    close tables_cur;
    begin
    dbms_output.get_lines(l_messages, l_numlines);
    for i in 1..l_messages.count
    loop
    insert into gse_lng_update_exceptions(id, text, Job) values(i, l_messages(i), l_app_job);
    commit;
    end loop;
    end;
    END;

    Hoek, davidp 2, Tubby, rp0428 et al.,
    I think I'm making progress. I'm researching and trying to incorporate your suggestions.
    I worked through the examples of error logging here: http://www.oracle.com/technetwork/issue-archive/2006/06-mar/o26performance-096310.html. I'm not sure if this will work for me though since I'm updating many tables and not just one. So it seems I would need to run this for every table that I'm updating?
    BEGIN
            DBMS_ERRLOG.CREATE_ERROR_LOG('[table_name]');
    END;
    Otherwise, this is the current state of things:
    create or replace
    procedure gse_lng_test_1 (p_table varchar2, p_column varchar2) *--using proper parameter names prefixed with 'p' to distinguish from local variables*
    IS
    i number;
    l_query VARCHAR2(4000);
    l_messages dbms_output.chararr;
    l_numlines integer := 1000; -- retrieves max 1000 messages from the buffer
    l_rows_updated number := 0;
    l_rows_processed number;
    BEGIN
    DBMS_OUTPUT.ENABLE(1000000);
    commit;
    l_query := 'Update ' ||p_table||' set ' ||p_column|| ' = :newval where '||p_column|| ' = :engval and language = :lang' ; *--build the string once in a local variable with bind variables. Table names and column names are passed via parameters*
    for c2 IN (SELECT TABLE_NAME, COLUMN_NAME, COLUMN_VALUE, eng_value, LANGUAGE FROM GSE_LNG_STRINGS WHERE COMPLETION_STATUS = 'Y' and table_name = p_table and column_name = p_column) *--using implicit cursor instead of explicit cursor*
    LOOP
    BEGIN
    EXECUTE IMMEDIATE l_query USING c2.eng_value, c2.column_value, c2.language; *--execute immediate with bind variables*
    exception
      when dup_val_on_index then
      dbms_output.put_line('this query caused a dup_val_on_index: '||SQLERRM||' - '||l_query); *--include SQLERRM in message*
    when others then
    dbms_output.put_line('this query caused an exception: '||SQLERRM||' - '||l_query); *--include SQLERRM in message*
    end;
    commit;
    end loop;
    end;Now that the table names and column names are in parameters, I am calling this from APEX as follows:
    Begin
    for c1 in (select distinct table_name, column_name from gse_lng_strings)
    LOOP
    gse_lng_test_1 (p_table=> c1.table_name, p_column=>c1.column_name);
    end loop;
    end;The one thing I need to do is to get a status of the number of rows processed and updated so I can report back to APEX realtime with a jquery counter plugin that I'm using. That was the reason I was inserting records into a dummy table (gse_update_tracking) before. It worked ok but I realize it was a clumsy approach. I'm not to sure how to accomplish that since I don't think I can access sql%rowcount while the loop is running. Is that correct and if so, are there any other options?
    I know I still need to deal with my exception handling and I would like to use the DML error logging if at all possible.
    Overall though I feel like it's much cleaner and more manageable. Hopefully it's looking better?
    thanks again for the education - I really appreciate it,
    John

  • Possible to find session/user who ran SQL in v$SQLAREA ?

    Using this:
    select * from v$sqlarea where sql_text like '%2412982%' and sql_text like '%prms%' and module != 'sqlplusw.exe';
    I am able to locate a particular instance of a piece of SQL being executed and stored in the library cache.
    However, I would really like to know who run it but I never "catch them".
    Is there a way?
    1* select * from v$sqlarea where sql_text like '%2412982%' and sql_text like '%prms%' and module != 'sqlplusw.exe'
    SQL> /
    SQL_TEXT
    SHARABLE_MEM PERSISTENT_MEM RUNTIME_MEM SORTS VERSION_COUNT LOADED_VERSIONS OPEN_VERSIONS USERS_OPENING FETCHES EXECUTIONS USERS_EXECUTING LOADS FIRST_LOAD_TIME INVALIDATIONS
    PARSE_CALLS DISK_READS BUFFER_GETS ROWS_PROCESSED COMMAND_TYPE OPTIMIZER_MODE PARSING_USER_ID PARSING_SCHEMA_ID KEPT_VERSIONS ADDRESS HASH_VALUE
    MODULE MODULE_HASH ACTION ACTION_HASH SERIALIZABLE_ABORTS CPU_TIME ELAPSED_TIME I
    CHILD_LATCH
    select it.company, it.product, p.description, it.transaction_code, ifsapp.km_util_api.conv_to_date_fmt(it.company,to_date(it.transaction_date,'YYYY-MM-DD')) order_date, it.reference, it.wareh
    ouse_id warehouse, it.transaction_quantity, it.inventory_unit_of_measure, it.location_aisle, it.location_row, it.location_tier, it.lot_identifier, it.user_profile, it.reference_2, it.referenc
    e_3 from ifsapp.prms_inventory_transaction it, ifsapp.prms_product p where it.company=p.company (+) and it.product=p.product (+) and it.company=upper('OKM') and ((it.lot_identifier like upp
    er('%2412982%')) or ('' is not null and it.lot_identifier like upper('%%')) or ('' is not null and it.lot_identifier like upper('%%')) or ('' is not null and it.lot_identifier like upper('%%')) or
    ('' is not null and it.lot_identifier like upper('%%'))) and (('' is null or rtrim(it.product)=upper('')) or (rtrim(it.product)=upper('')) or (rtrim(it.product)=upper('')) or (rtrim(it.product)=
    8328 3616 17240 1 1 0 1 1 1 1 0 1 2006-09-28/08:47:09 0
    1 134719 134846 0 3 CHOOSE 166 166 0 07000004A8D88FB0 1040757058
    Repetitive Distribution.exe 0 0 0 34410000 58880847 N
    3

    I think the SQL listed is wrong, as it only display the SQL created by Oracle whenever the user login, which is:
    SELECT DECODE('A','A','1','2') FROM DUAL
    And all subsequent SQL issued by the user during the session is not listed.
    I am also in the midst of trying of get the user issuing the SQL :-).....MANY THANKS AHEAD....

  • Get All sql history in oracle 10g

    How to get all select and insert statement from the beginning in the oracle? I tried, "select * from v$sqlarea;" but it's giving only today results, but i need all select and insert statement from the beginning where oracle installed or before particular month. Thanks in advance.

    Thanks Sir for sharing this pause feature with query output
    col stmtid 
    heading 'Stmt Id'          
    format
    9999999999
    col dr     
    heading 'PIO blks'         
    format   999,999,999
    col bg     
    heading 'LIOs'             
    format   999,999,999
    col sr     
    heading 'Sorts'            
    format  
    999,999
    col exe    
    heading 'Runs'             
    format   999,999,999
    col rp     
    heading 'Rows'             
    format 9,999,999,999
    col rpr    
    heading 'LIOs|per Row'     
    format   999,999,999
    col rpe    
    heading 'LIOs|per Run'     
    format   999,999,999
    col sqltxt    heading 'SQL Statement'  
    format A25 word_wrapped
    set pause
    on
    set pagesize  30
    set pause
    'More: '
    set linesize  120
    select  s.hash_value stmtid
    ,t.sql_text sqltxt
    ,sum(s.disk_reads) dr
    ,sum(s.buffer_gets) bg
    ,sum(s.rows_processed) rp
    ,sum(s.buffer_gets)/greatest(sum(s.rows_processed),1) rpr
    ,sum(s.executions) exe
    ,sum(s.buffer_gets)/greatest(sum(s.executions),1) rpe
    from v$sql s, v$sqltext t
    where s.command_type in ( 2,3,6,7 )
      and s.hash_value = t.hash_value
    group by s.hash_value, t.sql_text
    order by 5 desc

  • Help for identifing top sql statements

    Hi all,
    We are doing load testing on oracle 9i with 500 concurent users. At some point of
    time the database was hang. I would like to know which query is taking more time/
    which resource occuping more. Can any body help in this regard.
    Thanks in advance

    Some useful information can be found in V$SQLAREA, for example :
    SQL> select SQL_TEXT, EXECUTIONS, DISK_READS, BUFFER_GETS, ROWS_PROCESSED, CPU_TIME, ELAPSED_TIME
      2  from v$sqlarea
      3* order by CPU_TIME desc;

  • 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

  • Dynamic pl/sql in pro*c/c++

    I have a stored procedure to query and will receive a result by it....
    I used the dbms_sql package to give name of the table at run-time
    then it runs in sql*plus well...
    but If i called it in pro*c/c++, it would not return result...
    This is my examples..
    (1) stored procedure
    CREATE OR REPLACE PACKAGE XDMS_STORE_PKG
    IS
    PROCEDURE isExistInstance(table_name IN VARCHAR2, url IN VARCHAR2, num OUT N
    UMBER);
    END XDMS_STORE_PKG;
    CREATE OR REPLACE PACKAGE BODY XDMS_STORE_PKG IS
    PROCEDURE isExistInstance (table_name IN VARCHAR2, url IN VARCHAR2, num OUT NUMBER)
    IS
    cursor1 integer;
    rows_processed integer;
    tmp NUMBER;
    tmp_char VARCHAR2(10);
    BEGIN
    cursor1 := dbms_sql.open_cursor;
    dbms_sql.parse (cursor1, 'SELECT count(*) FROM ' &#0124; &#0124; table_name &#0124; &#0124; ' WHERE DocURL = ' &#0124; &#0124; ':x', dbms_sql.v7);
    dbms_sql.bind_variable(cursor1, 'x', url);
    dbms_sql.define_column (cursor1, 1, tmp);
    rows_processed := dbms_sql.execute (cursor1);
    loop
    if dbms_sql.fetch_rows (cursor1) > 0 then
    dbms_sql.column_value (cursor1, 1, tmp);
    num := tmp;
    else
    exit;
    end if;
    end loop;
    dbms_sql.close_cursor (cursor1);
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line(sqlerrm);
    if dbms_sql.is_open (cursor1) then
    dbms_sql.close_cursor (cursor1);
    end if;
    END isExistInstance;
    END XDMS_STORE_PKG;
    (2) In the sqlplus
    set serveroutput on;
    DECLARE
    cnt NUMBER;
    dtdid VARCHAR2(10) := 'DT_AAAAC';
    url VARCHAR2(200) := 'http://www.ce.cnu.ac.kr/~xdms/data/personnel.xml';
    BEGIN
    XDMS_STORE_PKG.isExistInstance(dtdid, url, cnt);
    dbms_output.put_line(to_char(cnt));
    END;
    (3) In the pro*c/c++
    bool StorageManager::isExistInstance(char *this_url)
    EXEC SQL BEGIN DECLARE SECTION;
    int count = 0;
    char dtdid[6];
    char url[200];
    EXEC SQL END DECLARE SECTION;
    if(isNewDtd) return false;
    sprintf(dtdid, "DT_%s", this_dtdid);
    strcpy(url, this_url);
    EXEC SQL EXECUTE
    BEGIN
    XDMS_STORE_PKG.isExistInstance(:dtdid, :url, :count);
    END;
    END-EXEC;
    if(count < 1) return false;
    else return true;
    thanks...
    null

    This is tough it seems. However here are a few thoughts if they can help:
    - Generate(build) a dynamic pl/sql block like :
    Begin
    Your Procedure Name
    End;
    keep building this piece of code for each one of your procedures in C or C++. And then execute it as any PL/sql code in the form of a 'constructed' string. Pro*C also has DEscribe Using BInd, but i do not know if that can help.

  • Reg: Rows_Processed column in v$SQLAREA

    Hi all,
    I had a request to check the rows processed while an insert statement is running in the database.
    Can anyone clarify me on this from v$sqlarea (rows_processed) is it possible to get the rows processed till that time.
    As i am in thinking that it depends on how application has commit transactions.
    Can any one throw some light on this request...
    Thanks in advance...
    Satya G

    Hi,
    Rows_processed column of v$sql gives the count of total rows that has been processed whether it is committed or not committed. It gives the sum of rows processed by the query even if some of the transaction has been rollbacked.
    I suppose you are looking for USED_UREC in v$transaction.
    Regards
    Anurag

  • SQL monitoring scripts

    Hi Gurus,
    I need a whole bunch of SQL monitoring SQLs in other words some data dictionary SQL scripts to monitor SQLs like following
    --Top 5 worst sqls
    select c.*
    from (select disk_reads, buffer_gets, rows_processed, executions,
    -- address,
    -- hash_value,
    first_load_time, sql_text
    from v$sqlarea
    where parsing_user_id !=0
    order by buffer_gets/decode(executions,null,1,0,1,executions) desc ) c
    where rownum <= 5
    order by disk_reads desc;
    Thanks
    Amitava.

    Just look at the AWR data / run an AWR report.
    See DBA_HIST_SQLSTAT.

  • SQL - Highest Physical Reads

    Dear Experts,
    I want to find out the query (sql id) that contributed to highest number of physical reads over a 24 hours period (snap id's 1 to 24) by a specific user - 'USER'
    I'm using query as below, don't think it's giveing me right..any suggestions pls
    select sql_id, PHYSICAL_READ_BYTES_DELTA from DBA_HIST_SQLSTAT
    where PARSING_SCHEMA_NAME = 'USER' and snap_id between 1 and 24 order by PHYSICAL_READ_BYTES_DELTA;

    You can try this
    select substr(sql_text,1,500) "SQL",
                                          (cpu_time/1000000) "CPU_Seconds",
                                          disk_reads "Disk_Reads",
                                          buffer_gets "Buffer_Gets",
                                          executions "Executions",
                                          case when rows_processed = 0 then null
                                               else round((buffer_gets/nvl(replace(rows_processed,0,1),1)))
                                               end "Buffer_gets/rows_proc",
                                          round((buffer_gets/nvl(replace(executions,0,1),1))) "Buffer_gets/executions",
                                          (elapsed_time/1000000) "Elapsed_Seconds",
                                          module "Module"
                                     from v$sql s
                                    order by disk_reads desc nulls lastYou can get this from the SQL DEveloper --reports-database administration-Topsql-diskreads                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • V$SQL View underlying definition

    HI
    Is it possible to get underlying deifintion of v$views ? ( if i query text from dba_views i see v_$sql is selecting from v$sql)
    I want to know what are the underlying tables used for v$sql.How can i find that
    Thanks

    sb92075 wrote:
    894365 wrote:
    HI
    Is it possible to get underlying deifintion of v$views ? ( if i query text from dba_views i see v_$sql is selecting from v$sql)
    I want to know what are the underlying tables used for v$sql.How can i find thatAny/all of the V$* "views" query SGA data structures & are presented as regular SQL Views.Which may be true, but doesn't answer his question.
    The way it works is, let's take V$SQL as an example:
    SQL> select owner,object_type,object_name from dba_objects where object_name='V$SQL';
    OWNER        OBJECT_TYPE            OBJECT_NAME
    PUBLIC        SYNONYM            V$SQL
    SQL> So, V$SQL is actually a public synonym. Let's see what it points at:
    SQL> exec print_table('select owner,synonym_name,table_owner,table_name,db_link from dba_synonyms where owner=''PUBLIC'' and synonym_name = ''V$SQL''');
    OWNER                     : PUBLIC
    SYNONYM_NAME                : V$SQL
    TABLE_OWNER                : SYS
    TABLE_NAME                : V_$SQL
    DB_LINK                 :
    PL/SQL procedure successfully completed.Now, we can see that V$SQL is a public synonym that points to SYS.V_$SQL. Now, DBA_SYNONYMS says it's a table, but, it could also be a view. And, in this case, it is a view.
    We can see that here:
    SQL> exec print_table('select owner,object_type,object_name from dba_objects where owner=''SYS'' and object_name =''V_$SQL''');
    OWNER                     : SYS
    OBJECT_TYPE                : VIEW
    OBJECT_NAME                : V_$SQL
    PL/SQL procedure successfully completed.Ok, so V_$SQL is a view.
    Let's see what it's definition is:
    SQL> exec print_table('select text from dba_views where owner=''SYS'' and view_name = ''V_$SQL''');
    TEXT                     : select
    "SQL_TEXT","SQL_FULLTEXT","SQL_ID","SHARABLE_MEM","PERSISTENT_MEM","RUNTIME_MEM"
    ,"SORTS","LOADED_VERSIONS","OPEN_VERSIONS","USERS_OPENING","FETCHES","EXECUTIONS
    ","PX_SERVERS_EXECUTIONS","END_OF_FETCH_COUNT","USERS_EXECUTING","LOADS","FIRST_
    LOAD_TIME","INVALIDATIONS","PARSE_CALLS","DISK_READS","DIRECT_WRITES","BUFFER_GE
    TS","APPLICATION_WAIT_TIME","CONCURRENCY_WAIT_TIME","CLUSTER_WAIT_TIME","USER_IO
    _WAIT_TIME","PLSQL_EXEC_TIME","JAVA_EXEC_TIME","ROWS_PROCESSED","COMMAND_TYPE","
    OPTIMIZER_MODE","OPTIMIZER_COST","OPTIMIZER_ENV","OPTIMIZER_ENV_HASH_VALUE","PAR
    SING_USER_ID","PARSING_SCHEMA_ID","PARSING_SCHEMA_NAME","KEPT_VERSIONS","ADDRESS
    ","TYPE_CHK_HEAP","HASH_VALUE","OLD_HASH_VALUE","PLAN_HASH_VALUE","CHILD_NUMBER"
    ,"SERVICE","SERVICE_HASH","MODULE","MODULE_HASH","ACTION","ACTION_HASH","SERIALI
    ZABLE_ABORTS","OUTLINE_CATEGORY","CPU_TIME","ELAPSED_TIME","OUTLINE_SID","CHILD_
    ADDRESS","SQLTYPE","REMOTE","OBJECT_STATUS","LITERAL_HASH_VALUE","LAST_LOAD_TIME
    ","IS_OBSOLETE","IS_BIND_SENSITIVE","IS_BIND_AWARE","IS_SHAREABLE","CHILD_LATCH"
    ,"SQL_PROFILE","SQL_PATCH","SQL_PLAN_BASELINE","PROGRAM_ID","PROGRAM_LINE#","EXA
    CT_MATCHING_SIGNATURE","FORCE_MATCHING_SIGNATURE","LAST_ACTIVE_TIME","BIND_DATA"
    ,"TYPECHECK_MEM","IO_CELL_OFFLOAD_ELIGIBLE_BYTES","IO_INTERCONNECT_BYTES","PHYSI
    CAL_READ_REQUESTS","PHYSICAL_READ_BYTES","PHYSICAL_WRITE_REQUESTS","PHYSICAL_WRI
    TE_BYTES","OPTIMIZED_PHY_READ_REQUESTS","LOCKED_TOTAL","PINNED_TOTAL","IO_CELL_U
    NCOMPRESSED_BYTES","IO_CELL_OFFLOAD_RETURNED_BYTES" from v$sql
    PL/SQL procedure successfully completed.Huh? How can V_$SQL be based on V$SQL, when V$SQL is a synonym that points to V_$SQL??
    Well, this is where the trick comes in. SYS.V$SQL is a fixed view, i.e. a view that is owned by SYS and starts with 'V$' or 'GV$'.
    So, we can look at V$FIXED_VIEW_DEFINITION to see the definition of SYS.V$SQL:
    SQL> exec print_table('select view_definition from v$fixed_view_definition where view_name = ''V$SQL''');
    VIEW_DEFINITION            : select     SQL_TEXT , SQL_FULLTEXT , SQL_ID,
    SHARABLE_MEM , PERSISTENT_MEM , RUNTIME_MEM , SORTS , LOADED_VERSIONS ,
    OPEN_VERSIONS , USERS_OPENING , FETCHES , EXECUTIONS , PX_SERVERS_EXECUTIONS ,
    END_OF_FETCH_COUNT, USERS_EXECUTING , LOADS , FIRST_LOAD_TIME, INVALIDATIONS,
    PARSE_CALLS , DISK_READS , DIRECT_WRITES , BUFFER_GETS , APPLICATION_WAIT_TIME,
    CONCURRENCY_WAIT_TIME, CLUSTER_WAIT_TIME, USER_IO_WAIT_TIME, PLSQL_EXEC_TIME,
    JAVA_EXEC_TIME, ROWS_PROCESSED , COMMAND_TYPE , OPTIMIZER_MODE , OPTIMIZER_COST,
    OPTIMIZER_ENV, OPTIMIZER_ENV_HASH_VALUE, PARSING_USER_ID , PARSING_SCHEMA_ID ,
    PARSING_SCHEMA_NAME, KEPT_VERSIONS , ADDRESS , TYPE_CHK_HEAP , HASH_VALUE,
    OLD_HASH_VALUE, PLAN_HASH_VALUE, CHILD_NUMBER, SERVICE, SERVICE_HASH, MODULE,
    MODULE_HASH , ACTION , ACTION_HASH ,  SERIALIZABLE_ABORTS , OUTLINE_CATEGORY,
    CPU_TIME, ELAPSED_TIME, OUTLINE_SID, CHILD_ADDRESS, SQLTYPE, REMOTE,
    OBJECT_STATUS, LITERAL_HASH_VALUE, LAST_LOAD_TIME, IS_OBSOLETE,
    IS_BIND_SENSITIVE, IS_BIND_AWARE, IS_SHAREABLE,CHILD_LATCH, SQL_PROFILE,
    SQL_PATCH, SQL_PLAN_BASELINE, PROGRAM_ID, PROGRAM_LINE#,
    EXACT_MATCHING_SIGNATURE, FORCE_MATCHING_SIGNATURE, LAST_ACTIVE_TIME, BIND_DATA,
    TYPECHECK_MEM, IO_CELL_OFFLOAD_ELIGIBLE_BYTES, IO_INTERCONNECT_BYTES,
    PHYSICAL_READ_REQUESTS, PHYSICAL_READ_BYTES, PHYSICAL_WRITE_REQUESTS,
    PHYSICAL_WRITE_BYTES, OPTIMIZED_PHY_READ_REQUESTS, LOCKED_TOTAL, PINNED_TOTAL,
    IO_CELL_UNCOMPRESSED_BYTES, IO_CELL_OFFLOAD_RETURNED_BYTES from GV$SQL where
    inst_id = USERENV('Instance')
    PL/SQL procedure successfully completed.So, SYS.V$SQL is based on GV$SQL. So, what's GV$SQL??
    SQL> exec print_table('select owner,object_type,object_name from dba_objects where object_name =''GV$SQL''');
    OWNER                     : PUBLIC
    OBJECT_TYPE                : SYNONYM
    OBJECT_NAME                : GV$SQL
    PL/SQL procedure successfully completed.Another synonym?? Where does it all end?? (Hang in there, we're almost there!)
    So, what does the GV$SQL synonym point to?
    SQL> exec print_table('select * from dba_synonyms where owner=''PUBLIC'' and synonym_name = ''GV$SQL''');
    OWNER                     : PUBLIC
    SYNONYM_NAME                : GV$SQL
    TABLE_OWNER                : SYS
    TABLE_NAME                : GV_$SQL
    DB_LINK                 :
    PL/SQL procedure successfully completed.Ok, so, now we have GV_$SQL. What's that, exactly? Is it really a table? Or perhaps another view?
    SQL> exec print_table('select owner,object_type,object_name from dba_objects where owner=''SYS'' and object_name = ''GV_$SQL''');
    OWNER                     : SYS
    OBJECT_TYPE                : VIEW
    OBJECT_NAME                : GV_$SQL
    PL/SQL procedure successfully completed.Ok, so GV_$SQL is another view. Let's look at that definition!
    SQL> exec print_Table('select text from dba_views where owner=''SYS'' and view_name = ''GV_$SQL''');
    TEXT                     : select
    "INST_ID","SQL_TEXT","SQL_FULLTEXT","SQL_ID","SHARABLE_MEM","PERSISTENT_MEM","RU
    NTIME_MEM","SORTS","LOADED_VERSIONS","OPEN_VERSIONS","USERS_OPENING","FETCHES","
    EXECUTIONS","PX_SERVERS_EXECUTIONS","END_OF_FETCH_COUNT","USERS_EXECUTING","LOAD
    S","FIRST_LOAD_TIME","INVALIDATIONS","PARSE_CALLS","DISK_READS","DIRECT_WRITES",
    "BUFFER_GETS","APPLICATION_WAIT_TIME","CONCURRENCY_WAIT_TIME","CLUSTER_WAIT_TIME
    ","USER_IO_WAIT_TIME","PLSQL_EXEC_TIME","JAVA_EXEC_TIME","ROWS_PROCESSED","COMMA
    ND_TYPE","OPTIMIZER_MODE","OPTIMIZER_COST","OPTIMIZER_ENV","OPTIMIZER_ENV_HASH_V
    ALUE","PARSING_USER_ID","PARSING_SCHEMA_ID","PARSING_SCHEMA_NAME","KEPT_VERSIONS
    ","ADDRESS","TYPE_CHK_HEAP","HASH_VALUE","OLD_HASH_VALUE","PLAN_HASH_VALUE","CHI
    LD_NUMBER","SERVICE","SERVICE_HASH","MODULE","MODULE_HASH","ACTION","ACTION_HASH
    ","SERIALIZABLE_ABORTS","OUTLINE_CATEGORY","CPU_TIME","ELAPSED_TIME","OUTLINE_SI
    D","CHILD_ADDRESS","SQLTYPE","REMOTE","OBJECT_STATUS","LITERAL_HASH_VALUE","LAST
    _LOAD_TIME","IS_OBSOLETE","IS_BIND_SENSITIVE","IS_BIND_AWARE","IS_SHAREABLE","CH
    ILD_LATCH","SQL_PROFILE","SQL_PATCH","SQL_PLAN_BASELINE","PROGRAM_ID","PROGRAM_L
    INE#","EXACT_MATCHING_SIGNATURE","FORCE_MATCHING_SIGNATURE","LAST_ACTIVE_TIME","
    BIND_DATA","TYPECHECK_MEM","IO_CELL_OFFLOAD_ELIGIBLE_BYTES","IO_INTERCONNECT_BYT
    ES","PHYSICAL_READ_REQUESTS","PHYSICAL_READ_BYTES","PHYSICAL_WRITE_REQUESTS","PH
    YSICAL_WRITE_BYTES","OPTIMIZED_PHY_READ_REQUESTS","LOCKED_TOTAL","PINNED_TOTAL",
    "IO_CELL_UNCOMPRESSED_BYTES","IO_CELL_OFFLOAD_RETURNED_BYTES" from gv$sql
    PL/SQL procedure successfully completed.Another GV$SQL?? Does this ever end???
    Back to V$FIXED_VIEW_DEFINITION for the final round:
    SQL> exec print_table('select view_definition from v$fixed_view_definition where view_name = ''GV$SQL''');
    VIEW_DEFINITION            : select inst_id,kglnaobj,kglfnobj,kglobt03,
    kglobhs0+kglobhs1+kglobhs2+kglobhs3+kglobhs4+kglobhs5+kglobhs6+kglobt16,
    kglobt08+kglobt11, kglobt10, kglobt01, decode(kglobhs6,0,0,1),
    decode(kglhdlmd,0,0,1), kglhdlkc, kglobt04, kglobt05, kglobt48, kglobt35,
    kglobpc6, kglhdldc, substr(to_char(kglnatim,'YYYY-MM-DD/HH24:MI:SS'),1,19),
    kglhdivc, kglobt12, kglobt13, kglobwdw, kglobt14, kglobwap, kglobwcc, kglobwcl,
    kglobwui, kglobt42, kglobt43, kglobt15, kglobt02, decode(kglobt32,       0,
    'NONE',        1, 'ALL_ROWS',          2, 'FIRST_ROWS',          3, 'RULE',
    4, 'CHOOSE',            'UNKNOWN'), kglobtn0, kglobcce, kglobcceh, kglobt17,
    kglobt18, kglobts4, kglhdkmk, kglhdpar, kglobtp0, kglnahsh, kglobt46, kglobt30,
    kglobt09, kglobts5, kglobt48, kglobts0, kglobt19, kglobts1, kglobt20, kglobt21,
    kglobts2, kglobt06, kglobt07, decode(kglobt28, 0, to_number(NULL), kglobt28),
    kglhdadr, kglobt29, decode(bitand(kglobt00,64),64, 'Y', 'N'), decode(kglobsta,
    1, 'VALID',        2, 'VALID_AUTH_ERROR',      3, 'VALID_COMPILE_ERROR',
    4, 'VALID_UNAUTH',       5, 'INVALID_UNAUTH',           6, 'INVALID'), kglobt31,
    substr(to_char(kglobtt0,'YYYY-MM-DD/HH24:MI:SS'),1,19), decode(kglobt33, 1, 'Y',
    'N'),  decode(bitand(kglobacs, 1), 1, 'Y', 'N'),  decode(bitand(kglobacs, 2), 2,
    'Y', 'N'),  decode(bitand(kglobacs, 4), 4, 'Y', 'N'),  kglhdclt, kglobts3,
    kglobts7, kglobts6, kglobt44, kglobt45,  kglobt47, kglobt49, kglobcla,
    kglobcbca, kglobt22, kglobt52, kglobt53, kglobt54, kglobt55,  kglobt56,
    kglobt57, kglobt58, kglobt23, kglobt24, kglobt59,  kglobt53 -
    ((kglobt55+kglobt57) - kglobt52)  from x$kglcursor_childSo, here we are, finally, we get to the fabled 'X$' table! An X$ table is hardcoded into the Oracle kernel, and it's a table projection of a chunk of the SGA memory. It's can't be updated, only queried, and is not subject to read consistency.
    I'm sure this post will raise questions, but it's already too long, so, I'll leave it at that.
    Feel free to ask follow up questions, and I'll try to address them.
    Hope that helps,
    -Mark

  • Quick question about expensive SQL

    Hello
    I want to run queries to get the most expensive and most often run SQL statements without running the statspack snapshots. Which tables/views would I need to query? Would V$SQL or V$SQL_TEXT be ok or would other tables be better?
    Cheers
    David

    David:
    Either v$sql or v$sqlarea will give you some statistics like disk_reads, buffer_gets, and rows_processed which you can use as a measure of "expensiveness", and executions, and users_executing which link to the number of executions. Both views show only the first 1000 bytes of the sql statement. You can join to v$sql_text to get the full text if your sql is longer than 1000 characters.
    The downside to this approach, using a one-shot query, is that v$sqlarea only shows the sql currently in the shared pool. Since the statistics are only accumulated while the query in in the shared pool, you may miss an expensive and/or frequently run query if it had been aged out of the pool at any time.
    Even if you do not want to run a full statspack report, I would suggest you want to take a similar approach. Collect the data at several times during the day over a short window. For example, at 09:00 and at 09:15, then at 11:00 and at 11:15, then at 13:00 and 13:15, then finally at 15:00 and at 15:15. Do this for a few days.
    If your business is cyclical, then you need to do this through a full cycle. For example, one system I support is a payroll system. The load on the system, and the sql being executed is very different in the two or three days before the payroll calculation (when everyone is entering their time cards for the two week pay period), than in the two or three days after the payroll calculation (when it is mostly the Payroll department doing corrections and producing bank deposits and cheques). For a GL system, you would probably want to gather data early in the month, and again during month-end processing.
    HTH
    John

Maybe you are looking for

  • Part payment in vendor

    Hello team, I have problem with my client,the requirement is: vendor wants part payments also to be shown against the full value of particular bill(s) any excess amount not to be shown as part payment of a bill in particular money receipt. Can u plea

  • Validation not working for FK01

    Hi Guys, I have written a validation using GGB0 where in i want to restrict a user for using the transaction code in FK01. I have given the prerequisite as below SYST-UNAME = 'SRIKANTHD' AND SYST-TCODE = 'FK01' and Check = False Then give an error me

  • Safari 3 font too bold

    I have scoured Google and this forum and find no one talking about this, yet I have seen it on several machines: Safari 3 is making my bold fonts "crazy bold"... The problem does not exist in Safari 2, and removing the bold just makes the font look r

  • Stuck while installing Essbase

    Hello Am installing Essbase on Windows 2008 R2 server and while am installing Essbase am getting stuck while the Essbase is installing OPMN . Am not able to go beyond that. Please help me with this.

  • Recover a deleted record / table

    Hello, Our Oracle DB (10.2.0.4) is on archive mode. But flashback is not enabled In such cases, If a user deleted a table entry / a entire table itself, Is it possible to recover How to solve this kind of a issue. Is it really deleting from the DB or