Script to find the list of Queries currently running in database with User Login Name and Host Name.

Hai,
How to find the list of queries currently running in the Database with User Login Information.
Since my database application is running slow, to find the slow queries.

Try the below query
SELECT r.start_time [Start Time],r.session_id [SPID],
DB_NAME(database_id) [Database],
s.host_name,
s.program_name,
s.login_name,
SUBSTRING(t.text,(r.statement_start_offset/2)+1,
CASE WHEN statement_end_offset=-1 OR statement_end_offset=0
THEN (DATALENGTH(t.Text)-r.statement_start_offset/2)+1
ELSE (r.statement_end_offset-r.statement_start_offset)/2+1
END) [Executing SQL],
r.status,command,wait_type,wait_time,wait_resource,
last_wait_type
FROM sys.dm_exec_requests r
OUTER APPLY sys.dm_exec_sql_text(sql_handle) t
inner join sys.dm_exec_sessions s
on s.session_id = r.session_id
WHERE r.session_id !=@@SPID -- don't show this query
AND r.session_id > 50 -- don't show system queries
ORDER BY r.start_time
Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

Similar Messages

  • How to find the list of Queries/Reports which are using Exceptional Aggregation in SAP BI?

    Hi All,
    We are interested to know how to find the list of Queries/ Reports which are using Exceptional aggregation in SAP BI.
    Please let us know is there any table's to check the list of reports using Exceptional Aggregation in SAP BI.

    Hi,
    Here you go..
    1) Go to table RSZCALC and get list of ELTUID where AGGREXC is not INITIAL and AGGRCHA is not initial; now you get only exception aggregation set based on some chars. Also you can further add STEPNR = 1 since your intention is just to get query name , not the calculation details; this will reduce number of entries to lookup and save DB time for next steps.
    Here you will get list of exception aggregation UUID numbers from which you can get properties from RSZELTDIR.
    2) Pass list of RSZCALC-ELTUID to table RSZELTXREF - TELTUID and get list of RSZELTXREF -SELTUID - this table stores query to it's elements maping kind.
    3) Now again pass RSZELTXREF - SELTUID into same table but into different field RSZELTZREF - TELTUID and get RSZELTXREF - SELTUID
    This step you get query reference sheet or column or query general UUID for next step.
    4) Pass list of RSZELTXREF - SELTUID into RSZELTDIR - ELTUID with DEFTP as 'REP'. Now you get list of query names in RSZELTDIR - MAPNAME and description in TXTLG.
    Note: you can also get the reference chars used for exception aggregation from RSZCALC - AGGRCHA field.
    Hope this helps.
    Please keep in mind, it might take more time depends on how many query elements you have in the system...
    Comments added for better DB performance by: Arun Thangaraj

  • How to find the list of Queries for that have statistics enabled in the sys

    Hi ,
    How to find the list of Queries  that have statistics enabled on them in the system.
    Please help me in this regard
    Thanks
    Maruthi

    hi ,
    I found three options there like
    X - on
    D - Default
    off
    can you please expalin the difference between on and Default
    Thanks in Advance
    Maruthi

  • How to find the list of queries containing a Particular Infoobject

    Hi all,
    I have requirement to find the list of queries and workbooks which contains a Particular Infoobject. Please advice is there any Database table or Programs exists to find..
    Thanks in advance
    GAMY..

    Hi,
    Thanks for your replies.
    I have tried the oprion already..(RSD1 > Type in the name of the InfoObject and from the menu Edit > choose Where Used list.) but no use. It doesn't show the list of queires..It shows only the data targets.
    I would like to know is there any table to achieve the requirement.
    Thanks in advance
    Ganesh(GAMY)

  • PS Script to find the list of users and the groups in a Workgroup server

    Hi There, could you please explain on how to get a complete list of local users and local groups in a "Workgroup" server to which they belong to using Powershell. I'm able to get the users list but couldn't find any help in finding
    the script to find to which localgroup the user belong to. Anticipating your response. Also let me know the cmdlet for Win2k3 servers to find the same.

    Here's some code from David Pham (don't remember wher I fund this code):
    Trap {"Error: $_"; Break;}
    Function EnumLocalGroup($LocalGroup)
    $Group = [ADSI]"WinNT://$strComputer/$LocalGroup,group"
    "Group: $LocalGroup"
    # Invoke the Members method and convert to an array of member objects.
    $Members= @($Group.psbase.Invoke("Members"))
    ForEach ($Member In $Members)
    $Name = $Member.GetType().InvokeMember("Name", 'GetProperty', $Null, $Member, $Null)
    $Name
    # Specify the computer.
    $strComputer = gc env:computername
    "Computer: $strComputer"
    $computer = [adsi]"WinNT://$strComputer"
    $objCount = ($computer.psbase.children | measure-object).count
    $i=0
    foreach($adsiObj in $computer.psbase.children)
    switch -regex($adsiObj.psbase.SchemaClassName)
    "group"
    { $group = $adsiObj.name
    EnumLocalGroup $group }
    } #end switch
    $i++
    } #end foreach

  • Script to find the " List of objects to be pinned in the shared pool"

    hi all,
    please suggest me any script is there to find the recommended objects to be pinned in to shared pool.
    Regards,
    Vamsi.

    I think the important question here is – do you really need to PIN objects? Are you facing any ORA-4031 errors?
    Oracle would tell you to PIN packages such as STANDARD, DBMS_STANDARD, DBMS_UTILITY, DBMS_OUTPUT. It really depends on your application. So I am afraid there is no exact answer for that, but you can work with your application team to learn if there is some large object that is very frequently used that you might want to PIN.
    I suggest that you check the larger objects from your SGA using the view v$db_object_cache that folks already pointed out checking the column SHARABLE_MEM.
    You can refer to v$sql or v$sqlarea (which is a grouping of v$sql) to find the most executed stored procedures and packages and so on.
    However, most of the problems shared pool problems I have faced were related to bad application coding - such as lack of bind variables - or shared pool undersized. Once those problems were fixed, I hardly had to PIN anything into the SGA.
    Regards

  • Script to find the currently active sql

    hey,
    Can somebody post me a script to find the currently active sql in the database ???

    Hi,
    You can try these below:
    select s.username
           c1,t.sql_text
    from v$session s, v$sqltext t
    where
    s.sql_address = t.address and
    s.sql_hash_value = t.hash_value and
    s.username is not null
    order by s.username,s.prev_sql_addr,s.prev_hash_value,t.piece;
    or
    select sesion.sid,
           sesion.serial#,
           sesion.username,
           sesion.sql_id,
           sesion.sql_child_number,
           optimizer_mode,
           hash_value,
           address,
           sql_text
      from v$sqlarea sqlarea, v$session sesion
    where sesion.sql_hash_value = sqlarea.hash_value
       and sesion.sql_address    = sqlarea.address
       and sesion.username is not nullCheers

  • How to find the list of existing tables in a schema using DB link?

    Hi
    I know how to find the list of existing tables in a schema using the following query
    SQL> select * from tab;
    but, how to list the tables using a DB link?
    For Example
    SQL> select * from tab@dblink_name;
    why this doesn't work?
    Pl advice me
    Thanks
    Reddy.

    ORA-02019: connection description for remote database not foundHave you used this database link successfully for some other queries?
    The error posted seems to indicate that the DB Link is not functional at all. Has it worked for any other type of DML operation or is this the first time you ever tried to use the link?

  • Script to find if list of Apps patches exists in DB 'A' but not in DB 'B'

    Hi All,
    DB:11.1.0.7
    Oracle Apps:12.1.1
    OS:Linux 86x64 bits Red Hat
    Could anyone please share the script to find if list of patches exists in DB 'A' but not in DB 'B'
    Thanks for your time
    Regards,

    We have already answered you, not sure why you keep asking the same question!
    SELECT bug_number,creation_date from ad_bugs where bug_number in
    ('1234','5678','56783','4321','765432');
    I get the list of patches out of the above say - '1234','5678'
    Now how to get the list of patches out of the above list of 5 patches which are not in the DB 'A' .I know this could be done manually but this is just an example as there may be hundreds of patches like this in ad_bugs to extract and we cannot manually do it in excel or any other way bit through a queryRun the same query in Database B and compare it with the output of Database A. Or, simply create a database link for Database B from Database A and run this query from DB A:
    SQL> SELECT bug_number, creation_date
    from ad_bugs
    where bug_number in ('1234','5678','56783','4321','765432')
    minus
    SELECT bug_number, creation_date
    from ad_bugs@<DBlink to DB B>
    where bug_number in ('1234','5678','56783','4321','765432');Thanks,
    Hussein

  • Script to find the Concurrent Request ID from its associated SID

    Hi,
    In one of my production system, my server load is going very high. From the top used process ID of server, I found the SID and found out that the program running is "ora_rw20_run@acgerp (which is a concurrent program)
    How do I find out the Request ID using the SID/PID? Can someone please provide me the script to find the Concurrent Request ID from its associated SID?
    Thanks!

    There has been no new changes in the report server or in the database. Suddenly of late, we have been observing this program running and it never ends, consuming major part of the cpu load. Not sure what this program is -> ora_rw20_run. There is no mention about it in metalink or in google.
    I followed MOS Doc 1058210.6 and tried to debug more. But the formatted output doesnt give any info either.
    TKPROF: Release 10.2.0.2.0 - Production on Tue Oct 20 09:44:21 2009
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Trace file: prod_ora_15721.trc
    Sort options: default
    count = number of times OCI procedure was executed
    cpu = cpu time in seconds executing
    elapsed = elapsed time in seconds executing
    disk = number of physical reads of buffers from disk
    query = number of buffers gotten for consistent read
    current = number of buffers gotten in current mode (usually for update)
    rows = number of rows processed by the fetch or execute call
    0 statements EXPLAINed in this session.
    Trace file: prod_ora_15721.trc
    Trace file compatibility: 10.01.00
    Sort options: default
    1 session in tracefile.
    0 user SQL statements in trace file.
    0 internal SQL statements in trace file.
    0 SQL statements in trace file.
    0 unique SQL statements in trace file.
    96507 lines in trace file.
    0 elapsed seconds in trace file.
    When I use the below query, I can find that the session is running a module named "PAXMGSLS" and the action is Concurrent Request.
    But I am not sure how to find out the Concurrent Request ID using this info to dig more (look into the concurrent request log files etc)
    select s.sid,s.serial#,p.spid os_pid,s.status,
    s.osuser,s.username,s.COMMAND,s.MACHINE,s.MODULE, s.SCHEMANAME,
    s.LOCKWAIT,s.action
    from v$session s, v$process p
    WHERE s.paddr = p.addr
    and s.sid = 823
    SID     SERIAL#     OS_PID     STATUS     OSUSER     USERNAME     COMMAND     MACHINE     MODULE     SCHEMANAME     LOCKWAIT     ACTION
    823     47     4559     ACTIVE     applprod     APPS     3     acgerp     PAXMGSLS     APPS          Concurrent Request

  • Is there a way to find the list of PCs and iDevices connected to my Itunes Match?

    Is there a way to find the list of PCs and iDevices connected to my Itunes Match?

    Is there a way to find the list of PCs and iDevices connected to my Itunes Match?

  • HT4199 I just got a new iPod touch 4th generation and I'm trying to connect to my router and my iPod says, 'Cannont find network.' I don't know what to do! No other networks come up on the list so I can't 'tag' along with thier wifi. Please help. I need a

    I just got a new iPod touch 4th generation and I'm trying to connect to my router and my iPod says, 'Cannont find network.' I don't know what to do! No other networks come up on the list so I can't 'tag' along with thier wifi. Please help. I need advice.

    What type network is yu router set up for? The 4G iPod can only connect and see 2.4 GHZ networl like B, G and the 2,4 GHz N. There is also a 5 GHz N but the iPod will not even seethat network.
    See:
    iOS: Troubleshooting Wi-Fi networks and connections
    iOS: Recommended settings for Wi-Fi routers and access points

  • How to find the list of users loggin through HTTP session

    Hi All,
    we are using SRM 5.5 system with ITS. I am able to find the list of concurrent users from ABAP level using report "CCUEVAL" but how do I know the list of concurrent users logged in from HTTP session?.
    could you please let us know the SAP note number or any report?
    Thanks in advance,
    Mohan Karri

    Hi Uday,
    thank you very much for your prompt response.
    I need a report because by end of every month I would need the average peak http users list for the reporting month.
    or tell me how to find " how many users logged in through HTTP session in a day?"
    Thanks
    Mohan

  • Query to find the list of users having access to a particular scenario

    Hi,
    I am learning Hyperion Planning 9.2 x version. I wanted to know the query to find the list of users having access to Plan Iteration - 1 scenarion.
    As I am new to Hyperion Essbase and Hyperion Planning, I am assuming these ideas work out to get the desired result.
    1) As Hyperion Planning uses Relational DB to store the User Security information, we can query the list of users who is having access to Plan Iteration - 1 Scenario.
    I am not sure if this solution works. Please correct me If I am wrong.
    2) We can also query from the essbase editor to find out who all having access to this scenario.
    If the above is correct, can you please provide me the query.
    I am really need of this and I will be happy if any one provide the solution.
    Thanks & Regards,
    Upendra. Bestha

    Hi,
    If you are looking for some SQL to retrieve the access rights by member then you can use something like (SQL Server code though can easily be modified for Oracle)
    SELECT usr.object_name as Username,mem.object_name as Member,
    'Access Rights' = CASE acc.access_mode
    WHEN -1 THEN 'None'
    WHEN 1 THEN 'Read'
    WHEN 2 THEN 'Write'
    WHEN 3 THEN 'Write'
    ELSE 'Unknown' END,
    'Relation' = CASE acc.flags
    WHEN 0 THEN 'Member'
    WHEN 5 THEN 'Children'
    WHEN 6 THEN 'Children (inclusive)'
    WHEN 8 THEN 'Descendants'
    WHEN 9 THEN 'Descendants (inclusive)'
    ELSE 'Unknown' END
    FROM
    hsp_access_control acc, hsp_object mem, hsp_object usr
    WHERE acc.object_id = mem.object_id
    AND acc.user_id = usr.object_id
    AND mem.object_name = 'Plan Iteration - 1'
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • How to find the list of  transaction code based on a  field ?

    Hi  Gurus
    I have a unique requirement.We are adding a  new field into our system and want to know which all t-code  contains that field ?  So that we can update the  user training manual. Can some one tell me the ways and means of  finding the list of all the t-code ( or where used e.g functional area ) based on  " a field" ?
    Thanks in advance
    SN

    Hi,
    1. Tcode KS02.
    2. click on the text "Cost Center"
    3. hit F1
    4. Click on the technical information
    5. in the next screen double click on Field name :KOSTL
    6. Select the row for the component KOSTL
    7. Click on the display list
    8. In the next screen, in the object name:KBAS
    Drilldown to transactions.
    Here you get a complete list of the transactions.
    Hope its useful.
    thanks.

Maybe you are looking for