Monitoring Long Running SQL
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
Similar Messages
-
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,
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 -|----- |----- | | |
-------------------------------------------------------------------------------- -
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? -
Ccms monitoring - Long running job
I checked in CMMS monitoring (RZ20) version ECC 6.0, there is no option to monitor long running background job.
How to monitor long running background job using transaction RZ20?Hi,
Check this [link|Re: How to monitor long running background job.;
Thanks
Sunny -
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} -
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 -
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 -
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 -
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). -
Long running select statement and v$session_longops
Oracle Version: 10.2.0.4
I've a long running sql query that takes the estimated 6 minutes to complete and return the result.
While it's running I'd like to observe it into the view v$session_longops.
I altered the session that runs the query with
ALTER SESSION SET timed_statistics=TRUE;The tables it queries have gathered statistics on them.
However I don't see any rows in the view v$session_longops for the respective SID and serial#. Why is that? What am I missing?
Thank you!Hi,
Now I understand what you all meant by "loops" here .. Yes, the query does nested loops as one can see from the execution plan. So it could be the reason
SELECT STATEMENT, GOAL = ALL_ROWS
SORT GROUP BY
CONCATENATION
TABLE ACCESS BY LOCAL INDEX ROWID TABLE_1
NESTED LOOPS
NESTED LOOPS
TABLE ACCESS BY GLOBAL INDEX ROWID TABLE_2
INDEX RANGE SCAN IPK_t2_CDATE
TABLE ACCESS BY INDEX ROWID TABLE_3
INDEX RANGE SCAN IPK_T3
PARTITION RANGE ALL
INDEX RANGE SCAN IRGP_REGCODE
TABLE ACCESS BY LOCAL INDEX ROWID TABLE_1
NESTED LOOPS
NESTED LOOPS
TABLE ACCESS BY GLOBAL INDEX ROWID TABLE_2
INDEX RANGE SCAN IPK_t2_STATUS
TABLE ACCESS BY INDEX ROWID TABLE_3
INDEX RANGE SCAN IPK_T3
PARTITION RANGE SINGLE
INDEX RANGE SCAN IRGP_REGCODE -
SQL Developer Locking up/Unable to Cancel long Running tasks
I have had the same problem with a number of versions of SQL Developer (and version 3.2.09). It occurs when trying to cancel a long-running PL-SQL Function or procedure that has been started by 'Run' in SQL Developer.
Select Terminate in Run Manager does not stop the job. Nor does trying to exit SQLDeveloper; it asks whether I want to kill the job; then doesn't kill it and doesn't exit either.
Trying to save modifications to anything the process depends on results in SQL Developer locking for ~20 minutes.
I have to resort to getting a DBA to manually kill the process at the server.
Is there any possiblity of a workaround or a way of making the PL/SQL not lock so it can be terminated please?
ThanksI have had the same problem with a number of versions of SQL Developer (and version 3.2.09). It occurs when trying to cancel a long-running PL-SQL Function or procedure that has been started by 'Run' in SQL Developer.
Select Terminate in Run Manager does not stop the job. Nor does trying to exit SQLDeveloper; it asks whether I want to kill the job; then doesn't kill it and doesn't exit either.
Trying to save modifications to anything the process depends on results in SQL Developer locking for ~20 minutes.
I have to resort to getting a DBA to manually kill the process at the server.
Is there any possiblity of a workaround or a way of making the PL/SQL not lock so it can be terminated please?
Thanks -
Alert monitor for long running background jobs
Hello,
I have to configure an alert moniter for long running background jobs which are running more than 20000 secs using rule based. I have created a rule based MTE and assigend MTE class CCMS_GET_MTE_BY_CLASS to virtual node but i dont find a node to specify the time.
could any one guide me how can i do this.
Thanks,
KasiHi *,
I think the missing bit is where to set the maximum runtime. The runtime is set in the collection method and not the MTE class.
process: rz20 --> SAP CCMS Technical Expert Monitors --> All Contexts on local application server --> background --> long-running jobs. Click on 'Jobs over Runtime Limits' then properties, click the methods tab then double click 'CCMS_LONGRUNNING_JOB_COLLECT', in the parameters tab you can then set the maximum runtime.
If you need to monitor specific jobs, follow the process (http://help.sap.com/saphelp_nw70/helpdata/en/1d/ab3207b610e3408fff44d6b1de15e6/content.htm) to create the rule based monitor, then follow this process to set the runtime.
Hope this helps.
Regards,
Riyaan.
Edited by: Riyaan Mahri on Oct 22, 2009 5:07 PM
Edited by: Riyaan Mahri on Oct 22, 2009 5:08 PM
Maybe you are looking for
-
PO outbound message control - Condition record / PO IDOC outbound user exit
Guys, I have a system with PO outbound message control sending PO idocs to a unique plant that is set up as a customer in the partner profile. I am using a custom message type and RSEOUT00 to send my idocs with custom message type to this plant. This
-
Page numbers wrong in PDF - original Quark file ok!
We do magazines mainly and have a Homes and Interiors publication which I have produced for over 7 years. The workflow has changed over the years and is now a PDF one as you'd expect. We output from Quark 7.31 to a postscript file then distill using
-
Error installing DPM Agent in Update Rollup 5 for System Center 2012 R2 Data Protection Manager
I have updated my main DPM server to Update Rollup 5 for System Center 2012 R2 Data Protection Manager and all went well. All Protected servers updated and rebooted and continued protection - EXCEPT one; Physical Windows Server 2012 R2 Datacenter. Tr
-
Datagrid colum item renderer HELP!!!!!
Hi, I have the below datagrid, and I have to populate one of the column with three different images, a cricle an squeare and a triangle. I've been sucessful adding dinamically the differents itemrenderers. For the triangle one it has been a really pa
-
Hi, can we use 15 inch mac book pro dvd to macbook pro13
hi, can we use 15 inch mac book pro dvd to macbook pro13