How to join v$session to v$sql?
Oracle 9.2.0.8 on Windows 2000 Server
I am using the query below to identify memory intensive sessions coming from a particular machine. I want to find out what queries they are running. What the best way of doing this? Can I join v$session to v$sql?
set feedback off
set verify off
SET LINESIZE 145
SET PAGESIZE 9999
COLUMN sid FORMAT 999 HEADING 'SID'
COLUMN oracle_username FORMAT a12 HEADING 'Oracle User' JUSTIFY right
COLUMN os_username FORMAT a9 HEADING 'O/S User' JUSTIFY right
COLUMN session_program FORMAT a18 HEADING 'Session Program' TRUNC
COLUMN session_machine FORMAT a8 HEADING 'Machine' JUSTIFY right TRUNC
COLUMN session_pga_memory FORMAT 9,999,999,999 HEADING 'PGA Memory'
COLUMN session_pga_memory_max FORMAT 9,999,999,999 HEADING 'PGA Memory Max'
COLUMN session_uga_memory FORMAT 9,999,999,999 HEADING 'UGA Memory'
COLUMN session_uga_memory_max FORMAT 9,999,999,999 HEADING 'UGA Memory MAX'
COLUMN server FORMAT a10
SELECT
s.sid sid
, lpad(s.username,12) oracle_username
, lpad(s.osuser,9) os_username
, s.program session_program
, lpad(s.machine,8) session_machine
, lpad(s.server,8) server
, (select ss.value from v$sesstat ss, v$statname sn
where ss.sid = s.sid and
sn.statistic# = ss.statistic# and
sn.name = 'session pga memory') session_pga_memory
, (select ss.value from v$sesstat ss, v$statname sn
where ss.sid = s.sid and
sn.statistic# = ss.statistic# and
sn.name = 'session pga memory max') session_pga_memory_max
, (select ss.value from v$sesstat ss, v$statname sn
where ss.sid = s.sid and
sn.statistic# = ss.statistic# and
sn.name = 'session uga memory') session_uga_memory
, (select ss.value from v$sesstat ss, v$statname sn
where ss.sid = s.sid and
sn.statistic# = ss.statistic# and
sn.name = 'session uga memory max') session_uga_memory_max
FROM
v$session s
WHERE s.machine LIKE 'land%'
ORDER BY session_pga_memory DESC
/
John,
The hash_value (and in 10g the sql_id) is the better option for this join - it's an "indexed" access path, whereas the sql_address join leaves you thrashing though the library cache hammering the library cache latches as you go.
(See http://www.jlcomp.demon.co.uk/guilty.html and associated notes for various comments on messing with v$ )
Unfortunately, even that doesn't give you an exact answer until 10g, as Oracle does not expose the child number for the specific child cursor that this session is using. It's a piece of information that's hidden underneath v$open_cursor in x$kgllk.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
Similar Messages
-
How to call a session variable into sql?
for example, I have a coldfusion session variable - session.testvar
I am writing a Stored procedure in sql server 2000. The query within my stored procedure needs to insert a value into a table. The value needs to be my CF session variable. I have no idea how this is done, does anyone else have a hunch?
I am using coldfusion 8 and sql server 2000.Pass it to the SP as a variable
- there are examples in the cf docs -
How to join 5 different tables using SQL to make it to a flat file structur
I am trying to load five differnt tables into one flat file structure table without cartesian product.
I have five different tables Jobplan, Jobtask(JT), Joblabor(JL), Jobmaterial(JM) and Jpsequence(JS) and the target table as has all the five tables as one table.
The data i have here is something like this.
jobplan = 1record
jobtask = 5 records
joblabor = 2 records
jobmaterial = 1 record
jpsequence = 3 records
The output has to be like this.
JPNUM DESCRIPTION LOCATION JT_JPNUM JT_TASK JL_JPNUM JL_labor JM_JPNUM JM_MATERIAL JS_JPNUM JS_SEQUENCE
1001 Test Jobplan USA NULL NULL NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 10 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 20 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 30 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 40 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 50 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA NULL NULL 1001 Sam NULL NULL NULL NULL
1001 Test Jobplan USA NULL NULL 1001 Mike NULL NULL NULL NULL
1001 Test Jobplan USA NULL NULL NULL NULL 1001 Hammer NULL NULL
1001 Test Jobplan USA NULL NULL NULL NULL NULL NULL 1001 1
1001 Test Jobplan USA NULL NULL NULL NULL NULL NULL 1001 2
1001 Test Jobplan USA NULL NULL NULL NULL NULL NULL 1001 3
Please help me out with this issue.
Thanks,
Siva
Edited by: 931144 on Apr 30, 2012 11:35 AMHope below helps you
CREATE TABLE JOBPLAN
( JPNUM NUMBER,
DESCRIPTION VARCHAR2(100)
INSERT INTO JOBPLAN VALUES(1001,'Test Jobplan');
CREATE TABLE JOBTASK
( LOCATION VARCHAR2(10),
JT_JPNUM NUMBER,
JT_TASK NUMBER
INSERT INTO JOBTASK VALUES('USA',1001,10);
INSERT INTO JOBTASK VALUES('USA',1001,20);
INSERT INTO JOBTASK VALUES('USA',1001,30);
INSERT INTO JOBTASK VALUES('USA',1001,40);
INSERT INTO JOBTASK VALUES('USA',1001,50);
CREATE TABLE JOBLABOR
( JL_JPNUM NUMBER,
JL_LABOR VARCHAR2(10)
INSERT INTO JOBLABOR VALUES(1001,'Sam');
INSERT INTO JOBLABOR VALUES(1001,'Mike');
CREATE TABLE JOBMATERIAL
( JM_JPNUM NUMBER,
JM_MATERIAL VARCHAR2(10)
INSERT INTO JOBMATERIAL VALUES(1001,'Hammer');
CREATE TABLE JOBSEQUENCE
( JS_JPNUM NUMBER,
JS_SEQUENCE NUMBER
INSERT INTO JOBSEQUENCE VALUES(1001,1);
INSERT INTO JOBSEQUENCE VALUES(1001,2);
INSERT INTO JOBSEQUENCE VALUES(1001,3);
SELECT JP.JPNUM AS JPNUM ,
JP.DESCRIPTION AS DESCRIPTION ,
NULL AS LOCATION ,
NULL AS JT_JPNUM ,
NULL AS JT_TASK ,
NULL AS JL_JPNUM ,
NULL AS JL_labor ,
NULL AS JM_JPNUM ,
NULL AS JM_MATERIAL ,
NULL AS JS_JPNUM ,
NULL AS JS_SEQUENCE
FROM JOBPLAN JP
UNION ALL
SELECT JP.JPNUM AS JPNUM ,
JP.DESCRIPTION AS DESCRIPTION ,
JT.LOCATION AS LOCATION ,
JT.JT_JPNUM AS JT_JPNUM ,
JT.JT_TASK AS JT_TASK ,
NULL AS JL_JPNUM ,
NULL AS JL_labor ,
NULL AS JM_JPNUM ,
NULL AS JM_MATERIAL ,
NULL AS JS_JPNUM ,
NULL AS JS_SEQUENCE
FROM JOBPLAN JP, JOBTASK JT
UNION ALL
SELECT JP.JPNUM AS JPNUM ,
JP.DESCRIPTION AS DESCRIPTION ,
NULL AS LOCATION ,
NULL AS JT_JPNUM ,
NULL AS JT_TASK ,
JL.JL_JPNUM AS JL_JPNUM ,
JL.JL_labor AS JL_labor ,
NULL AS JM_JPNUM ,
NULL AS JM_MATERIAL ,
NULL AS JS_JPNUM ,
NULL AS JS_SEQUENCE
FROM JOBPLAN JP, JOBLABOR JL
UNION ALL
SELECT JP.JPNUM AS JPNUM ,
JP.DESCRIPTION AS DESCRIPTION ,
NULL AS LOCATION ,
NULL AS JT_JPNUM ,
NULL AS JT_TASK ,
NULL AS JL_JPNUM ,
NULL AS JL_labor ,
JM.JM_JPNUM AS JM_JPNUM ,
JM.JM_MATERIAL AS JM_MATERIAL ,
NULL AS JS_JPNUM ,
NULL AS JS_SEQUENCE
FROM JOBPLAN JP, JOBMATERIAL JM
UNION ALL
SELECT JP.JPNUM AS JPNUM ,
JP.DESCRIPTION AS DESCRIPTION ,
NULL AS LOCATION ,
NULL AS JT_JPNUM ,
NULL AS JT_TASK ,
NULL AS JL_JPNUM ,
NULL AS JL_labor ,
NULL AS JM_JPNUM ,
NULL AS JM_MATERIAL ,
JS.JS_JPNUM AS JS_JPNUM ,
JS.JS_SEQUENCE AS JS_SEQUENCE
FROM JOBPLAN JP, JOBSEQUENCE JS;
JPNUM DESCRIPTION LOCATION JT_JPNUM JT_TASK JL_JPNUM JL_LABOR JM_JPNUM JM_MATERIA JS_JPNUM JS_SEQUENCE
1001 Test Jobplan NULL NULL NULL NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 10 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 20 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 30 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 40 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan USA 1001 50 NULL NULL NULL NULL NULL NULL
1001 Test Jobplan NULL NULL NULL 1001 Sam NULL NULL NULL NULL
1001 Test Jobplan NULL NULL NULL 1001 Mike NULL NULL NULL NULL
1001 Test Jobplan NULL NULL NULL NULL NULL 1001 Hammer NULL NULL
1001 Test Jobplan NULL NULL NULL NULL NULL NULL NULL 1001 1
1001 Test Jobplan NULL NULL NULL NULL NULL NULL NULL 1001 2
1001 Test Jobplan NULL NULL NULL NULL NULL NULL NULL 1001 3
{code} -
How to join two pl/sql tables .,.,,Urgent pls help
Hi,
Please tell me how to join to pl/sql tables with example
thanks
aspIf your main intention is to get the common records/or getting whole records from the 2 different pl/sql arrays then , pls check this piece of code & explanation
The SQL language has long offered the ability to apply set operations (UNION, INTERSECT, and MINUS) to the result sets of queries. In Oracle Database 10g, you can now use those same high-level, very powerful operators against nested tables (and only nested tables) in your PL/SQL programs and on nested tables declared as columns inside relational tables.
Let's take a look at some of the syntax needed to do this, starting with UNION.
First, I create a schema-level nested table type:
CREATE OR REPLACE TYPE strings_nt
IS TABLE OF VARCHAR2(100);
Then I define a package and within it create and populate two nested tables of this type, each containing some of my father's and my favorite things:
CREATE OR REPLACE PACKAGE favorites_pkg
IS
my_favorites strings_nt
:= strings_nt ('CHOCOLATE'
, 'BRUSSEL SPROUTS'
, 'SPIDER ROLL'
dad_favorites strings_nt
:= strings_nt ('PICKLED HERRING
, 'POTATOES'
, 'PASTRAMI'
, 'CHOCOLATE'
PROCEDURE show_favorites (
title_in IN VARCHAR2
, favs_in IN strings_nt
END;
In this package, I also include a procedure to show the contents of a strings_nt nested table. This will come in very handy shortly.
By defining these collections in a package, outside any program, they persist (they maintain their state and values) for the duration of my session or until I change or delete them. This means that I can now write programs outside the package to manipulate the contents of those collections.
Note that this package has been simplified for the purposes of presenting collection functionality. In a production application, you should always take care to "hide" your package data, as with these collections, in the package body, and then provide procedures and functions to manage the data.
Suppose, for example, that I would like to combine these two collections into a single collection of our favorites. Prior to Oracle Database 10g, I would have to write a loop that transfers the contents of one collection to another. Now, I can rely on the MULTISET UNION operator, as shown below:
DECLARE
our_favorites
strings_nt := strings_nt ();
BEGIN
our_favorites :=
favorites_pkg.my_favorites
MULTISET UNION ---- Use INTERSECT , if you want to know common records
favorites_pkg.dad_favorites;
favorites_pkg.show_favorites (
'ME then DAD', our_favorites);
END;
The output from this script is:
ME then DAD
1 = CHOCOLATE
2 = BRUSSEL SPROUTS
3 = SPIDER ROLL
4 = PICKLED HERRING
5 = POTATOES
6 = PASTRAMI
7 = CHOCOLATE
------------------------------ -
How to provide joins between oracle tables and sql server tables
Hi,
I have a requirement that i need to generate a report form two different data base. i.e Oracle and Sql Server.
how to provide joins between oracle tables and sql server tables ? Any help on this
Regards,
Malliuser10675696 wrote:
I have a requirement that i need to generate a report form two different data base. i.e Oracle and Sql Server. Bad idea most times. Heterogeneous joins do not exactly scale and performance can be severely degraded by network speed and b/w availability. And there is nothing you can do in the application and database layers to address performance issue at the network level in this case - your code's performance is simply at the mercy of network performance. With a single glaring fact - network performance is continually degrading. All the time. Always. Until it is upgraded. When the performance degradation starts all over again.
If the tables are not small (few 1000 rows each) and row volumes static, I would not consider doing a heterogeneous join. Instead I would rather go for a materialised view on the Oracle side, use a proper table and index structure, and do a local database join. -
How to find session information in sql plus
Can someone please tell me how to find session information in sql plus? I specifically want to know my privileges for the current session. Thanks in advance.
SELECT * FROM session_privs;
SELECT * FROM session_roles; -
How to invoke multiple sessions of sql*plus thru pl/sql program
Hi
How to invoke multiple sessions of sql*plus thru pl/sql program.
ThanksHow to invoke sql*plus in a procedure?????
I have to invoke more pl/sql sessions?????No you don't "have to".
Look at what you are trying to do.
You have a program running inside the PL/SQL engine. This is running nicely inside the Oracle database and is perfectly capable of issuing other SQL statements, PL/SQL programs etc. inside it's nice cosy Oracle environment.
You are asking for this PL/SQL to shell out to the operating system, run an external application, for which it will have to supply a username and password (are you planning on hard coding those into your PL/SQL?), and then that external application is supposed to run more SQL or PL/SQL against the database.
a) Why hold all this code external to the database when it can quite happily reside on the database itself and be executed through jobs or whatever.
b) Consider what would happen if someone were to replace the external application with their own program of the same file name... they'd be able to capture the username and password for connecting to the database, therefore a major security flaw.
The whole idea of doing what you want through external calls to SQL*Plus is ridiculous. -
How to raise an exeption in PL/SQL when the client session has terminated?
Due to metalink Note:310924.1, I tried a similar demo script in my 10gR2 database;
session 1)
CREATE TABLE tbl_test(col1 NUMBER,
col2 VARCHAR2(256));
DECLARE
v_client_ip_addr VARCHAR2(15) := '';
v_sqlcode NUMBER;
v_sqlerrm VARCHAR2(256) := '';
BEGIN
FOR i IN 1 .. 10 LOOP
v_client_ip_addr := sys_context('USERENV',
'IP_ADDRESS');
INSERT INTO tbl_test VALUES (i, v_client_ip_addr);
dbms_lock.sleep(5); -- 5 saniye uyu
END LOOP;
ROLLBACK;
EXCEPTION
WHEN OTHERS THEN
v_sqlcode := SQLCODE;
v_sqlerrm := SQLERRM;
INSERT INTO tbl_test VALUES (v_sqlcode, v_sqlerrm);
COMMIT;
END;
session 2)
kill the process
but result is not similar with the metalink note, no rows returned;
SQL>
Table created
DECLARE
v_client_ip_addr VARCHAR2(15) := '';
v_sqlcode NUMBER;
v_sqlerrm VARCHAR2(256) := '';
BEGIN
FOR i IN 1 .. 10 LOOP
v_client_ip_addr := sys_context('USERENV',
'IP_ADDRESS');
INSERT INTO tbl_test VALUES (i, v_client_ip_addr);
dbms_lock.sleep(5); -- 5 saniye uyu
END LOOP;
ROLLBACK;
EXCEPTION
WHEN OTHERS THEN
v_sqlcode := SQLCODE;
v_sqlerrm := SQLERRM;
INSERT INTO tbl_test VALUES (v_sqlcode, v_sqlerrm);
COMMIT;
END;
ORA-00028: your session has been killed
SQL> select * from tbl_test;
COL1 COL2
Any comments will be welcomed,
Thank you :)
Kind regards.
H.Tonguc YILMAZ
Turkcell Ar-Ge, Yazılım Geliştirme
[email protected]
"Learning is expensive, not more than unawareness."Confirm. That Metalink Note is incorrect.
I've tested against Oracle 10G (1.2.0.1) using both dedicated and shared server connections. In both cases the exception handler did not catch the exception raised for a killed session.
Interestingly the exception stack is slightly different between dedicated and shared server.
Shared server:
ERROR at line 1:
ORA-00028: your session has been killed
ORA-06512: at "SYS.DBMS_LOCK", line 201
ORA-06512: at "BILLY.KILLTEST", line 9
ORA-06512: at line 1
Dedicated server:
ERROR at line 1:
ORA-00028: your session has been killed
I did a minor modification to the code:
connect scott/tiger
drop table tbl_test;
create table tbl_test (col1 number, col2 varchar2(15));
create or replace procedure KillTest is
v_client_ip_addr VARCHAR2(15) := '';
begin
for i in 1..10
loop
v_client_ip_addr := SYS_CONTEXT('USERENV','IP_ADDRESS');
insert into tbl_test values (i, v_client_ip_addr);
commit;
dbms_lock.sleep(5);
end loop;
exception
when OTHERS then
insert into tbl_test values (0, 'exception');
commit;
end;
exec killtest
-- kill this session from another SQL*Plus session
connect scott/tiger
select * from tbl_test;
It is not unusual that an application exception handler does not catch all exceptions - also not in PL/SQL. I recall other instances where I also had system related exceptions that could not be caught via an application exception handler in PL/SQL.
This makes sense as a system related error could "damage" the PL/SQL engine's heap and stack to such an extent that it is unsafe to proceed with the execution of the engine. Thus any application handlers that the engine would have executed under non-system error conditions, are not executed at all.
Whether a kill of a session translates into a such a serious system error to cause this, is of course debatable. -
How to use the session id provided by fuego.papi.ProcessServiceSession
Hi, I'm wondering how to reuse the session id provided by the ProcessServiceSession in the Oracle BPM 10g Process API (PAPI)...
After the processService.createSession(passport, "localhost") call, I get an ProcessServiceSession instance, wich has an getId() method, so... the question is:
Is there a way to reuse this sessionId in another call to the processServiceSession's methods?, something like: I have this sessionId "userName321321321321321", so I want to reuse it to avoid passing the username and password in another moment of the application...
Moment 1: The user does the log in step and obtains a sessionId, then, the user exits the application... (I'm not going to execute the close() of the ProcessServiceSession, so, I keep the session alive)
Moment 2: The user goes back to the application and does some other things, so, with the generated session id in moment 1, I'd like to retrieve that session (by the session id) and accept him as valid user, without ask him the password again and allow him to do PAPI stuff.
Is this doable?
Edited by: user11204803 on 09/11/2010 11:41hi
yes , you can get SQL_ID from v$session and also you can join it for v$SQL also it get another details ......
CHeers -
How to join GRPO with AP invoice thru query ?
hi all,
How to join GRPO with AP invoice in sql query ?
JeyakanthanHi Jeyakanthan
Are you using query in SAP Business One or outside the system? If you select the tables in SAP Business One as OPCH and OPDN then no inner join will appear, as the links sit on the line level. You will need PCH1 and PDN1. The link can be found in both directions, but bear in mind that 1 AP Invoice could be based on more than 1 Goods Receipt PO. For this reason the best approach is to start at the AP Invoice line level and use the BaseType and BaseRef fields to view which lines were pulled from which Goods Receipt PO's.
Kind regards
Peter Juby -
How to use Temporary Table in PL-SQL
In MySQL there is no Temporary table concept.
So for intermediate calculation I have created a table as below
create table SequenceTempTable
SessionId VARCHAR(50),
Sequence VARCHAR(500),
CreatedDate DATE
) ENGINE=MEMORY;
Whenever I invoke a SP, I load the data into SequenceTempTable using Session Id as below
CREATE PROCEDURE `GetSequence`(
IN Start_Date VARCHAR(25),
IN End_Date VARCHAR(25)
BEGIN
SELECT UUID() INTO v_SessionId;
INSERT INTO SequenceTempTable values (v_SessionId,'1,2,5,3',now());
required code
DELETE FROM SequenceTempTable WHERE SessionId = v_SessionId;
COMMIT;
END;
i.e. I have created a table as temporary table (created once),
and load the data using Session Id and once session specific intermediate computation done,
I deleted the session specific data.
Could you give me examples of How to use Temporary table in PL-SQL code with respect to my above example.
Because I have gone through creating Temporary table but I stuck with use in PL-SQL. I mean to say Is there any need of creating table in advance before invoking SP.
And one more thing as in MySQL temp table I created which is using MEMORY engine i.e. this table will always be in MEMORY so there is no need of writing data on disk.
Regards
SanjeevHi Sanjeev
Read about GTT here
http://www.oracle-base.com/articles/8i/TemporaryTables.php
GTT always contains just session specific data. \
In case you want to use the GTT in the same session again you can use option
ON COMMIT PRESERVE ROWS;
Or if it is used just once in the session use can use
ON COMMIT DELETE ROWS;
Do remember that for GTT the data of one session can not be accessed in other session.
Also you can go away with Delete from GTT if not used again in same session.
Regards
Arun -
How to reduce execution time of this SQL?
This SQL will output only 2 rows. I tried using hints (an index) but to no avail.
http://www.freeimagehosting.net/uploads/cf214afcf1.jpg
Or, is it NOT possible, limit of query optimization has reached?Rakesh jayappa wrote:
Hi,
Run the sql tuning advisory.
Let me know recommendation.
Kind Regards,
Rakesh************************** Here is my tuning request **************************
1.) The following SQL statement has been identified to perform poorly. It currently takes up to 12 seconds to execute, but it's supposed to take a second at most.
This is the statement:
select DISTINCT trunc(c.sst_post_date) as post_date
from ac_t_sessn b , ac_t_ssntr c
where
b.ses_status = 0
and b.ses_profit_center = c.sst_profit_center
and b.ses_acct_year = c.sst_acct_year
and b.ses_acct_period = c.sst_acct_period
and b.ses_sessn_no = c.sst_sessn_no
AND
C.sst_post_mtd||C.sst_post_TYPE IN
(SELECT Y.pst_post_mtd||Y.pst_post_type
FROM ac_r_post_functions Y
WHERE Y.pst_post_status IN (0,'2'))
order by trunc(c.sst_post_date);It should return data from a table in a specific order.
2.) The version of the database is Oracle9i Enterprise Edition Release *9.2.0.6.0*
3.) These are the parameters relevant to the optimizer:
UAT_UML@umltest>show parameter optimizer
NAME TYPE VALUE
optimizer_dynamic_sampling integer 1
optimizer_features_enable string 9.2.0
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_max_permutations integer 2000
optimizer_mode string CHOOSE
UAT_UML@umltest>show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 16
UAT_UML@umltest>show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
UAT_UML@umltest>show parameter cursor_sharing
NAME TYPE VALUE
cursor_sharing string EXACT
UAT_UML@umltest>column sname format a20
UAT_UML@umltest>column pname format a20
UAT_UML@umltest>column pval2 format a20
UAT_UML@umltest>select
2 sname
3 , pname
4 , pval1
5 , pval2
6 from
7 sys.aux_stats$;
no rows selected4.) Here is the output of EXPLAIN PLAN:
UAT_UML@umltest>select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost |
| 0 | SELECT STATEMENT | | 454 | 22700 | | 5391 |
| 1 | SORT UNIQUE | | 454 | 22700 | | 5072 |
| 2 | HASH JOIN | | 69384 | 3387K| 2592K| 4478 |
| 3 | INDEX FAST FULL SCAN| INDX_AC_T_SESSN | 110K| 1294K| | 244 |
| 4 | HASH JOIN | | 416K| 15M| | 3877 |
| 5 | TABLE ACCESS FULL | AC_R_POST_FUNCTIONS | 23 | 253 | | 2 |
| 6 | TABLE ACCESS FULL | AC_T_SSNTR | 1790K| 46M| | 3866 |
Note: cpu costing is off, PLAN_TABLE' is old version5.) Here is the output of SQL*Plus AUTOTRACE including the TIMING information:
UAT_UML@umltest>set autotrace traceonly arraysize 100
UAT_UML@umltest>
UAT_UML@umltest>select DISTINCT trunc(c.sst_post_date) as post_date
2 from ac_t_sessn b , ac_t_ssntr c
3 where
4 b.ses_status = 0
5 and b.ses_profit_center = c.sst_profit_center
6 and b.ses_acct_year = c.sst_acct_year
7 and b.ses_acct_period = c.sst_acct_period
8 and b.ses_sessn_no = c.sst_sessn_no
9 AND
10 C.sst_post_mtd||C.sst_post_TYPE IN (SELECT Y.pst_post_mtd||Y.pst_post_type FROM ac_r_po
st_functions Y
11 WHERE Y.pst_post_status IN (0,'2'))
12 order by trunc(c.sst_post_date);
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=5391 Card=454 Bytes=
22700)
1 0 SORT (UNIQUE) (Cost=5072 Card=454 Bytes=22700)
2 1 HASH JOIN (Cost=4478 Card=69384 Bytes=3469200)
3 2 INDEX (FAST FULL SCAN) OF 'INDX_AC_T_SESSN' (NON-UNIQU
E) (Cost=244 Card=110433 Bytes=1325196)
4 2 HASH JOIN (Cost=3877 Card=416304 Bytes=15819552)
5 4 TABLE ACCESS (FULL) OF 'AC_R_POST_FUNCTIONS' (Cost=2
Card=23 Bytes=253)
6 4 TABLE ACCESS (FULL) OF 'AC_T_SSNTR' (Cost=3866 Card=
1790555 Bytes=48344985)
Statistics
0 recursive calls
0 db block gets
42741 consistent gets
171 physical reads
0 redo size
425 bytes sent via SQL*Net to client
507 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
2 rows processed
UAT_UML@umltest>DISCONNECT
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production6.) The TKPROF output snippet
TKPROF: Release 11.2.0.1.0 - Development on Wed Oct 27 12:47:35 2010
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Trace file: umltest_ora_1604.trc
Sort options: prsela exeela fchela
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
select DISTINCT trunc(c.sst_post_date) as post_date
from ac_t_sessn b , ac_t_ssntr c
where
b.ses_status = 0
and b.ses_profit_center = c.sst_profit_center
and b.ses_acct_year = c.sst_acct_year
and b.ses_acct_period = c.sst_acct_period
and b.ses_sessn_no = c.sst_sessn_no
AND
C.sst_post_mtd||C.sst_post_TYPE IN (SELECT Y.pst_post_mtd||Y.pst_post_type FROM ac_r_post_functions Y
WHERE Y.pst_post_status IN (0,'2'))
order by trunc(c.sst_post_date)
call count cpu elapsed disk query current rows
Parse 1 0.01 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 3.20 4.38 171 42741 0 2
total 4 3.21 4.39 171 42741 0 2
Misses in library cache during parse: 1
Optimizer mode: CHOOSE
Parsing user id: 445
Rows Row Source Operation
2 SORT UNIQUE
24 HASH JOIN
11 INDEX FAST FULL SCAN OBJ#(62817) (object id 62817)
2293715 HASH JOIN
31 TABLE ACCESS FULL OBJ#(67305)
1790555 TABLE ACCESS FULL OBJ#(62828)
alter session set sql_trace true
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 1 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Misses in library cache during execute: 1
Optimizer mode: CHOOSE
Parsing user id: 445
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 1 0.01 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 3.20 4.38 171 42741 0 2
total 5 3.21 4.39 171 42741 0 2
Misses in library cache during parse: 1
Misses in library cache during execute: 1
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
2 user SQL statements in session.
0 internal SQL statements in session.
2 SQL statements in session.
Trace file: umltest_ora_1604.trc
Trace file compatibility: 9.02.00
Sort options: prsela exeela fchela
1 session in tracefile.
2 user SQL statements in trace file.
0 internal SQL statements in trace file.
2 SQL statements in trace file.
2 unique SQL statements in trace file.
51 lines in trace file.
10 elapsed seconds in trace file. Any help would be greatly appreciated? -
Kill the session Using Pl/sql Script
Hi,
I wrote a PL/SQL Script which kills the Specified Schema name..... the Script Run Successfully i got this output message "PL/SQL procedure successfully completed." But the Problem is in session status the status is in KILLED" state for more than 30 minutes.
Please Advice Why the Session in Killed State for more than 30 minutes and please tell me how to kill the session immediate;
I am Using Oracle DB 11g R1 and OS is Windows 2003 Server R2
My Pl/sql Script
SET SERVEROUTPUT ON;
DECLARE
KILLER1 V$SESSION.SID%TYPE;
KILLER2 V$SESSION.SERIAL#%TYPE;
CURSOR KILL_SESSION IS SELECT SID,SERIAL# FROM V$SESSION WHERE SCHEMANAME='NAME';
BEGIN
OPEN KILL_SESSION;
LOOP
FETCH KILL_SESSION INTO KILLER1,KILLER2;
EXIT WHEN KILL_SESSION%NOTFOUND;
DBMS_OUTPUT.put_line ('ALTER SYSTEM KILL SESSION '''||KILLER1||','||KILLER2||''' IMMEDAITE');
EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION'||chr(39)||KILLER1||','||KILLER2||chr(39);
END LOOP;
IF (KILLER1 > 0)
THEN
EXECUTE IMMEDIATE 'ALTER SYSTEM KILL SESSION'||chr(39)||KILLER1||','||KILLER2||chr(39);
END IF;
CLOSE KILL_SESSION;
END;
Thank You
ShanHello,
In fact you may use orakill it's an Oracle utility for Windows so as to Kill the thread corresponding
to the session.
It's equivalent to a kill -9 on Unix.
Please find here a link about the use of orakill:
http://articles.techrepublic.com.com/5100-10878_11-5224960.html
Hope this help.
Best regards,
Jean-Valentin
Edited by: Lubiez Jean-Valentin on Mar 27, 2010 5:17 PM -
How to kill oracle session?
hi there,
Aside from using tool like TOAD is there a syntax on how to kill oracle session?
pls help.
tnx...First findout the SID, Serial No for the Particular Session ( syntax is as follows )
SELECT sid, serial#,osuser, program FROM v$session;
(Killing the session on SQL Prompt)
ALTER SYSTEM KILL SESSION 'sid,serial#';
force to kill the session by adding IMMEDIATE
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
OS Oracle Kill Session
First findout the SID, SPID for the Particular Session ( SQL syntax is as follows )
SELECT s.sid,p.spid, s.osuser ,s.program
FROM v$process p, v$session s
WHERE p.addr = s.paddr;
Windows OS Command for kill Session
orakill SID SPID
Regs,
Naresh -
How to make the session to wait until other session get closed successfully
Hi ,
In my program , I am calling sql loader and after that I am opening a session and inside that I am calling stored procedure which validates the data.
above calling of sql loader and stored procedure is done inside the shell script i.e .prog file which is registerd as host concurrent program.
Here i am facing the problem like when two files are processed with same content then second file content's are not erroring out as duplicate though there is a duplicate validation exist inside the procedure. IF I call dbms_lock.sleep(60) then it is working and sencond file are records are error out with duplicate error message. but this is working only for small data files.
Please suggest me how to make the session to come out successfully then only i can open other sesssion .
Thanks
Raghavuser5853450 wrote:
Hi ,
In my program , I am calling sql loader and after that I am opening a session and inside that I am calling stored procedure which validates the data.
above calling of sql loader and stored procedure is done inside the shell script i.e .prog file which is registerd as host concurrent program.
Here i am facing the problem like when two files are processed with same content then second file content's are not erroring out as duplicate though there is a duplicate validation exist inside the procedure. IF I call dbms_lock.sleep(60) then it is working and sencond file are records are error out with duplicate error message. but this is working only for small data files.
Please suggest me how to make the session to come out successfully then only i can open other sesssion .
Thanks
RaghavFor starters you could use external tables rather than SQL*Loader and then you could keep all the control on the database side of things rather than relying on an external utility. The external tables will give you all the functionality of SQL*Loader but all you to just read the data using SQL select statements instead and cut out all the shell script dependency.
Alternatively you could also look at Job Chaining...
http://download.oracle.com/docs/cd/B19306_01/server.102/b14214/chapter1.htm#FEATURENO05574
Maybe you are looking for
-
Can't print to PDF with Acrobat XI Pro
Since I upgraded from X PRO to XI PRO I have not been able to print to PDF. All my different printer settings to Adobe PDF's are not working.
-
Hi Currently our application is running in JDK 1.4.2.11 and because of the SSL vulnerability issues we are planning to upgrade the JDK to 1.4.2.15 version. Just wanted to know do we need to complie the code for this change.
-
HELP!! MY Zen Micros broken AG
ok I got impatient waiting for replies on the other post... My zen micro screen has gone blank, but the music still plays, this is the second time it has broken in the 2 weeks i've had it!! please can some one tell me how to fix this as i dont want t
-
Hi all, Please let me know the details of the following. 1.What is Multi-Threading? 2. How it is useful to increase the Performance of a SQL query.( How it is useful in Optimizing the query. 3. How we'll use MultiThread concept in Partitions and Usin
-
What are the benefits to using the OCI JDBC driver?
I understand that the Thin JDBC driver is geared toward Applets since it is all Java and relatively small for download. If I am running servlets is there any compelling reason for me to use the OCI driver? I would think my application would be more p