Top sessions query
Hello does anyone have a query that I can use to show sid, serial# and current SQL for a specified user. I know there are tools out there but there is no budget for anything now and OEM is acting very unstable in my environment. I keep having to shut it down and restart it. My Oracle version is 9.2.0.8 on Sun Solaris 9. Thank you for your input.
-- David
Justin, I do not have a sql_id in my v$session or v$sql. This is for 10g and above. I am running 9.2.0.8.
SQL> desc v$session
Name Null? Type
SADDR RAW(8)
SID NUMBER
SERIAL# NUMBER
AUDSID NUMBER
PADDR RAW(8)
USER# NUMBER
USERNAME VARCHAR2(30)
COMMAND NUMBER
OWNERID NUMBER
TADDR VARCHAR2(16)
LOCKWAIT VARCHAR2(16)
STATUS VARCHAR2(8)
SERVER VARCHAR2(9)
SCHEMA# NUMBER
SCHEMANAME VARCHAR2(30)
OSUSER VARCHAR2(30)
PROCESS VARCHAR2(12)
MACHINE VARCHAR2(64)
TERMINAL VARCHAR2(30)
PROGRAM VARCHAR2(48)
TYPE VARCHAR2(10)
SQL_ADDRESS RAW(8)
SQL_HASH_VALUE NUMBER
PREV_SQL_ADDR RAW(8)
PREV_HASH_VALUE NUMBER
MODULE VARCHAR2(48)
MODULE_HASH NUMBER
ACTION VARCHAR2(32)
ACTION_HASH NUMBER
CLIENT_INFO VARCHAR2(64)
FIXED_TABLE_SEQUENCE NUMBER
ROW_WAIT_OBJ# NUMBER
ROW_WAIT_FILE# NUMBER
ROW_WAIT_BLOCK# NUMBER
ROW_WAIT_ROW# NUMBER
LOGON_TIME DATE
LAST_CALL_ET NUMBER
PDML_ENABLED VARCHAR2(3)
FAILOVER_TYPE VARCHAR2(13)
FAILOVER_METHOD VARCHAR2(10)
FAILED_OVER VARCHAR2(3)
RESOURCE_CONSUMER_GROUP VARCHAR2(32)
PDML_STATUS VARCHAR2(8)
PDDL_STATUS VARCHAR2(8)
PQ_STATUS VARCHAR2(8)
CURRENT_QUEUE_DURATION NUMBER
CLIENT_IDENTIFIER VARCHAR2(64)
SQL> desc v$sql
Name Null? Type
SQL_TEXT VARCHAR2(1000)
SHARABLE_MEM NUMBER
PERSISTENT_MEM NUMBER
RUNTIME_MEM NUMBER
SORTS NUMBER
LOADED_VERSIONS NUMBER
OPEN_VERSIONS NUMBER
USERS_OPENING NUMBER
FETCHES NUMBER
EXECUTIONS NUMBER
USERS_EXECUTING NUMBER
LOADS NUMBER
FIRST_LOAD_TIME VARCHAR2(19)
INVALIDATIONS NUMBER
PARSE_CALLS NUMBER
DISK_READS NUMBER
BUFFER_GETS NUMBER
ROWS_PROCESSED NUMBER
COMMAND_TYPE NUMBER
OPTIMIZER_MODE VARCHAR2(10)
OPTIMIZER_COST NUMBER
PARSING_USER_ID NUMBER
PARSING_SCHEMA_ID NUMBER
KEPT_VERSIONS NUMBER
ADDRESS RAW(8)
TYPE_CHK_HEAP RAW(8)
HASH_VALUE NUMBER
PLAN_HASH_VALUE NUMBER
CHILD_NUMBER NUMBER
MODULE VARCHAR2(64)
MODULE_HASH NUMBER
ACTION VARCHAR2(64)
ACTION_HASH NUMBER
SERIALIZABLE_ABORTS NUMBER
OUTLINE_CATEGORY VARCHAR2(64)
CPU_TIME NUMBER
ELAPSED_TIME NUMBER
OUTLINE_SID NUMBER
CHILD_ADDRESS RAW(8)
SQLTYPE NUMBER
REMOTE VARCHAR2(1)
OBJECT_STATUS VARCHAR2(19)
LITERAL_HASH_VALUE NUMBER
LAST_LOAD_TIME VARCHAR2(19)
IS_OBSOLETE VARCHAR2(1)
CHILD_LATCH NUMBEREdited by: JesusLuvR on Jan 30, 2009 1:49 PM
Similar Messages
-
Top N query giving error for oracle 8.0.6
Dear All,
We are executing this query SELECT XBLNR, WERKS, MATNR, MDV01, BACKFLQUANT, STATUS, SAPTIMESTAMP, PITSTIMESTAMP, PMTIMESTAMP, BATCH FROM (SELECT XBLNR, WERKS, MATNR, MDV01, BACKFLQUANT, STATUS, SAPTIMESTAMP, PITSTIMESTAMP, PMTIMESTAMP, BATCH FROM PMBPITS.PITS_UNITY WHERE STATUS = '01' ORDER BY PMTIMESTAMP) WHERE ROWNUM < 20
on oracle 8.0.6 but this is giving the following error
ora - 00907 missing right parenthesis error
1. Is it that in the inner select we cannot use order by and where clause together.
2. We also found that if we remove order by from inner select then the query is not giving error
pls help . points will be awardedHi,
what ever the Aman said is correct. You check this is supported in 8.1.5, SQL allows you to embed the ORDER BY clause in a subquery and place the ROWNUM condition in the top-level query;
'Top-N query' is a ORACLE 8i feature which is supported in SQL. However,
Bug:855720 states the following:
"PL/SQL does not support top-N queries (ORDER BY in SUBSELECT/SUBQUERY
or VIEW. Since this feature is available in SQL, but not in PL/SQL,
it has been logged as a Bug that will be fixed in 8.1.6."
- Pavan Kumar N -
Top N query with INLIST Iterator performance problem
I have a top N query that is giving me problems on Oracle 11.2.0.3.
First of all, I have a query like the following (simplified from the real query, but produces the same problem):
select /*+ gather_plan_statistics */ * from
select rowid
from payer_subscription ps
where ps.subscription_status = :i_subscription_status
and ps.merchant_id = :merchant_id2
order by transaction_date desc
) where rownum <= :i_rowcount; This query works well. It can very efficiently find me the top 10 rows for a massive data set, using an index on merchant_id, subscription_status, transaction_date.
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
| 0 | SELECT STATEMENT | | 1 | | 10 |00:00:00.01 | 4 |
|* 1 | COUNT STOPKEY | | 1 | | 10 |00:00:00.01 | 4 |
| 2 | VIEW | | 1 | 11 | 10 |00:00:00.01 | 4 |
|* 3 | INDEX RANGE SCAN DESCENDING| SODTEST2_IX | 1 | 100 | 10 |00:00:00.01 | 4 |
-------------------------------------------------------------------------------------------------------As you can see the estimated actual rows at each stage are 10, which is correct.
Now, I have a requirement to get the top N records for a set of merchant_Ids, so if I change the query to include two merchant_ids, the performance tanks:
select /*+ gather_plan_statistics */ * from
select rowid
from payer_subscription ps
where ps.subscription_status = :i_subscription_status
and (ps.merchant_id = :merchant_id or
ps.merchant_id = :merchant_id2 )
order by transaction_date desc
) where rownum <= :i_rowcount;
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
| 0 | SELECT STATEMENT | | 1 | | 10 |00:00:00.17 | 178 | | | |
|* 1 | COUNT STOPKEY | | 1 | | 10 |00:00:00.17 | 178 | | | |
| 2 | VIEW | | 1 | 200 | 10 |00:00:00.17 | 178 | | | |
|* 3 | SORT ORDER BY STOPKEY| | 1 | 200 | 10 |00:00:00.17 | 178 | 2048 | 2048 | 2048 (0)|
| 4 | INLIST ITERATOR | | 1 | | 42385 |00:00:00.10 | 178 | | | |
|* 5 | INDEX RANGE SCAN | SODTEST2_IX | 2 | 200 | 42385 |00:00:00.06 | 178 | | | |Notice now that there are 42K rows coming out of the two index range scans - Oracle is no longer aborting the index range scan when it reaches 10 rows. What I thought would happen, is that Oracle would get at most 10 rows for each merchant_id, knowing that at most 10 rows are to be returned by the query. Then it would sort that 10 + 10 rows and output the top 10 based on the transaction date, but it refuses to do that.
Does anyone know how I can get the performance of the first query, when I need to pass a list of merchants into the query? I could probably get the performance using a union all, but the list of merchants is variable, and could be anywhere between 1 or 2 to several 100, so that makes that a bit unworkable.Across the two merchants_id's there are about 42K rows (this is in test, on Prod there could be several million). In the first query example, Oracle can answer the query in about 4 logical IOs and without even doing a sort as it uses the index to scan and get the relevant rows in Oracle.
In the second case, I hoped it would pull 10 rows for each merchant_id and then sort the resulting 20 rows to find the top 10 ordered by transaction_date, but instead it is scanning far more rows than it needs to.
In my example, it takes 4 logical IOs to answer the first query, but ~ 170 to answer the second, while I think it is achievable in 8 or so. For example, this query does what I want, but it is not a feasible option due to how many merchant_id's I may have to deal with:
select /*+ gather_plan_statistics */ *
from
select *
from
select * from
select merchant_id, transaction_date
from payer_subscription ps
where ps.subscription_status = :i_subscription_status
and ps.merchant_id = :merchant_id
order by transaction_date desc
) where rownum <= :i_rowcount
union all
select * from
select merchant_id, transaction_date
from payer_subscription ps
where ps.subscription_status = :i_subscription_status
and ps.merchant_id = :merchant_id2
order by transaction_date desc
) where rownum <= :i_rowcount
) order by transaction_date desc
) where rownum <= :i_rowcount;
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
| 0 | SELECT STATEMENT | | 1 | | 10 |00:00:00.01 | 6 | | | |
|* 1 | COUNT STOPKEY | | 1 | | 10 |00:00:00.01 | 6 | | | |
| 2 | VIEW | | 1 | 20 | 10 |00:00:00.01 | 6 | | | |
|* 3 | SORT ORDER BY STOPKEY | | 1 | 20 | 10 |00:00:00.01 | 6 | 2048 | 2048 | 2048 (0)|
| 4 | VIEW | | 1 | 20 | 20 |00:00:00.01 | 6 | | | |
| 5 | UNION-ALL | | 1 | | 20 |00:00:00.01 | 6 | | | |
|* 6 | COUNT STOPKEY | | 1 | | 10 |00:00:00.01 | 3 | | | |
| 7 | VIEW | | 1 | 100 | 10 |00:00:00.01 | 3 | | | |
|* 8 | INDEX RANGE SCAN DESCENDING| SODTEST2_IX | 1 | 100 | 10 |00:00:00.01 | 3 | | | |
|* 9 | COUNT STOPKEY | | 1 | | 10 |00:00:00.01 | 3 | | | |
| 10 | VIEW | | 1 | 11 | 10 |00:00:00.01 | 3 | | | |
|* 11 | INDEX RANGE SCAN DESCENDING| SODTEST2_IX | 1 | 100 | 10 |00:00:00.01 | 3 | | | |
---------------------------------------------------------------------------------------------------------------------------------------This UNION ALL query completes in 6 logical IOs - the original query I posted with 2 IDs takes 178 to return the same results. -
Can we hide filter in Search Master agreements standard top level query?
Hi Experts,
I have a requirement to hide flter in standard Search Master Agreements top level query. See below screen shot
I have an idea how to delete filter in query but when i have added that query to top level navigation i don't have any idea.
So i want to hide Business Unit & Region filter in Search Master Agreement query when it is in top level navigation.
If anyone have idea please share with me how to hide.
Thanks,
LavaHi Lava,
It is not a filter but this a Standard field which is coming from the Master Agreement.
So, you cannot hide or even delete any field.
But if it is a custom field you can hide it by inactivating the respective field in Extension Defination.
Please let me know if you need any assistance.
Thanks,
Raj. -
Top utilising Query in SQL server
Hi,
Is there any query to get the top utilization query of the day?Hi,
Top CPU utilizing query
--This might take some time to give result on busy systemselect top 10
sum(qs.total_worker_time) as total_cpu_time,
sum(qs.execution_count) as total_execution_count,
count(*) as number_of_statements,
t.text
from
sys.dm_exec_query_stats qs
cross apply sys.dm_exec_sql_text(qs.sql_handle) as t
group by t.text
order by sum(qs.total_worker_time) desc
For memory utilization there is no perfect way to find out if query has completed. but
sys.dm_exec_query_memory_grants would help you
SELECT mg.granted_memory_kb, mg.session_id, t.text, qp.query_plan
FROM sys.dm_exec_query_memory_grants AS mg
CROSS APPLY sys.dm_exec_sql_text(mg.sql_handle) AS t
CROSS APPLY sys.dm_exec_query_plan(mg.plan_handle) AS qp
ORDER BY 1 DESC OPTION (MAXDOP 1)
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
My TechNet Wiki Articles -
hi
How can i get the top 5 or 2 users who consuming large physical and logical i/o s,like we getting the top sessions in OEM.I dont want to use OEM.Is it v$filestat and v$session?
with regards
ramyaYou can use v$sesstat and v$session. Something like :
select * from (select
b.username,
b.terminal,
to_char(b.logon_time,'dd/mm/yyyy hh24:mi:ss'),
b.program,
a.value
from v$sesstat a, v$session b
where a.statistic# in (40, 41, 42) and
b.sid = a.siD and
b.username is not null and
b.username not like 'SYS%'
order by a.value desc)
where rownum < 6;In v$statname you can see all statistics, and eventually change statistic#. -
Building a session query from multiple queries of same name
I have a SQL query that runs with the name="getcamp" multiple times within a page, then uses a template to display results.
The criteria is different on each run, but the data retrieved is exactly the same.
On another page I need all of the data, so I can loop over it as if it was one query. The idea is to pass the query to the other page in a name="session.getcamp" , so that the data from the query is stored in a session.
The issue I have is that there are the 5 queries with the same name in the first page. Could anybody tell me how I would merge each one into a session query that would have the one name session.getcamp but contain the results of all 5 queries
Thanks
MarkACS LLC wrote:
I have a SQL query that runs with the name="getcamp" multiple times within a page, then uses a template to display results.
The criteria is different on each run, but the data retrieved is exactly the same.
On another page I need all of the data, so I can loop over it as if it was one query. The idea is to pass the query to the other page in a name="session.getcamp" , so that the data from the query is stored in a session.
The issue I have is that there are the 5 queries with the same name in the first page. Could anybody tell me how I would merge each one into a session query that would have the one name session.getcamp but contain the results of all 5 queries
I would suggest the following design:
1) Indeed use the session scope to store the part-queries. However, I would store each of them in the session scope, and union them only where a union is required. You thereby achieve more power and flexibility, as each of the queries will continue to be available to requests throughout the session.
2) I would use the duplicate function to avoid any further reference to the original query. Something like:
First query, name= "getCamp"
<cfset session.getCamp1 = duplicate(getCamp)>
Second query, name= "getCamp"
<cfset session.getCamp2 = duplicate(getCamp)>
etc., etc.
3) On the page where you need to merge the 5 queries:
<cfquery name="getCamp_merged" dbtype="query">
select * from session.getCamp1
union
select * from session.getCamp2
union
select * from session.getCamp3
union
select * from session.getCamp4
union
select * from session.getCamp5
</cfquery>
It's Sunday today, at least where I am. As far as CPU consumption is concerned, whether or not what I've suggested turns out to be the devil's work is up to you to find out. -
Is there a way to permanently keep my customized settings for Top Session?
I always want to see All Active Sessions, why is it that i must always click on the customize button first?
Thanks
RandyI'm not aware of any way to save the customizations set in Top Consumers/Top Sessions. I've never seen that done before.
Possibly an enhancement request?
If anyone else, has done this let me know, but I've not seen it. -
Missing dll in top sessions monitor..
I installed OEM V9.0.1 on Win2K workstation. I am able to launch Enterprise manager console, access schema, etc,
but when I click on TOP SESSIONS MONITOR (after entering the user id & password), i get the following error
"the dynamic link library oravppdc.dll could not be found in the specified path"
I have searched all the directories for this dll, but I am not able to find it. where can I find it ?
thanks & regardsHello,
Check SAP note 1145609 and see if it helps.
Regards,
David -
Hi,
I want to show top 3 salary records from emp table and I am using below query in oracle * plus. However I am getting an error saying, "FROM keyword not found where expected". I am not getting what mistake I am doing while writing this query. Can someone plz advice?
Query:
Select top 3 sal from emp;
Thanks in advance.Hi,
In Oracle, there is no TOP keyword. The usual way to do a top-N query in Oracle is to use an analytic function, such as RANK:
WITH got_r_num AS
SELECT sal
, ename, empno, ... -- whatever columns you want
, RANK () OVER (ORDER BY sal DESC) AS r_num
FROM scott.emp
SELECT sal
, ename, empno, ... -- if wanted
, r_num -- if wanted
FROM got_r_num
WHERE r_num <= 3
ORDER BY sal
;Depending on how you want to handle ties, ypu may want to add tie-breaking columns to the end of the analytic ORDER BY clause, and/or use ROW_NUMBER instead of RANK. -
How to find top utilized query for last two months in oem
how to find top utilized query for last two months in oracle enterprise manager?
Can you mark the thread as Helpful and once marked the information can be reviewed by other customer for similar queries
Regards
Krishnan -
Invalid values in 'Top Sessions'
I have a newly install OEM grid control and on the "Top Sessions" page for multiple databases, I am seeing 'bad' values for every session on numerous columns, i.e.
CPU (1/100 sec) 1127219200
Logical Reads 1106247680
Hard Parses 1127219200
Disk Sorts 5658315534953873408
I am getting these result against both 10.2.0.1 and 9.2.0.6 version databases. I have used 'Monitoring Configuration' to setup the dbsnmp user and install statspack. It seems to me as though I must have a bad version of the statspack tables or something.
Thanks for your help!I am also facing same issue.. in fact, in our case, all the values in the columns like Disk sorts, total parses, hard parses are all same for all the sessions.
And our target OS is
SunOS 5.9 Generic_118558-22 (64-bit) .
Would you please pos the bug number, so I can gather some more info. -
Hi,all,
I need to decide what is top session in a DB, to see how much it would consume resource in that server. When I use TOAD to do it, I find these are so many factors when I make dicision. such as "CPU used by","Physical write" ...
That means "It is top session sort by CPU used by". So I want to know those essential factors, by which certain session would consume much resource.
Do you have any advice? Are there any scripts on hand to do this job,except third-part tool like TOAD?
RobinHowever when I want to work with the top sessions I use the Performance Manager ( This is part of OEM ). These are its advices and descriptions.
Top SessionsSessions are displayed in descending order based upon the delta value of the statistic chosen as the sort statistic. This is a customizable chart that allows sorting and filtering of sessions based upon a number of user settable criterion.Typically the session that is performing the most I/O is the session that should be targetted for tuning. To identify the SQL statement the session is currently executing you can drill down to the Current SQL Chart. From this drilldown you can choose to tune the SQL statement directly.Complete detailed information about any session can be found by selecting the session and drilling down to the Session Details Chart. This chart allows you to view the current SQL statement as well as resource consumption and performance metrics at the same time.The list of all cursors the session has currently open is available through the Open Cursors For This Session Chart. This helps identify all the SQL statements the session is using. From this chart SQL statements can be selected for tuning further drilldown and analysis.This chart can be used to create a customized Top Sessions view. All of the available statistics and identifiers for sessions are shown in a large table by default. By using the Set Options button in the toolbar the chart can be customized to show only the items of interest and the sort criteria can be changed. Customized charts can then be saved, named and accessed directly by name. Specific advice for each of the data items shown on this chart is available below.This chart includes the following data items:
Session NameDescription This data item represents either the Oracle username of the current session or, if the session is owned by an Oracle background process, the name of the background process. Data Source select NVL(s.username, b.name) from v$session s, v$bgprocess b User Action The session name is useful in determining which database users are consuming the most resources. If there is a need to prevent a particular session from consuming too much, one way to control resource usage is to create a resource profile. This profile can then be applied to the Oracle user specified in the session name. The profile provides hard limits on any resource that is explicitly added to it. Some of the resources that can be controlled with profiles are cpu usage, idle time, connect time, etc.
OS UsernameDescription This data item represents the name of the operating system client user. That is the username reported at the time of the database connection time from the operating system. Data Source select osuser from v$session User Action The operating system username can be useful if more than one OS user shares a particular Oracle account (such as SYSTEM). If the session name is not unique, the OS username may provide the identity of the user for the session.
and so on...
Do you have OEM ?
Joel Pérez -
Creating a TOP N Query with a time reference
Hello,
how can i create a TOP 5 Query which is giving me the highest sales order changes in the sales amount during the last day.
Following structure:
Sales Order
Extraction point
Sales(Amount)
I have already created a Top 5 Query which is giving me the 5 highest Sales order with the highest sales. But now i need a query which is giving me the 5 highest sales order during the last extraction point.
Thanks for any advice
Best regardsHi please try the below steps:
1. create a formula variable on the extract point.
2. Create a query only on Extract point as Char in row & formula keyfigure (FKF1) on the extract point formula variable.
3. Create a condition of Top 5 on the FKF1 on the above query.
4.Now come to your original query create a variable on the extract point char use the replacement path & select the query which you just created as the background query for this variable.
So the background query will provide only the TOP 5 extract point values to your original query.
Regards
Mahendra -
CoA Session Query and invalid signature (err=2)!
When the portal/radius client sends a CoA-Req (session query); the ISG responds with a CoA-ACK however the portal receives an error message stating “rad_verify: Received CoA-ACK packet from client 172.X.X.X port 3799 with invalid signature (err=2)! (Shared secret is incorrect.)
The same happens when the a CoA-Re (session query) is sent from the Radius Client with an invalid/non-existing portbundle number.
We were expecting an ACK in the first and a NAK in the second case!
Did any one see this before? Please provide inputs if any?
Thanks!Thank You Admani, I have already done that but just wanted to know if anyone else noticed the same and have a solution if any?
Maybe you are looking for
-
Looking for 'music player' widget to play songs dragged onto iWeb page
Has anyone found a 'music player' widget that can be embedded into an iWeb page, and that can then load and play the songs that have been dragged onto that page? I have found several such widgets that can scan a URL for mp3 files, and I have successf
-
IMac keeps shutting down during startup loading bar under apple sign
My electricity went out and came back on a minute later. When my computer started up again the font was back to original factory setting. I then restarted my computer and every time it would load up it would shutdown. The computer chimes and then rea
-
Airport conflict with television setup?
so i just set up my airport right next to my television setup (direct TV tivo), and now the tivo will not respond to the remote control... is there some kind of conflict going on there? well, obviously, duh... anyone else ever have this problem? any
-
Hi there, Just wondering if anyone can tell me what dimensions i should make my flash movie? It is going to be for a cd-rom and be executed at full screen......just wondering if anyone has some guidelines for this. Thanks, Nathan
-
Detecting character encoding?
I'm running into a problem with Safari (I've got Safari 4 beta installed, but I think this was a problem with 3 as well) where it won't automatically detect character encodings. These are sites in Japanese which load and display correctly in Firefox