Killing long running SQl automatically
I want to put a restriction on my database, if a sql query is running for more then 15 min, then killing this automatically. If this is possible kindly let me know.
Hi,
yes you can do that, use Resource Manager for that like described below:
http://www.pythian.com/blog/oracle-limiting-query-runtime-without-killing-the-session/
Best regards,
Nikolay
Similar Messages
-
does win8/8.1/10 kill/end-task long-running programs automatically as stated in specs? how specifically does it detect a locked-up process?
has this been put into windows 7 at any time to make it similar to windows 8?
Please supply accurate answers. thank you.
My understanding the reason for this change was to handle locked-up programs.
I do have a number of long-running processes. some examples of mine and scenarios for other users:
simulations on a Workstation or HPC Server
doing a directory tree walk on a hard disk with >=1TB of data
reference articles I have found on the subject:
windows 7
http://windows.microsoft.com/en-us/windows/exit-program-not-responding#1TC=windows-7
windows 8
From some of what I understand, you can also get the "Program Not Responding" or similarly titled dialog box when:
bug in the source code of the program in question. for instance, while(1){} such as forever loops (win7)
similar program bug when declaring a function one way but defining it a different way and then calling it (mismatch in function signature) (win7)
similar to above with DLLs in using MSVCRT*.DLL or other
(?) can't remember for sure on this, but I think some badly formed calls or it was invalid values or data type mismatch to Win32 API can do this from buggy code. (win7)
for (x=0; x < 16777216; x++) {your code here...} in other words, large values for loop termination (win7)
this is a repost of http://answers.microsoft.com/en-us/windows/forum/windows_8-performance/does-win88110-kill-long-running-programs/d35c3c9e-c6f4-4bbf-846a-2041bf2167a0?tm=1427518759476
here due to a request to do so.does win8/8.1/10 kill/end-task long-running programs automatically as stated in specs? how specifically does it detect a locked-up process?
has this been put into windows 7 at any time to make it similar to windows 8?
Please supply accurate answers. thank you.
My understanding the reason for this change was to handle locked-up programs.
Hi Jim,
First, I have to admit that I'm not fully understanding the question, If a program is not responding, it means the program is interacting more slowly than usual with Windows, typically could be a confliction of software or hardware resources between
two programs, lack of system resources, or a bug in the software or drivers. In that case, we can choose to wait or end the program. This design is similiar in Windows 7, Windows 8 and other OS.
For deeper analysis, system determines whether the system considers that a specified application is not responding using a "IsHungAppWindow function",
https://msdn.microsoft.com/en-us/library/ms633526.aspx
And this link also give some explanation: Preventing Hangs in Windows Applicationshttps://msdn.microsoft.com/en-us/library/windows/desktop/dd744765%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
While I'm not a developer, to better understand this, I recommend you contact members in the MSDN Forum:
https://social.msdn.microsoft.com/Forums/en-US/home
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
Script to kill long running reports in OBIEE
Hi
I have requirement to kill long running reports . I am using OBIEE version 10.1.3.4.0 which has a bug where it is not taking query limits governor and the reports are not getting killed if i am setting that parameter in RPD.
Oracle support has advised me to upgrade to next version, but for now, i cannot upgrade.
Can anyone suggest me script to run on obiee app server that can kill long running reports on obiee and database server.
I have AIX server and all reports run on database with same functional ID that is being used for ETL as well to Analytics database.Shikhs17 wrote:
Hi
I have requirement to kill long running reports . I am using OBIEE version 10.1.3.4.0 which has a bug where it is not taking query limits governor and the reports are not getting killed if i am setting that parameter in RPD.
Oracle support has advised me to upgrade to next version, but for now, i cannot upgrade.
Can anyone suggest me script to run on obiee app server that can kill long running reports on obiee and database server.
I have AIX server and all reports run on database with same functional ID that is being used for ETL as well to Analytics database.Do you want to enforce the limitation on the database to automatically kill running sessions that run over specific period of time? -
Is there a way to get long running SQL Agent jobs information using powershell?
Hi All,
Is there a way to get long running SQL Agent jobs information using powershell for multiple SQL servers in the environment?
Thanks in Advance.
--HuntI'm running SQL's to fetch the required details and store it in centralized table.
foreach ($svr in get-content "f:\PowerSQL\Input\LongRunningJobsPowerSQLServers.txt"){
$dt = new-object "System.Data.DataTable"
$cn = new-object System.Data.SqlClient.SqlConnection "server=$svr;database=master;Integrated Security=sspi"
$cn.Open()
$sql = $cn.CreateCommand()
$sql.CommandText = "SELECT
@@SERVERNAME servername,
j.job_id AS 'JobId',
name AS 'JobName',
max(start_execution_date) AS 'StartTime',
max(stop_execution_date)AS 'StopTime',
max(avgruntimeonsucceed),
max(DATEDIFF(s,start_execution_date,GETDATE())) AS 'CurrentRunTime',
max(CASE WHEN stop_execution_date IS NULL THEN
DATEDIFF(ss,start_execution_date,stop_execution_date) ELSE 0 END) 'ActualRunTime',
max(CASE
WHEN stop_execution_date IS NULL THEN 'JobRunning'
WHEN DATEDIFF(ss,start_execution_date,stop_execution_date)
> (AvgRunTimeOnSucceed + AvgRunTimeOnSucceed * .05) THEN 'LongRunning-History'
ELSE 'NormalRunning-History'
END) 'JobRun',
max(CASE
WHEN stop_execution_date IS NULL THEN
CASE WHEN DATEDIFF(ss,start_execution_date,GETDATE())
> (AvgRunTimeOnSucceed + AvgRunTimeOnSucceed * .05) THEN 'LongRunning-NOW'
ELSE 'NormalRunning-NOW'
END
ELSE 'JobAlreadyDone'
END)AS 'JobRunning'
FROM msdb.dbo.sysjobactivity ja
INNER JOIN msdb.dbo.sysjobs j ON ja.job_id = j.job_id
INNER JOIN (
SELECT job_id,
AVG
((run_duration/10000 * 3600) + ((run_duration%10000)/100*60) + (run_duration%10000)%100)
+
STDEV
((run_duration/10000 * 3600) + ((run_duration%10000)/100*60) + (run_duration%10000)%100) AS 'AvgRuntimeOnSucceed'
FROM msdb.dbo.sysjobhistory
WHERE step_id = 0 AND run_status = 1
GROUP BY job_id) art
ON j.job_id = art.job_id
WHERE
(stop_execution_date IS NULL and start_execution_date is NOT NULL) OR
(DATEDIFF(ss,start_execution_date,stop_execution_date) > 60 and DATEDIFF(MINUTE,start_execution_date,GETDATE())>60
AND
CAST(LEFT(start_execution_date,11) AS DATETIME) = CAST(LEFT(GETDATE(),11) AS DATETIME) )
--ORDER BY start_execution_date DESC
group by j.job_id,name
$rdr = $sql.ExecuteReader()
$dt.Load($rdr)
$cn.Close()
$dt|out-Datatable
Write-DataTable -ServerInstance 'test124' -Database "PowerSQL" -TableName "TLOG_JobLongRunning" -Data $dt}
You can refer the below link to refer out-datatable and write-dataTable function.
http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/01/use-powershell-to-collect-server-data-and-write-to-sql.aspx
Once we've the table details, I'm sending one consolidated email to automatically.
--Prashanth -
We have a customer that runs our Crystal Reports and they have complained that some of the reports cause long running sql queries and they have to kill these queries manually from SQL Management tools. We have changed the code so that we now dispose the report source and viewer objects as we call .dispose() function on them;
reportSource.dispose();
viewer.dispose();
At first this seemed work but customer later complained that the issue still occurs. Can anyone help with why some of these CR queries are still running way after report is generated (with correct set of data), and based on the customer some of them running for more than 2 hours? What else can we do to make sure that all CR related queries cease to exist once report is generated? Appreciate all the help.1. Run the report from with Crystal designer. You should see the query being sent to DB server. After the report is viewed and you close it in designer, do you see the DB connection being dropped? If not, this may not be a SDK\ API related issue.
2. Try using latest set of CRJ Jars [here|http://downloads.businessobjects.com/akdlm/crystalreportsforeclipse/2_0/crjava-runtime_12.2.213.zip] in your application. Also update the crystalreportviewers folder with the new viewer found at this link.
3. Make sure that you are calling reportClientDocument.close() at the end when user is done viewing the report.
4. When you say logn running queries are seen in DB, are you referring to a DB connection left open? or is it actually running any query and returning results? -
Hi All,
I have a long running sql which I am tuning for oltp environment.
Here is the sql
explain plan for
SELECT a.* ,rownum as rnm
FROM ( SELECT /*+ FIRST_ROWS(100) STAR_TRANSFORMATION PARALLEL(PLS,2) */
/* End of Hint in Query Builder */
PLD.PRVDR_LCTN_IID AS "ProviderLocationIid", PLD.PRVDR_LCTN_DTL_SID AS "ProviderLocationDetailSid",
PLD.ENRLMNT_TYPE_CID AS "EnrollMentTypeCid", PLD.PRVDR_TYPE_CODE AS "ProviderTypeCode",
PLD.MAINECARE_ID AS "Provider Id", PLD.PRVDR_NAME AS "Provider Name",
PLD.PRVDR_TYPE_CODE || '-' || PLD.PRVDR_TYPE_NAME AS "Provider Type",
TO_CHAR(PLS.FROM_DATE,'MM/dd/yyyy') AS "Start Date",
TO_CHAR(PLS.TO_DATE,'MM/dd/yyyy') AS "End Date", PLD.COUNTY_NAME AS "County",
PLD.CITY_TOWN_NAME AS "Town", PLD.ENRLMNT_TYPE_NAME AS "Enrollment Type",
PLS.STATUS_CID AS "StatusCid", STSBS.STATUS_NAME AS "Business Status",
PLD.LCTN_PHONE_NMBR AS "Phone Number", PLD.PRVDR_TYPE_NAME AS "PrvdrTypeName",
SP.SPCLTY_CODE||'-'||SP.SPCLTY_NAME ||'/'|| SP1.SPCLTY_CODE||'-'||
SP1.SPCLTY_NAME AS "Specialty/Subspecialty",
UPPER(SP1.SPCLTY_CODE) AS "SubSpclty", UPPER(SP.SPCLTY_CODE) AS "Spclty"
FROM /*Query Builder Clause*/
STATUS STS,
STATUS STSBS,
SPECIALTY_SUBSPECIALTY SSP,
(SELECT PRVDR_LCTN_STATUS_SID, PRVDR_LCTN_IID, PRVDR_LCTN_DTL_SID, FROM_DATE, TO_DATE,
STATUS_TYPE_CID, STATUS_CID, OPRTNL_FLAG,
FN_GETANCHORDT(FROM_DATE,TO_DATE) AS ANCHOR_DATE
FROM PRVDR_LCTN_STATUS
WHERE STATUS_TYPE_CID = 1
AND OPRTNL_FLAG = 'A'
) PLS,
PRVDR_LCTN_X_SPCLTY_SUBSPCLTY PXSP,
PRVDR_LCTN_STATUS PLSBS,
PROVIDER_LOCATION_DETAIL PLD,
SPECIALTY SP1,
SPECIALTY SP
WHERE
STS.STATUS_TYPE_CID = 1
AND STS.STATUS_CID = 2
AND STSBS.STATUS_TYPE_CID = 15
AND PLSBS.OPRTNL_FLAG = 'A'
-- UPPER(UPPER(SP1.SPCLTY_CODE)) LIKE UPPER('1%')
AND SP1.SPCLTY_CODE LIKE '1%'
-- AND UPPER(UPPER(SP.SPCLTY_CODE)) LIKE UPPER('1%')
AND SP.SPCLTY_CODE LIKE '1%'
AND PLS.OPRTNL_FLAG = 'A'
AND SP1.OPRTNL_FLAG = 'A'
AND PXSP.OPRTNL_FLAG = 'A'
AND PXSP.STATUS_CID = 2
AND SSP.OPRTNL_FLAG = 'A'
AND SP.OPRTNL_FLAG = 'A'
AND PLS.ANCHOR_DATE >= PLSBS.FROM_DATE
AND PLS.ANCHOR_DATE <= PLSBS.TO_DATE
AND PLS.STATUS_TYPE_CID = STS.STATUS_TYPE_CID
AND PLS.STATUS_CID = STS.STATUS_CID
AND PLD.PRVDR_LCTN_DTL_SID = PLS.PRVDR_LCTN_DTL_SID
AND PLSBS.PRVDR_LCTN_IID = PLS.PRVDR_LCTN_IID
AND PLSBS.STATUS_TYPE_CID = STSBS.STATUS_TYPE_CID
AND PLSBS.STATUS_CID = STSBS.STATUS_CID
AND PLS.ANCHOR_DATE >= SP1.FROM_DATE
AND PLS.ANCHOR_DATE <= SP1.TO_DATE
AND PXSP.PRVDR_LCTN_IID = PLS.PRVDR_LCTN_IID
AND PXSP.SPCLTY_SUBSPCLTY_SID = SSP.SPCLTY_SUBSPCLTY_SID
AND PLS.ANCHOR_DATE >= PXSP.FROM_DATE
AND PLS.ANCHOR_DATE <= PXSP.TO_DATE
AND SSP.SPCLTY_CODE = SP.SPCLTY_CODE
-- AND SSP.SUBSPCLTY_CODE = SP1.SPCLTY_CODE
AND SSP.SUBSPCLTY_CODE = SP1.SPCLTY_CODE
AND PLS.ANCHOR_DATE >= SSP.FROM_DATE
AND PLS.ANCHOR_DATE <= SSP.TO_DATE
AND PLS.ANCHOR_DATE >= SP.FROM_DATE
AND PLS.ANCHOR_DATE <= SP.TO_DATE
ORDER BY /*Query Builder Clause*/
"Provider Id" DESC
) A
WHERE rownum < 101
Here is the Emplain plan
SQL> @c:\mohammed\tune\UTLXPLS
Plan Table
| Operation | Name | Rows | Bytes| Cost | Pstart| Pstop |
| SELECT STATEMENT | | | | | | |
| COUNT STOPKEY | | | | | | |
| VIEW | | | | | | |
| SORT ORDER BY STOPKEY | | 1 | 358 | 120 | | |
| SORT ORDER BY STOPKEY | | | | | | |
| NESTED LOOPS | | 1 | 358 | 117 | | |
| NESTED LOOPS | | 1 | 313 | 116 | | |
| NESTED LOOPS | | 1 | 268 | 115 | | |
| NESTED LOOPS | | 1 | 240 | 114 | | |
Plan Table
| NESTED LOOPS | | 1 | 209 | 112 | | |
| NESTED LOOPS | | 1 | 95 | 111 | | |
| NESTED LOOPS | | 1 | 74 | 110 | | |
| NESTED LOOPS | | 7 | 294 | 103 | | |
| INDEX UNIQUE SCAN |SYS_C00489936 | 1 | 7 | | | |
| TABLE ACCESS FULL |PRVDR_LCTN_STATUS | 1K| 53K| 102 | | |
| TABLE ACCESS BY INDEX ROWID |PRVDR_LCTN_STATUS | 57K| 1M| 2 | | |
| INDEX RANGE SCAN |TUNE_PNBS2_1 | 57K| | 1 | | |
| TABLE ACCESS BY INDEX ROWID |STATUS | 5 | 105 | 1 | | |
| INDEX UNIQUE SCAN |SYS_C00489936 | 5 | | | | |
| TABLE ACCESS BY INDEX ROWID |PROVIDER_LOCATION_D | 40K| 4M| 1 | | |
Plan Table
| INDEX UNIQUE SCAN |XPKPROVIDER_LOCATIO | 40K| | | | |
| TABLE ACCESS BY INDEX ROWID |PRVDR_LCTN_X_SPCLTY | 1M| 39M| 3 | | |
| INDEX RANGE SCAN |TUNE_SARWAR_0503200 | 1M| | 2 | | |
| TABLE ACCESS BY INDEX ROWID |SPECIALTY_SUBSPECIA | 549 | 15K| 1 | | |
| INDEX UNIQUE SCAN |SYS_C00489888 | 549 | | | | |
| TABLE ACCESS BY INDEX ROWID |SPECIALTY | 11 | 495 | 1 | | |
| INDEX UNIQUE SCAN |SYS_C00489875 | 11 | | | | |
| TABLE ACCESS BY INDEX ROWID |SPECIALTY | 11 | 495 | 1 | | |
| INDEX UNIQUE SCAN |SYS_C00489875 | 11 | | | | |
32 rows selected.
I have tried with several hints and several driving tables and tires. Any help in this regard will be highly appreciated.
Thanks a lot,
Mohammed Sarwar
ocp dba
Email: [email protected]
[email protected]
Phone : 301-944-2029 w
913-484-9204 cellThis should be better. Any help on tuning the above sql statement using the following explain plan will be highly appreciated.
Plan Table
| Operation ------------------| Name -------------| Rows | Bytes| Cost | Pstart| Pstop |
| SELECT STATEMENT -----------| ------------------| -----| -------|------| | |
| COUNT STOPKEY --------------|-------------------|------|--------|------| | |
| VIEW -----------------------|-------------------|----- | -------| -----| | |
| SORT ORDER BY STOPKEY ------|------------------ |--- 1 | ---358 | 120 -| | |
| SORT ORDER BY STOPKEY ------| ------------------|----- |------- | -----| | |
| NESTED LOOPS ---------------|-------------------|--- 1 |--358 -|- 117 | | |
| NESTED LOOPS ---------------|----------------- -|--- 1 | -313 -| -116 | | |
| NESTED LOOPS ---------------|----------------- -|--- 1 | 268-- | 115 -| | |
| NESTED LOOPS--------------- |-------------------| --1- | -240 -| -114 | | |
Plan Table
| NESTED LOOPS--------------- |------------------ | ---1 |- 209 -|- 112 | | |
| NESTED LOOPS--------------- | ------------------|--- 1 |-- 95- | -111 | | |
| NESTED LOOPS ---------------|----- -------------|--- 1 |-- 74 -| -110 | | |
| NESTED LOOPS ---------------|----------------- -|--- 7 | -294- |- 103| | |
| INDEX UNIQUE SCAN ----------|SYS_C00489936------| ---1 |--- 7--|-----| | |
| TABLE ACCESS FULL ----------|PRVDR_LCTN_STATUS -| --1K | 53K-- | 102 | | |
| TABLE ACCESS BY INDEX ROWID |PRVDR_LCTN_STATUS- | 57K -|---- 1M|-- 2 | | |
| INDEX RANGE SCAN -----------|TUNE_PNBS2_1 ------| 57K- |------ |-- 1 | | |
| TABLE ACCESS BY INDEX ROWID |STATUS------------ | 5 |105----|-- 1 | | |
| INDEX UNIQUE SCAN---------- |SYS_C00489936 -----| 5--- | ------|-----| | |
| TABLE ACCESS BY INDEX ROWID-|PROVIDER_LOCATION_D| 40K | 4M----|-- 1 | | |
Plan Table
| INDEX UNIQUE SCAN ----------|XPKPROVIDER_LOCATIO| 40K |----- |----- | | |
| TABLE ACCESS BY INDEX ROWID-|PRVDR_LCTN_X_SPCLTY| 1M -|---39M|--- 3 | | |
| INDEX RANGE SCAN -----------|TUNE_SARWAR_0503200| 1M -| -----|--- 2 | | |
|TABLE ACCESS BY INDEX ROWID- |SPECIALTY_SUBSPECIA| 549 |---15K| ---1 | | |
| INDEX UNIQUE SCAN ----------|SYS_C00489888 -----| 549 |----- | -----| | |
|TABLE ACCESS BY INDEX ROWID- |SPECIALTY ---------| 11- |---495|--- 1 | | |
| INDEX UNIQUE SCAN ----------|SYS_C00489875----- | 11 -|----- |----- | | |
|TABLE ACCESS BY INDEX ROWID -|SPECIALTY ---------| 11- |---495|----1 | | |
| INDEX UNIQUE SCAN-----------|SYS_C00489875----- | 11 -|----- |----- | | |
-------------------------------------------------------------------------------- -
Long Running SQL and ORDS Spawns Multiple Database Sessions
Hi all.
We have a strange situation when accessing a long running SQL Report (a single APEX Page).
The SQL takes about 15 mins to run but when I monitor what database sessions are spawned by the APEX Listener, I see multiple sessions all executing the same SQL. It appears that after 6 minutes, the APEX Listener spawns a new database session to execute the same SQL.
Has anyone seen this before and if so, is there a key setting I am missing as I don't want this to happen. I am new to the APEX Listener and WebLogic so apologies if this is the way it's meant to work but it seems odd that after a certain amount of time (6 minutes in my case) a new database session is spawned to do the same work.
We are running:
WebLogic: 10.3.0.6
APEX_LISTENER_VERSION 2.0.0.354.17.06
Datadate: 11.2.0.3.0 Production
APEX: 4.2.1.00.08
Cheers for any help.
DuncsHi Duncan,
With all respect, you should please rethink your interface. I would never consider writing a Web application with a request that knowingly takes 15 minutes to return the results. You can consider doing this asynchronously via DBMS_SCHEDULER and then alerting the user (via email, perhaps) that their results are ready. Or if you can precompute this in advance, consider using materialized views so that the user's response time is sub-second.
In an era where the patience of the average end-user is measured in single-digit seconds, it is impractical to ever expect an end-user to wait 15 minutes for their resultant Web page.
Joel -
Hi all,
Some users run reports for very large period of time (diffrence of start & end dates 2 years) and they end up scanning the whole database and crashing the application services.
Is there any way to monitor this kind of queries and kill it before the application hangs??
thanks in advance.If you set up PROFILES in your database (you need to set RESOURCE_LIMIT to true for this), you don't need to monitor any query, the session will be killed automatically when a threshold is exceeded.
Consult the PROFILE concept and the CREATE PROFILE command in the documentation for further details.
Sybrand Bakker
Senior Oracle DBA -
Webkit timeout kills long running tasks
Hi There
We have just been forced to refactor/recode a significant
portion of one of our AIR based RIA's due to an arbitrary decision
made by the Webkit team to restrict all XML HTTP requests via a
hard coded, hidden timeout of 60 seconds. This decision not only
affects AIR but also affects Safari and other browsers based upon
Webkit.
Our application performs complex analytic queries which may
run to a few minutes. Whilst long synchronous requests are not
generally a good idea for web based solutions, we believe that RIA
intranet applications are a completely different ball game and
should not be subject to arbitrary constraints such as these with
no flexibility or warning. We would not see this behaviour in Java
/ C# or other such application languages, so why are we seeing this
in Adobe AIR?
Our MD has understandably questioned the suitability of Adobe
AIR for future developments of enterprise RIA's, and we are all
naturally concerned about other "features" being added or removed
to the Adobe AIR functionality, even indirectly and whether in fact
we can rely upon Adobe to monitor the stability of their runtime.
We don't believe it is acceptable for us to tell our customers that
it was the fault of a component nested within multiple layers of
the runtime outside of our control and believe that it is equally
unacceptable for Adobe to stand by and claim the same.
We are excited about the prospects of investing in Adobe AIR
for delivering rapid RIAs to our customers, but are we to expect
similar show stoppers to arise over the coming months or even
years, and can we trust the Adobe runtime as an "In production"
solution going forward.
Mark Robertshaw
Director
Oxford Information Labs
http://www.oxil.co.ukMark,
Thanks for bringing this to our attention. We, as I'm sure
you realize, aren't claiming that this sort of thing is ok. And we
do work hard to maintain the stability of the runtime. However, it
can be difficult to know a priori everything that we need to keep
an eye on. That's one of the reasons we have forums like this one
and we very much appreciate this kind of feedback.
As for this particular issue, I'll just point out that you
might consider taking advantage of the flash.net.* APIs to manage
your network request, at least as a temporary workaround.
regards,
Oliver Goldman | Adobe AIR Engineering -
Hi
I am planning to use enterprise manager grid control to create a UDM for the following sql that would alert me for the sql that is running for more then a hour for all databases any ideas on how to do this
SELECT
substr(swn.sql_text,40),
||'SQL is Running on Instance ' ||s.inst_id || 'Since '|| ROUND(sl.elapsed_seconds/60) elapsed_mins,
FROM gv$session_longops sl,
gv$session s ,
gv$sql swn
WHERE s.sid = sl.sid
AND s.inst_id = sl.inst_id
AND s.serial# = sl.serial#
AND s.inst_id = swn.inst_id
AND s.sql_address = swn.address
AND s.sql_hash_value = swn.hash_value
AND sl.sofar <> sl.totalwork
AND sl.totalwork <> 0
AND round((sl.elapsed_seconds)/60,0) > 60
order by 7Edited by: user9243284 on Jun 7, 2010 3:48 AMI think you should specify:
SQL query output: two columns
Metric Type: String
and the following query:
SELECT 'NA',0
from dual
union
SELECT distinct '( ' ||i.instance_name ||','|| sl.sid ||','|| sl.serial# ||', ) ' || substr(s.sql_text,1,1000) sql, ROUND(sl.elapsed_seconds/60) mins
FROM gv$session_longops sl,
gv$sql s,
gv$instance i
WHERE sl.sofar = sl.totalwork
AND sl.totalwork = 0
AND sl.inst_id = s.inst_id (+)
AND sl.sql_address = s.address (+)
AND sl.sql_hash_value = s.hash_value (+)
AND sl.inst_id = i.inst_id
use the select from dual, to make sure your query allways returns at least one row.
BTW, you will find some examples of UDM creation on my blog.
Regards
Rob
http://oemgc.wordpress.com -
We've an SQL procedure that hangs after running for hours. We've identified the SQL that's causing the bottleneck. Pl. find screnshot of the explain plan below.
Pls. suggest me to improve the performance of this query.
===============================================
SELECT COUNT(DISTINCT reat_elg.prd_hld_id)
FROM tl_w_prd_hld prdhld , tl_w_prd_hld_role prdhldrl , tl_w_phlc_cnt_stat prdhldco , tl_w_reat_elg reat_elg
WHERE reat_elg.prd_hld_id = prdhld.prd_hld_id AND
prdhld.prd_hld_id = prdhldrl.prd_hld_id AND
prdhld.prd_hld_id = prdhldco.prd_hld_id AND
reat_elg.prd_hld_id != '-1' AND
reat_elg.eligible_ind = 'Y' AND
prdhldrl.eff_end_date IS NULL AND
prdhldrl.hms_legown_ind = 'Y' AND
prdhldco.legown_issue_ind = 'N' AND
prdhld.jntown_type_ind='N' AND
reat_elg.prd_hld_id IN
(SELECT distinct phr2.prd_hld_id
FROM tl_w_prd_hld_role phr2, tl_w_phlc_cnt_stat ph_loi
WHERE ph_loi.prd_hld_id=ph_loi.prd_hld_id AND
phr2.prd_hld_id = reat_elg.prd_hld_id AND
phr2.eff_end_date IS NULL AND
phr2.hms_legown_ind = 'Y' AND
(ph_loi.create_source,phr2.prd_hld_id) IN
(SELECT DISTINCT
(CASE
WHEN (ccntbl_ind='Y' OR ce_legown_issue_ind='N' OR sfc_cntbl_ind='' OR sfc_legown_issue_ind='') AND ce_hms_legown_ind='Y' THEN ce_create_source
WHEN ccntbl_ind='Y' AND ce_legown_issue_ind='N' AND ce_hms_legown_ind='Y' THEN ce_create_source
WHEN ((ccntbl_ind='N' OR ce_legown_issue_ind='Y') AND ce_hms_legown_ind='Y' ) AND (sfc_cntbl_ind='Y' AND sfc_legown_issue_ind='N' AND SFC_hms_legown_IND='Y') THEN sfc_create_source
WHEN ((ccntbl_ind='N' OR ce_legown_issue_ind='Y') AND ce_hms_legown_ind='Y' ) AND ((sfc_cntbl_ind='N' AND sfc_legown_issue_ind='Y') AND SFC_hms_legown_IND='Y') THEN sfc_create_source
WHEN ((ccntbl_ind='N' OR ce_legown_issue_ind='Y') AND ce_hms_legown_ind='Y' ) AND (sfc_cntbl_ind='Y' AND sfc_legown_issue_ind='N' AND SFC_hms_legown_IND='N') THEN ce_create_source
WHEN ((ccntbl_ind='N' OR ce_legown_issue_ind='Y') AND ce_hms_legown_ind='Y' ) AND ((sfc_cntbl_ind='N' AND sfc_legown_issue_ind='Y') AND SFC_hms_legown_IND='N') THEN ce_create_source
END
(CASE
WHEN (ccntbl_ind='Y' OR ce_legown_issue_ind='N' OR sfc_cntbl_ind='' OR sfc_legown_issue_ind='') AND ce_hms_legown_ind='Y' THEN CE_prd_hld_ID
WHEN ccntbl_ind='Y' AND ce_legown_issue_ind='N' AND ce_hms_legown_ind='Y' THEN ce_create_source
WHEN ((ccntbl_ind='N' OR ce_legown_issue_ind='Y') AND ce_hms_legown_ind='Y' ) AND (sfc_cntbl_ind='Y' AND sfc_legown_issue_ind='N' AND SFC_hms_legown_IND='Y') THEN sfc_prd_hld_id
WHEN ((ccntbl_ind='N' OR ce_legown_issue_ind='Y') AND ce_hms_legown_ind='Y' ) AND ((sfc_cntbl_ind='N' AND sfc_legown_issue_ind='Y') AND SFC_hms_legown_IND='Y') THEN sfc_prd_hld_id
WHEN ((ccntbl_ind='N' OR ce_legown_issue_ind='Y') AND ce_hms_legown_ind='Y' ) AND (sfc_cntbl_ind='Y' AND sfc_legown_issue_ind='N' AND SFC_hms_legown_IND='N') THEN ce_prd_hld_id
WHEN ((ccntbl_ind='N' OR ce_legown_issue_ind='Y') AND ce_hms_legown_ind='Y' ) AND ((sfc_cntbl_ind='N' AND sfc_legown_issue_ind='Y') AND SFC_hms_legown_IND='N') THEN ce_prd_hld_id
END
FROM
SELECT
cnteng.prd_hld_id ce_prd_hld_id,
cnteng.cntbl_ind ccntbl_ind,
cnteng.legown_issue_ind ce_legown_issue_ind,
cnteng.hms_legown_ind ce_hms_legown_ind,
cnteng.create_source ce_create_source,
slsfrc.prd_hld_id sfc_prd_hld_id,
slsfrc.cntbl_ind sfc_cntbl_ind,
slsfrc.legown_issue_ind sfc_legown_issue_ind,
slsfrc.hms_legown_ind sfc_hms_legown_ind,
slsfrc.create_source sfc_create_source
FROM
(SELECT ph_loi.prd_hld_id,ph_loi.cntbl_ind,ph_loi.legown_issue_ind,prdhldrl.hms_legown_ind,ph_loi.create_source FROM tl_w_phlc_cnt_stat ph_loi,tl_w_prd_hld_role prdhldrl
WHERE
ph_loi.prd_hld_id=prdhldrl.prd_hld_id
AND ph_loi.create_source!='slsfrc'
)cnteng,
SELECT ph_loi.prd_hld_id,ph_loi.cntbl_ind,ph_loi.legown_issue_ind,prdhldrl.hms_legown_ind,ph_loi.create_source FROM tl_w_phlc_cnt_stat ph_loi,tl_w_prd_hld_role prdhldrl
WHERE
ph_loi.prd_hld_id=prdhldrl.prd_hld_id
AND ph_loi.CREATE_SOURCE='slsfrc'
)slsfrc where cnteng.prd_hld_id=slsfrc.prd_hld_id
GROUP BY phr2.prd_hld_id
HAVING COUNT(*) > 1
================================================
Explain plan
SQL> select * from table(dbms_xplan.display);
Message was edited by:
user604968Dear user604968
(Why not give your profile a name?)
Your explain plan has been removed - which doesn't help - but here's a couple of things
1) the use of DISTINCT in each of the main query, subquery and sub-sub-query fills me with suspicion. The complexity of the query makes me think that the data model is either misunderstood or (more likely) poorly designed
2) the outermost subquery is almost certainly incorrectly correlated with the outer query:
WHERE ph_loi.prd_hld_id=ph_loi.prd_hld_id why compare a column to itself? Presumably this should be something like:
WHERE ph_loi.prd_hld_id=phr2.prd_hld_id Good luck with puzzling it out...
Regards Nigel -
All,
I'm new for sql query tuning. My select sql query is running more than 5-6 hours to complete and it is using bind variable. I'm using OEM to monitor the query. I can see stats are upto date and no blocking sessions and no object locks in db level. Can anyone guide me where I have to look and what should be done to increase the performance?
Thanks.Read FAQ: {message:id=9360003}
And {message:id=9360002} -
How to kill long running package?
Hi,
Oracle version : 11.0.1.7.0
OS: IBM-AIX
I have executed health check package "DBMS_HM.RUN_CHECK" But my Database performance badly degraded. I wish to end the execution of the package.
How can i kill it?
Thanks
KSG-- show PROCESS id for all the active sessions
select p.spid,s.sid,s.serial#,s.username,s.status,s.client_identifier,s.last_call_et,p.program,p.terminal,logon_time,module,s.osuser
from V$process p,V$session s
where s.paddr = p.addr and s.status = 'ACTIVE' and s.username not like '%SYS%';
Find out the session and kill the session.
alter system kill session 'sid,serial#';
alter system kill session '32,87568';
Regards
Asif kabir -
Long running table partitioning job
Dear HANA grus,
I've just finished table partitioning jobs for CDPOS(change document item) with 4 partitions by hash with 3 columns.
Total data volumn is around 340GB and the table size was 32GB !!!!!
(migration job was done without disabling CD, so currently deleting data on the table with RSCDOK99)
Before partitioning, the data volumn of the table was around 32GB.
After partitioning, the size has changed to 25GB.
It took around One and half hour with exclusive lock as mentioned in the HANA adminitration guide.
(It is QA DB, so less complaints)
I thought that I might not can do this in the production DB.
Does anyone hava any idea for accelerating this task?? (This is the fastest DBMS HANA!!!!)
Or Do you have any plan for online table partitioning functionality??(To HANA Development team)
Any comments would be appreciate.
Cheers,
- JasonJason,
looks like we're cross talking here...
What was your rationale to partition the table in the first place?
=> To reduce deleting time of CDPOS (As I mentioned it was almost 10% quantity of whole Data volume, So I would like to save deleting time of the table from any pros of partitioning table like partitioning pruning)
Ok, I see where you're coming from, but did you ever try out if your idea would actually work?
As deletion of data is heavily related with locating the records to be deleted, creating an index would have probably be the better choice.
Thinking about it... you want to get rid of 10% of your data and in order to speed the overall process up, you decide to move 100% of the data into sets of 25% of the data - equally holding their 25% share of the 10% records to be deleted.
The deletion then should run along these 4 sets of 25% of data.
It's surely me, but where is the speedup potential here?
How many unloads happened during the re-partitioning?
=> It was fully uploaded in the memory before partitioning the table by myself.(from HANA studio)
I was actually asking about unloads _during_ the re-partitioning process. Check M_CS_UNLOADS for the time frame in question.
How do the now longer running SQL statements look like?
=> As i mentioned selecting/deleting increased almost twice.
That's not what I asked.
Post the SQL statement text that was taking longer.
What are the three columns you picked for partitioning?
=> mandant, objectclas, tabname(QA has 2 clients and each of them have nearly same rows of the table)
Why those? Because these are the primary key?
I wouldn't be surprised if the SQL statements only refer to e.g. MANDT and TABNAME in the WHERE clause.
In that case the partition pruning cannot work and all partitions have to be searched.
How did you come up with 4 partitions? Why not 13, 72 or 213?
=> I thought each partitions' size would be 8GB(32GB/4) if they are divided into same size(just simple thought), and 8GB size is almost same size like other largest top20 tables in the HANA DB.
Alright, so basically that was arbitrary.
For the last comment of your reply, most people would do partition for their existing large tables to get any benefit of partitioning(just like me). I think your comment can be applied for the newly inserting data.
Well, not sure what "most people" would do.
HASH partitioning a large existing table certainly is not an activity that is just triggered off in a production system. Adding partitions to a range partitions table however happens all the time.
- Lars -
Putting an already running SQL to background
Hi Gurus,
This sounds like a stupid problem but I'm sure most DBAs have faced it. Is there a way to move a long running SQL (like a create table as select * from big_table) to background process? I was contemplating whether there is a similar UNIX-like ctrl-z...
thanks,
jamesSimple answer, no.
Complex answer... well perhaps.
Your client session connects to Oracle. Oracle uses a server process to service your client session. You throw a CTAS (create table as select - yes, we also have acronyms for everything) its way.
The client process now waits. The SQL call it made is a blocking/synchronous call. The server process gets the CTAS, parses it into a cursor, and executes its.
What happens when you pull the client's plug? Nothing. The Oracle server process will only notice that its client session it is suppose to service is gone after the CTAS. As the CTAS is a DDL is has an implicit commit. So after the actual table has been created, the server process will notice you have pulled the client's plug and it will rollback (nothing to rollback), and terminate.
So the CTAS would have completed despite you pulling the client plug.
However.. this is pretty much an ugly hack of putting a server process in background mode so to speak. Also, it assumes that DCD (Dead Connected Detection) does not play a role. Also assumes that this behaviour of the server process is common across different Oracle patchsets and releases.
The correct method would be to use an EXECUTE IMMEDIATE command for the CTAS and to execute that using Oracle's DBMS_JOB or DBMS_SCHEDULER (10g and later).
Maybe you are looking for
-
Need advice with upgrading to a new HD
Hello, all. My available hardware: MBP 13-inch w/160GB HD running OS X Lion 500GB external firewire HD which I exclusively use for Time Machine 8GB USB flash drive 500GB internal 2.5-inch HD which I intend to install in the MBP USB 2.5-inch HD enclos
-
Option key not functioning correctly since 10.6.8
Since I upgraded to 10.6.8, my keyboard (first sllim version, extended) option key has not been functioning correctly or at all. Here are just a few problems associated with it: 8 I can no longer make a bullet (option 8) as you see here 8 I can no lo
-
IBM websphere 6.1 integration with OAM
Hi, 1) Is the "interceptorClassName" Clases Name important? can i name it as other thing rather than what is stated in the documentation? example: According to the WAS integtraion guide the Interceptor classname is as: com.oblix.tai.was5.WebGate2Trus
-
Contract Management for CCM 1.0 items ? (Not in backend)
Hi guys, I would like to enable Contract Management (Local & Global) in my SRM 4.0 sp8 environment. However, 90% of the catalog items in CCM (4,000 articles aprox) do not exist in the backend. My very simple question is: Should I create all thi
-
Change InfoProvider after ARCHIVING in BW 3.5
Hello Community, In this previous [thread|changing an archive object in BW;, we came to know that a BW archiving object can only be changed by deleting it. And, it is also true that deleting the archiving object will remove the ability to restore th