V$SQL V$SQLAREA V$SQLTEXT

hi,
Can any one please confirm
Oracle DOC says that
V$SQL contains the details regarding the SQL statements that are already executed and for long running queries details are updated every five seconds -------------> this means that this view contains only past executed sql statements
V$SQLAREA contains the details regarding the SQL statements that are ready to be executed -------------> this means that these statements will execute
V$SQLTEXT contains the details regarding the SQL statements that are currently being executed right?
can any one please confirm.
thanks

855370 wrote:
hi,
Can any one please confirm
Oracle DOC says that
V$SQL contains the details regarding the SQL statements that are already executed and for long running queries details are updated every five seconds -------------> this means that this view contains only past executed sql statements
V$SQLAREA contains the details regarding the SQL statements that are ready to be executed -------------> this means that these statements will execute
V$SQLTEXT contains the details regarding the SQL statements that are currently being executed right?
can any one please confirm.
thanksYou might take a close look at the Oracle documentation again:
http://download.oracle.com/docs/cd/E14072_01/server.112/e10820/dynviews_3042.htm
http://download.oracle.com/docs/cd/E11882_01/server.112/e17110/dynviews_3064.htm
http://download.oracle.com/docs/cd/E14072_01/server.112/e10820/dynviews_3067.htm
A SQL statement may appear in all three views even if it was never executed (it just needs to be parsed).
Notice that CHILD_NUMBER and CHILD_ADDRESS appear in V$SQL but not V$SQLAREA - the description in the documentation explains why. The columns listed for V$SQLTEXT provide a clue what that view shows.
(Note that my answer is intentionally slightly vague just in case this is a question found on an exam of some sort.)
Charles Hooper
Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
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

  • 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

  • How do I know the bind variables in sql_text of V$sql

    I query V$sql ,v$sqlarea,V$SQLTEXT, the sql_text show like select customer_name from customer where id = :B1;
    How can I to get the value of :B1?
    I want to know the entire SQL command, What should I do?

    Satish Kandi wrote:
    Not too sure but check out GV$SQL_BIND_CAPTURE.Satish,
    I remembered reading an anomaly that JL posted about it, I guess it would be helpful for OP to know that there may be parameters which can tweakthe behaviour of this view.
    http://jonathanlewis.wordpress.com/2008/07/24/bind-capture/
    Regards
    Aman....

  • How do I find out what I'm doing in a package ? v$sql ? etc.

    I'm running Linux and trying to find out at what point a process is at.
    It is running a procedure in a package, lets say. Package_main.main(). If I join v$session to any of v$sql,v$sqlarea,v$sqltext all I get is the sql text relating to the "package_main.main()" call. I want to find out what point in the PL/SQL statck the execution is : what view should I be looking at ?
    johnnie d

    I believe the problem you are describing has been identified as a design feature for 10g+. I have not spent any time looking at the issue.
    If you do not need immediate access but want to see what a session was doing you might be able to turn on sql trace for an active session and then review the trace file after you have allowed the trace to run long enough to capture what SQL is being executed.
    Being that all SQL would have a child cursor there should be a way to tie sql from within pl/sql being executed to the session executing the stored code. I just have not looked into this. Maybe someone else has.
    HTH -- Mark D Powell --

  • Which view contains the exact sql statement

    Dear All,
    Developers have used bind variables in their sql inside their applications (for example: SELECT Name FROM Employee WHERE EmployeeID =:empno)
    This bind variable is supplied a value within the application. I wanted to know which data dictionary view will give me the exact sql statement which gets executed.
    For example SELECT Name FROM Employee WHERE EmployeeID = 100;
    When I query V$SQL, V$SQLAREA, V$SQLTEXT, I get the same query with the bind variables (SELECT Name FROM Employee WHERE EmployeeID =:empno), instead can i get the query which actually holds the value for the bind variable.
    Regards,
    qA

    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4254158186083#75306330816538

  • Area or view of sql sentences with error??

    Hi Gurus!
    I wanna know if is there any view or something like that, where I can look for a sql sentence with error?
    The views V$SQL, V$SQLAREA, V$SQLTEXT doesn't work for that because they have de last rigth sql sentences and I need the last with error.
    Thanks in advance.

    SQL Developer maintains a history of the SQL statements that it has issued over time. That is a purely client-side function, though, it just tells you what SQL has been issued by the local client. It doesn't tell you anything about what SQL has been sent to the server by other client applications on the client machine or from other client machines.
    Justin

  • How to see SQLs for a database session ?

    I am on Oracle 8.1.7 in AIX.
    I can see all the session details in v$session , also I can look at the SQLs being executed on the server in v$sqlarea and v$sqltext.
    If I want to see, for a given database session, what are the SQLs those are run ? how can I do that ?
    Can I do that or not ???
    Please guide .
    Regards

    with this query you can know what are all views related
    to SQL Statements:
    SQL> select table_name from dictionary
    2 where table_name like '%SQL%';
    TABLE_NAME
    GV$SQL
    GV$SQLAREA
    GV$SQLTEXT
    GV$SQLTEXT_WITH_NEWLINES
    GV$SQL_BIND_DATA
    GV$SQL_BIND_METADATA
    GV$SQL_CURSOR
    GV$SQL_SHARED_CURSOR
    GV$SQL_SHARED_MEMORY
    V$SQL
    V$SQLAREA
    TABLE_NAME
    V$SQLTEXT
    V$SQLTEXT_WITH_NEWLINES
    V$SQL_BIND_DATA
    V$SQL_BIND_METADATA
    V$SQL_CURSOR
    V$SQL_SHARED_CURSOR
    V$SQL_SHARED_MEMORY
    18 rows selected.
    and here you can get information of each one:
    Catalog Views / Data Dictionary Views
    http://otn.oracle.com/pls/db92/db92.catalog_views?remark=homepage
    Joel P�rez

  • Find a user

    Hi All,
    If 10 users connected to my database, and one user executed some query and it was hanged or didn't get any result.
    now the database is running slow, so i want to find the user who runs that query.
    for v$session we can find the connected username, but how can we find which user executed that query????.
    using 10g with windows Xp
    Regards
    S.Senthil Kumar

    Check
    V$SQL
    V$SQLAREA
    V$SQLTEXT
    Sorry this will show the sql_text information.
    Regards,
    Sabdar Syed.
    Message was edited by:
    Sabdar Syed

  • Shared Pool utilisation

    Hello Team:
    I ran a metalink script to report the shared pool utilization recently. I took this output when the database was on peak load.
    SQL> /
    Obj mem: 66435759 bytes (63.36MB)
    Shared sql: 324219036 bytes (309.2MB)
    Cursors: 341207073 bytes (325.4MB)
    Free memory: 67228508 bytes (64.11MB)
    Shared pool utilization (total): 468785754 bytes (447.07MB)
    Shared pool allocation (actual): 754974720bytes (720MB)
    Percentage Utilized: 91%
    does this mean I have to add more space to shared pool. If so what is the threshold value?
    Regards,
    Bala

    Bhawani nandan Prasad - Principal DBA -- See a to z diagnostics about Shared pool
    1. Memory     2
    a. Shared Pool     2
    1. Introduction     2
    2. Architecture     2
    3. Scripts for different DBA tasks:     5
    a.Measure object usage inside the shared pool and Tune shared pool     7
    b.Check reload problem in library cache     12
    c.Find the large queries in the shared pool library cache (using > 4mb each)     13
    d.Find objects that can be considered pining into the shared pool     13
    e.LRU work and objects were loaded and flushed     13
    f.How much are waiting for Library Cache Latch     14
    g.Queries identical but aren’t shared.     14
    h.Get Biggest chunk of free memory.     14
    i.Check the shared pool reserved size status     16
    j.When having multiple subheaps:     16
    k.Check shared pool at first glance quick diagnostics     17
    l.Memory Usage - object list level view     17
    m.Loads Number of times object has been loaded     17
    n.Check number of times and object has been executed     18
    o.Check shared pool in more details     18
    p.Library Cache Statistics     18
    q.Reserve Pool Settings     19
    r.Pinned Objects     19
    s.Finding literal SQL     19
    t.Finding the Library Cache hit ratio     19
    u. Row Cache Misses – Dictionary cache stats     19
    v. Checking hash chain lengths     20
    w. Checking for high version counts     20
    x. Finding statement/s which use lots of shared pool memory     20
    y. Allocations causing shared pool memory to be 'aged' out     21
    z. Issues in various Oracle Releases     21
    4. Terminology     22
    5. Oracle 11g Caching and Pooling – SQL Result Cache     27
    6. References     37
    2. SQL     38
    3. Statistics     38
    4. Wait events     38
    5. Schema     39
    6. General     39
    a. Scripts     39
    1. accept.sql     39
    1. Memory
    a. Shared Pool
    1. Introduction
    Shared pool is used to cache different types of data such as textual and executable forms of PL/SQL blocks and SQL statements, dictionary cache data, and other data in SGA. Additional shared memory needed in the SHARED POOL if using ASM storage. Gathering schema/database stats (table/index stats) makes database query performance better and it reduce utilization of shared pool. Hence, practice to schedule job to gather stats regularly which suites your database performance. If you use shared pool effectively you can reduce resource consumption in at least four ways
    1.     Parse overhead is avoided if the SQL statement is already in the shared pool. This saves CPU resources on the host and elapsed time for the end user.
    2.     Latching resource usage is significantly reduced, which results in greater scalability.
    3.     Shared pool memory requirements are reduced, because all applications use the same pool of SQL statements and dictionary resources.
    4.     I/O resources are saved, because dictionary elements that are in the shared pool do not require disk access.
    This sharable area of memory is managed as a sophisticated cache and heap manager rolled into one. It has 3 fundamental problems to overcome:
    1.     The unit of memory allocation is not a constant - memory allocations from the pool can be anything from a few bytes to many kilobytes
    2.     Not all memory can be 'freed' when a user finishes with it (as is the case in a traditional heap manager) as the aim of the shared pool is to maximize share of information. The information in the memory may be useful to another session - Oracle cannot know in advance if the items will be of any use to anyone else or not.
    3.     There is no disk area to page out to so this is not like a traditional cache where there is a file backing store. Only "rewriteable" information can be discarded from the cache and it has to be re-created when it is next needed.
    Oracle 10g architecture of Shared pool:
    Library Cache     Shared SQL Area (Hash Value, SQL source, Execution plan)
    Data Dictionary Cache
    Enqueues     Fixed Area     Other
    Latches          
    Oracle 11g architecture of Shared pool:
    Library Cache     Shared SQL Area (Hash Value, SQL source, Execution plan)
    Data Dictionary Cache
    Result Cache
    Enqueues     Fixed Area     Other
    Latches          
    1. Library Cache
    Shared Sql Area: contains Parsed SQL and execution Plans for statements already run against the database. This area allows SQL execution plans to be reused by many users.
    Private SQL Area: Private SQL areas are non-shared memory areas assigned to unique user sessions.
    Pl/sql Area: contains the recently executed Procedures, Functions and Packages.
    Control Structures: Common control structure information example Memory for Latches and locks, sequence cache.
    2. Dictionary cache known as the row cache.
    Dictionary cache stores all the metadata info of tables and views in the database, Names and data types of the columns in the database, Object and system privileges of all the Users. Oracle maintains the stats of all the objects in the shared pool, if any of the memory objects are not used from the last 3 seconds, these memory objects will be aged out and will be removed from the cache. All the Shared Pool Structures are maintained by a LRU (least recently Used) algorithm, by which Oracle removes the objects from the shared Pool, until there is enough free space in the shared Pool to keep new Object.
    3. Scripts for different DBA tasks:
    Dictionary Views for shared POOL:
    NON-RAC
    V$DB_CACHE_ADVICE
    V$DB_OBJECT_CACHE
    V$DLM_LATCH
    V$DLM_LOCKS
    V$LATCH
    V$LATCHHOLDER
    V$LATCHNAME
    V$LATCH_CHILDREN
    V$LATCH_MISSES
    V$LATCH_PARENT
    V$LIBRARYCACHE
    V$LOCK
    V$LOCKED_OBJECT
    V$LOCKS_WITH_COLLISIONS
    V$LOCK_ACTIVITY
    V$LOCK_ELEMENT
    V$OPEN_CURSOR
    V$PROCESS
    V$PX_PROCESS
    V$PX_PROCESS_SYSSTAT
    V$PX_SESSION
    V$PX_SESSTAT
    V$ROWCACHE
    V$ROWCACHE_PARENT
    V$ROWCACHE_SUBORDINATE
    V$SESSION
    V$SESSION_CONNECT_INFO
    V$SESSION_CURSOR_CACHE
    V$SESSION_EVENT
    V$SESSION_LONGOPS
    V$SESSION_OBJECT_CACHE
    V$SESSION_WAIT
    V$SESSTAT
    V$SESS_IO
    V$SGA
    V$SGASTAT
    V$SGAINFO
    V$SGA_DYAMIC_COMPONENTS
    V$SGA_DYNAMIC_FREE_MEMORY
    V$SGA_RESIZE_OPS
    V$SGA_CURRENT_RESIZE_OPS
    v$shared_pool_advice
    V_$SHARED_POOL_ADVICE
    V$SHARED_POOL_RESERVED
    V$SHARED_SERVER
    V$SORT_SEGMENT
    V$SORT_USAGE
    V$SQL
    V$SQLAREA
    V$SQLTEXT
    V$SQLTEXT_WITH_NEWLINES
    V$SQL_BIND_DATA
    V$SQL_BIND_METADATA
    V$SQL_CURSOR
    V$SQL_SHARED_CURSOR
    V$SQL_SHARED_MEMORY
    V$STATNAME
    V$SUBCACHE
    V$SYSSTAT
    V$SYSTEM_CURSOR_CACHE
    V$SYSTEM_EVENT
    V$SYSTEM_PARAMETER
    X$KSMSP
    RAC
    GV$LATCH
    GV$LATCHHOLDER
    GV$LATCHNAME
    GV$LATCH_CHILDREN
    GV$LATCH_MISSES
    GV$LATCH_PARENT
    GV$LIBRARYCACHE
    GV$LOCK
    GV$LOCKED_OBJECT
    GV$LOCKS_WITH_COLLISIONS
    GV$LOCK_ACTIVITY
    GV$LOCK_ELEMENT
    GV$PROCESS
    GV$PX_PROCESS
    GV$PX_PROCESS_SYSSTAT
    GV$PX_SESSION
    GV$PX_SESSTAT
    GV$ROWCACHE
    GV$ROWCACHE_PARENT
    GV$ROWCACHE_SUBORDINATE
    GV$SESSION
    GV$SESSION_CONNECT_INFO
    GV$SESSION_CURSOR_CACHE
    GV$SESSION_EVENT
    GV$SESSION_LONGOPS
    GV$SESSION_OBJECT_CACHE
    GV$SESSION_WAIT
    GV$SESSTAT
    GV$SESS_IO
    GV$SGA
    GV$SGASTAT
    gv$shared_pool_advice
    GV$SHARED_POOL_RESERVED
    GV$SHARED_SERVER
    GV$SORT_SEGMENT
    GV$SORT_USAGE
    GV$SQL
    GV$SQLAREA
    GV$SQLTEXT
    GV$SQLTEXT_WITH_NEWLINES
    GV$SQL_BIND_DATA
    GV$SQL_BIND_METADATA
    GV$SQL_CURSOR
    GV$SQL_SHARED_CURSOR
    GV$SQL_SHARED_MEMORY
    GV$STATNAME
    GV$SUBCACHE
    GV$SYSSTAT
    GV$SYSTEM_CURSOR_CACHE
    GV$SYSTEM_EVENT
    GV$SYSTEM_PARAMETER
    GV$WAITSTAT
    GV$_LOCK
    a.Measure object usage inside the shared pool and Tune shared pool
    set pagesize 132
    column owner format a16
    column name format a36
    column sharable_mem format 999,999,999
    column executions format 999,999,999
    prompt
    prompt Memory Usage of Shared Pool Order - Biggest First
    prompt
    column name format 45
    select owner, name||' - '||type name, sharable_mem from v$db_object_cache
    where sharable_mem > 10000
    and type in ('PACKAGE', 'PACKAGE BODY', 'FUNCTION', 'PROCEDURE')
    order by sharable_mem desc
    prompt
    prompt Loads into Shared Pool - Most Loads First
    prompt
    select owner, name||' - '||type name, loads , sharable_mem from v$db_object_cache
    where loads > 3
    and type in ('PACKAGE', 'PACKAGE BODY', 'FUNCTION', 'PROCEDURE')
    order by loads desc
    prompt
    prompt Executions of Objects in the Shared Pool - Most Executions First
    prompt
    select owner, name||' - '||type name, executions from v$db_object_cache
    where executions > 100
    and type in ('PACKAGE', 'PACKAGE BODY', 'FUNCTION', 'PROCEDURE')
    order by executions desc
    select 'If the values for the EXEC and LOADS close increase SHARED_POOL_SIZE!' from dual ;
    set feedback off
    set linesize 80
    set pagesize 52
    clear columns
    clear breaks
    col executions HEADING EXEC
    col sharable_mem heading SHAMEM
    col owner format a8
    col name format a30
    col type format a12
    set numwidth 8
    ttitle center 'Data Base Objects Owned by All Users Statistics' skip 2
    select name, type, sharable_mem, loads, executions, pins
    from sys.v_$db_object_cache ;
    b.Check reload problem in library cache
    select namespace, pins, reloads from v$librarycache;
    show parameters shared_pool
    select bytes/1024/1024 from v$sgastat where pool='shared pool' and name='free memory';
    c.Find the large queries in the shared pool library cache (using > 4mb each)
    SELECT sql_text "Stmt", count(*), sum(sharable_mem) "Mem",
    sum(users_opening) "Open", sum(executions) "Exec"
    FROM v$sql GROUP BY sql_text HAVING sum(sharable_mem) > 4096000;
    d.Find objects that can be considered pining into the shared pool
    column name format a40
    column owner format a15
    select owner, name, executions, locks, pins, loads, kept from v$db_object_cache where loads > 10;
    create temp table and insert records of candidates to be pinned.
    CREATE TABLE LRU_TMP AS SELECT * FROM X$KSMLRU;
    INSERT INTO LRU_TMP SELECT * FROM X$KSMLRU;
    Use the LRU_TMP table for analysis.
    SELECT USERNAME, KSMLRCOM, KSMLRHON, KSMLRNUM, KSMLRSIZ, SQL_TEXT
    FROM V$SQLAREA A, LRU_TMP K, V$SESSION S WHERE KSMLRSIZ > 3000
    AND A.ADDRESS=S.SQL_ADDRESS AND A.HASH_VALUE = S.SQL_HASH_VALUE
    AND SADDR=KSMLRSES;
    You can see the candidates to pin from the query below
    COL STORED_OBJECT FORMAT A40;
    COL SQ_EXECUTIONS FORMAT 999,999;
    SELECT /*+ ORDERED USE_HASH(D) USE_HASH(C) */ O.KGLNAOWN||’.'||O.KGLNAOBJ STORED_OBJECT, SUM(C.KGLHDEXC) SQL_EXECUTIONS
    FROM SYS.X$KGLOB O, SYS.X$KGLRD D, SYS.X$KGLCURSOR C
    WHERE
    O.INST_ID = USERENV(’INSTANCE’) AND
    D.INST_ID = USERENV(’INSTANCE’) AND
    C.INST_ID = USERENV(’INSTANCE’) AND
    O.KGLOBTYP IN (7, 8, 9, 11, 12) AND
    D.KGLHDCDR = O.KGLHDADR AND
    C.KGLHDPAR = D.KGLRDHDL
    GROUP BY O.KGLNAOWN, O.KGLNAOBJ
    HAVING SUM(C.KGLHDEXC) > 0
    ORDER BY 2 DESC;
    How to pin object
    EXECUTE SYS.DBMS_SHARED_POOL.SIZES(150);
    EXECUTE SYS.DBMS_SHARED_POOL.KEEP('SYS.STANDARD');
    EXECUTE SYS.DBMS_SHARED_POOL.UNKEEP('SYS.STANDARD');
    e.LRU work and objects were loaded and flushed
    LRU work in the shared pool KSMLRNUM stores the number of objects that were flushed to load the large object. KSMLRISZ stores the size of the object that was loaded (contiguous memory allocated)
    column ksmlrcom format a20
    column username format a5
    select username,sid,KSMLRCOM,KSMLRSIZ,KSMLRNUM, KSMLRHON, KSMLROHV, KSMLRSES from x$ksmlru , v$session where KSMLRSES=SADDR and KSMLRNUM >2 ;
    f.How much are waiting for Library Cache Latch
    select count(*),event from v$session_wait where event not like '%SQL%' and event not like '%ipc%' and event not like '%timer%' GROUP BY EVENT;
    select count(*),wait_time from v$session_wait where event='latch free' and p2=106 group by wait_time;
    select sid,wait_time,seconds_in_wait from v$session_wait where event='latch free' and p2=106 and WAIT_TIME>1;
    g.Queries identical but aren’t shared.
    SELECT address, hash_value, version_count , users_opening , users_executing,
    substr(sql_text,1,240) "SQL" FROM v$sqlarea WHERE version_count > 10;
    h.Get Biggest chunk of free memory.
    select sysdate, decode( sign(ksmchsiz - 812), -1, (ksmchsiz - 16) / 4,
    decode(sign(ksmchsiz - 4012),-1, trunc((ksmchsiz + 11924) / 64),
    decode(sign(ksmchsiz - 65548), -1, trunc(1/log(ksmchsiz - 11, 2)) + 238,254))) bucket,
    sum(ksmchsiz) free_space, count(*) free_chunks, trunc(avg(ksmchsiz)) average_size,
    max(ksmchsiz) biggest from x$ksmsp
    where inst_id = userenv('Instance') and ksmchcls = 'free' group by
    decode(sign(ksmchsiz - 812),-1, (ksmchsiz - 16) / 4,
    decode(sign(ksmchsiz - 4012),-1, trunc((ksmchsiz + 11924) / 64),
    decode(sign(ksmchsiz - 65548),-1, trunc(1/log(ksmchsiz - 11, 2)) + 238,254 ))) ;
    SELECT KSMCHCLS CLASS, COUNT(KSMCHCLS) NUM, SUM(KSMCHSIZ) SIZ,
    To_char( ((SUM(KSMCHSIZ)/COUNT(KSMCHCLS)/1024)),’999,999.00′)||’k’ “AVG SIZE”
    FROM X$KSMSP GROUP BY KSMCHCLS;
    CLASS     NUM     SIZ     AVG SIZE
    freeabl     19010     34519404     1.77k
    recr     23581     24967956     1.03k
    R-freea     68     1632     .02k
    perm     22     39801268     1,766.75k
    R-free     34     7238192     207.90k
    free     2389     36075980     14.75k
    Watch for trends using these guidelines:
    a) if ‘free’ memory is low (less than 5mb or so) you may need to increase the shared_pool_size and shared_pool_reserved_size. You should expect ‘free’ memory to increase and decrease over time. Seeing trends where ‘free’ memory decreases consistently is not necessarily a problem, but seeing consistent spikes up and down could be a problem.
    b) if ‘freeable’ or ‘perm’ memory continually grows then it is possible you are seeing a memory bug.
    c) if ‘freeabl’ and ‘recr’ memory classes are always huge, this indicates that you have a lot of cursor info stored that is not releasing.
    d) if ‘free’ memory is huge but you are still getting 4031 errors, the problem is likely reloads and invalids in the library cache causing fragmentation.
    -Note says that this query can hang database on HP platforms
    See the shared pool parameters
    column name format a30
    select name,value from v$parameter where name like '%shared_pool%' ;
    select x.ksppinm, y.ksppstvl from x$ksppi x , x$ksppcv y where x.indx = y.indx and lower(x.ksppinm) like '%spin%';
    SELECT count(*) FROM v$latch_children WHERE NAME = 'library cache';
    Shrinking and growing operations from V$SGA_RESIZE_OPS dynamic view:
    select to_char(end_time, ‘dd-Mon-yyyy hh24:mi’) end, oper_type, initial_size, target_size, final_size from V$SGA_RESIZE_OPS where component=’shared pool’ order by end;
    #shared_pool_summary.sql -get an overview of chunks in the shared pool
    select
    ksmchcom contents,
    count(*) chunks,
    sum(decode(ksmchcls, 'recr', ksmchsiz)) recreatable,
    sum(decode(ksmchcls, 'freeabl', ksmchsiz)) freeable,
    sum(ksmchsiz) total
    from
    sys.x_$ksmsp
    where
    inst_id = userenv('Instance') and
    ksmchcls not like 'R%'
    group by
    ksmchcom
    #reserved_pool_summary.sql - get an overview of chunks in the reserved pool
    select
    ksmchcom contents,
    count(*) chunks,
    sum(decode(ksmchcls, 'R-recr', ksmchsiz)) recreatable,
    sum(decode(ksmchcls, 'R-freea', ksmchsiz)) freeable,
    sum(ksmchsiz) total
    from
    sys.x_$ksmspr
    where
    inst_id = userenv('Instance')
    group by
    ksmchcom
    #save_sqlplus_settings.sql -reset sqlplus settings
    set termout off
    store set sqlplus_settings replace
    clear breaks
    clear columns
    clear computes
    set feedback off
    set verify off
    set termout on
    set define "&"
    #restore_sqlplus_settings.sql -reset sqlplus settings
    set termout off
    @sqlplus_settings
    clear breaks
    clear columns
    clear computes
    set termout on
    i.Check the shared pool reserved size status
    SELECT free_space, avg_free_size, used_space, avg_used_size, REQUEST_MISSES, request_failures, last_miss_size FROM v$shared_pool_reserved;
    An ORA-04031 error referencing large failed requests, indicates the Reserved Area is too fragmented. The reserved pool is small when: REQUEST_FAILURES > 0 (and increasing), The DBA should Increase shared_pool_reserved_size and shared_pool_size together. It is possible that too much memory has been allocated to the reserved list. The DBA should Decrease shared_pool_reserved_size, If: REQUEST_MISS = 0 or not increasing
    FREE_MEMORY = > 50% of shared_pool_reserved_size minimum
    col free_space for 999,999,999,999 head “TOTAL FREE”
    col avg_free_size for 999,999,999,999 head “AVERAGE|CHUNK SIZE
    col free_count for 999,999,999,999 head “COUNT”
    col request_misses for 999,999,999,999 head “REQUEST|MISSES
    col request_failures for 999,999,999,999 head “REQUEST|FAILURES”
    col max_free_size for 999,999,999,999 head “LARGEST CHUNK”
    select free_space, avg_free_size, free_count, max_free_size, request_misses, request_failures from v$shared_pool_reserved;
    TOTAL FREE     AVERAGE
    CHUNK SIZE     COUNT     LARGEST CHUNK     REQUEST
    MISSES     REQUEST
    FAILURES
    7,238,192     212,888     34     212,888     0     0
    You should also use hidden and unsupported parameter “_shared_pool_reserved_pct” to control reserved pool. This parameter controls the allocated percentage of shared pool for reserved pool. By default it is %5 of the shared pool and if you use ASMM for memory management you can set this value higher like 10 to allocate reserved pool dynamically. When you set the parameter you will see the shared_pool_reserved_size parameter will be adjusted to the new setting. The parameter can not be modified when instance is started. You can use the query below to see the current value
    select a.ksppinm “Parameter”, b.ksppstvl “Session Value”, c.ksppstvl “Instance Value” from sys.x$ksppi a, sys.x$ksppcv b, sys.x$ksppsv c where a.indx = b.indx and a.indx = c.indx and a.ksppinm = ‘_shared_pool_reserved_pct’;
    Parameter     Session Value     Instance Value
    sharedpool_reserved_pct     10     10
    j.When having multiple subheaps:
    select KSMCHIDX, ksmchcom ChunkComment,
    decode(round(ksmchsiz/1000),0,'0-1K', 1,'1-2K', 2,'2-3K', 3,'3-4K',4,'4-5K',5,'5-6k',6,'6-7k',7,'7-8k',8,'8-9k', 9,'9-10k', '> 10K'), count(*), ksmchcls Status, sum(ksmchsiz) Bytes
    from x$ksmsp where KSMCHCOM = 'free memory' group by KSMCHIDX,ksmchcom, ksmchcls, decode(round(ksmchsiz/1000),0,'0-1K', 1,'1-2K', 2,'2-3K', 3,'3-4K',4,'4-5K',5,'5-6k',6,'6-7k',7,'7-8k',8,'8-9k', 9,'9-10k','> 10K');
    SubPool     SGA_HEAP     CHUNKCOMMENT     size     COUNT(*)     STATUS     BYTES
    1     sga heap(1,0)     free memory     > 10K     34     R-free     7238192
    1     sga heap(1,0)     free memory     3-4K     2     free     6284
    1     sga heap(1,0)     free memory     > 10K     241     free     35707400
    1     sga heap(1,0)     free memory     8-9k     1     free     7712
    1     sga heap(1,0)     free memory     2-3K     4     free     6752
    1     sga heap(1,0)     free memory     0-1K     2090     free     133288
    1     sga heap(1,0)     free memory     9-10k     21     free     188676
    1     sga heap(1,0)     free memory     1-2K     30     free     25868
    If you see lack of large chunks it is possible that you can face with ORA-04031 in near future.
    k.Check shared pool at first glance quick diagnostics
    select 'You may need to increase the SHARED_POOL_RESERVED_SIZE' Description, 'Request Failures = '||REQUEST_FAILURES Logic
    from      v$shared_pool_reserved where      REQUEST_FAILURES > 0
    and      0 != (select      to_number(VALUE) from      v$parameter
    where      NAME = 'shared_pool_reserved_size')
    union
    select 'You may be able to decrease the SHARED_POOL_RESERVED_SIZE' Description,'Request Failures = '||REQUEST_FAILURES Logic
    from      v$shared_pool_reserved where      REQUEST_FAILURES < 5
    and      0 != (select      to_number(VALUE) from      v$parameter
         where      NAME = 'shared_pool_reserved_size')
    l.Memory Usage - object list level view
    •     Owner - Owner of the object
    •     Object - Name/namespace of the object
    •     Sharable Memory - Amount of sharable memory in the shared pool consumed by the object
    select OWNER, NAME||' - '||TYPE object,SHARABLE_MEM
    from      v$db_object_cache where SHARABLE_MEM > 10000
    and     type in ('PACKAGE','PACKAGE BODY','FUNCTION','PROCEDURE')
    order by owner asc ,SHARABLE_MEM desc
    SELECT * FROM (SELECT ROW_NUMBER () over (PARTITION BY NAMESPACE ORDER BY SHARABLE_MEM DESC) ROW_within , NAMESPACE, SHARABLE_MEM, SUBSTR(NAME,1,40) NAME FROM V$DB_OBJECT_CACHE ORDER BY SHARABLE_MEM DESC) WHERE ROW_WITHIN <= 2 ORDER BY NAMESPACE, ROW_WITHIN;
    ROW_WITHIN NAMESPACE SHARABLE_MEM NAME
    1 CLUSTER 2794 C_OBJ#_INTCOL#
    2 CLUSTER 1684 SMON_SCN_TO_TIME
    1 RSRCPLAN 5117 SYS_GROUP

  • Close all SQL trace

    Hi,how I can close all SQL trace .
    that is I run a SQL with a client application such as SQL developer
    and I want no one can see this SQL script use views such as v$sqltext,v$sql,v$sqlarea etc.

    user11203282 wrote:
    and I want no one can see this SQL script use views such as v$sqltext,v$sql,v$sqlarea etc.Every SQL is going to use these views. Can you elaborate a bit what exactly you are looking for ?
    Amardeep Sidhu

  • SQL History

    Dear friends,
    How can we see the historical sql statement in Oracle 11g. I am looking a way to get some sql statements which ran 2-3 days before.
    I searched into v$session, v$sql, v$sqlarea views but it does not have the statements I am looking for.
    Then I searched into v$sqltext, v$sqltext_with_newlines, v$sql_monitor and dba_hist_sqltext tables but it has only last 24 hours statements.
    Requesting experts to kindly clear my doutbs:
    1. Need solution on the above issue.
    2. what is the time period when oracle flushed out data from v$session, v$sqlarea, v$sql, v$sqltext and v$sql_monitor?
    3. What is the sequence of flushing out the data i.e first from which table it has been flushed out to which table and finally - which is the last table data has been keet out and how long?
    4. Is there any parameter which can be changed and the historical data retain period can be increased/decreased?
    5. Any new views/tables which has been provided specially in Oracle 11g on the above subject.
    Looking forward to get your assistance.
    Regards.

    Maybe grid control and sure archive log (using logminer)

  • How to get SQL text from dbms_sql cursor ID

    Hello,
    I have a progam using dbms_sql. A cursor is built by dbms_sql.parse (cur_id, v_query, dbms_sql.native);From now on I have only the internal ID cur_id of the cursor. Is there a way to get back the original query the cursor is built from when the cursor is passed to another package?
    Regards
    Marcus

    Oracle provides several views that show part or all of the SQL statement. See your Oracle version# Reference manual for v$sql...
    v$sqltext is one view that displays the full text but the text is contained in multiple rows.
    HTH -- Mark D Powell --

  • Where to find the SQL text in v$ views?

    Hi All,
    Oracle 11.2.0.3 on RedHat.
    I am trying to find out SQL activity on my database for a very narrow time window. Please see the SQLs I did
    SQL> select distinct user_id, sql_id
      2  from v$active_session_history
      3  where sample_time between to_date('20120704012000','yyyymmddhh24miss') and
      4            to_date('20120704012200','yyyymmddhh24miss')
      5  and user_id = 111 ;
       USER_ID SQL_ID
           111
           111 gjg25k7stx9ba
           111 a8m049aj31b1y
           111 asjw7b7h99w4m
           111 fvffk1aqrb55n
           111 9gskv9b1u7mau
           111 03tsb9pp3h1uj
           111 dm0jppss5z0ay
           111 44n0svyuc000x
           111 16t1tpr7mdqnf
           111 bzpu510tng689
           111 dsqzhqdvzamys
    12 rows selected.
    SQL> select * from v$sqltext where sql_id='16t1tpr7mdqnf' order by piece ;
    no rows selected
    SQL> select * from table( dbms_xplan.display_awr('16t1tpr7mdqnf') ) ;
    no rows selectedI can see the text for all SQLs in v$sqltext, except 16t1tpr7mdqnf. User id 111 is the user used to run our batch processes.
    Where can I find the text for this SQL id 16t1tpr7mdqnf ?
    This SQL has run about 8 hours ago.
    Thanks in advance

    When you say, ASH captures active sessions, does that mean, it only captures "session" information, which may not include details about SQL ?Exactly, it's a snapshot of session level information for active sessions.
    So, session X can be executing sql statement abc123 and be captured by ASH which takes a snapshot of all active sessions every 1 second in V$ACTIVE_SESSION_HISTORY.
    1 in 10 of these active sessions is stored in the repository - DBA_HIST_ACTIVE_SESS_HISTORY (in practice, this 1 in 10 sample is literally as simple as store the active sessions from every 10th second).
    Independently of this, obviously you have the shared pool and V$SQL. If your statements are in here then great.
    Otherwise you have AWR which captures the top N sql from each interval.
    So, as mentioned, perfectly normal to have references to sql ids and sql plan hash values captured in ASH but not AWR.
    One interesting thing here is, sql_exec_id is blank. What does that say? It depends.
    It's likely to be one of two things:
    1. some sort of bug or limitation - there are certain operations and time limits were some of the ASH values get cleared out or don't get cleared out.
    2. occasionally I've seen the ASH information be misleading when it comes to certain recursive operations - one specific example I can think of related to the recursive merge of sql plan baseline metric tracking operations.

  • Sql queries - slow database

    hi all,
    is there a general but specific way to generate a list of sql queries that are consuming most resources and resulting in slow database performance?
    thanks.

    There are very few ways in this world that are "general but specific".
    You can use "general" tools like StatsPack and AWR.
    You can write "general" queries on V$SQL, V$SQLAREA, V$SQLSTATS.
    You can use "specific" methods like Tracing.
    You can use "specific" methods like Client side (or Application Server side) Logs.

Maybe you are looking for

  • How to input data into a table with columns?

    I am trying to input data into a table.  My table have 5 columns and an unlimited amount of rows.  I created a program in LabView that enters the data into the table but it enters all of the data in one row.  I would like to enter the first set of in

  • Will a Midi to usb work with a korg triton pro x?

    I'm considering buying a korg triton pro x 88 key. but I want to use garageband lessons to learn to get better on the piano, so will a Midi to usb work with it?

  • SQL - Joins

    Hi all. I am learning join- tables in SQL. My question relates to the use of WHERE. It is probably best if I show 2 examples: 1 SELECT ename, dname from emp e join dept d on (e.deptno = d.deptno) WHERE ename = 'Jones'; 2 SELECT ename, dname from emp

  • How to use Create input request Activity

     Hi,  I want to get inputs from the users .  I want to display a form were user can select a input from drop down list.  That selected item i want to store it in a variable and use across the flow.  How to do that using create input request or is the

  • Best way to implement selectOneRadio component with "other" option

    I have a selectOneRadio component that has an other option (see below). If the other option is selected I need to pull the value out of a text field. Any ideas on the best way (or any way) to implement this? This is how it looks on the screen... Plea