Long running sql
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 cell
This 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 -|----- |----- | | |
--------------------------------------------------------------------------------
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 -
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
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 -
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 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 -
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 -
I'm now writing some reports that are slow running. I've tuned the sql, however because the volume of data being returned and the complexity of the report queries the reports will likely never run faster then ~30 seconds.
I'm using the ApEx advanced reporting (BIP) and ApEx version 3.0.1.
What are some thoughts on how to best implement long running reports?
Thanks,
Todd
Message was edited by:
tfaHi Dimitri,
You asked...
What happens when you run the report directly from BI
Publisher?There are several reports from one application. I've run the report queries in OEM SQL Tuning Advisor and tuned them.
I have not seen a noticeable difference in run times between submitting the reports from APEX or running them from BIP. The queries for these reports have the same run time when run through SQL Developer.
The slow run time of the report queries can be traced to poor table design. The application is a bit of legacy application with the front end now being rewritten using APEX. The poor table design issues are magnified by the volume of data. I have plans to partition one of the transaction tables.
Prior to rewriting the user interface in APEX the application was written in Oracle Forms. When written in Forms the application was a bolt-on to the Oracle applications. In that environment users could submit reports to the run in the background (via Concurrent Manger) then the report output was viewed later following the completion of the report.
I'm pursuing a similar solution as the concurrent manager in Oracle applications but available in the APEX, BIP environment. The reports do run between 30 seconds to 1 minute which is to long for the users to wait on the submitting page. Any thoughts on how it is possible to run these long running reports without tying up the user’s page?
I'll investigate dbms_scheduler and BIP APIs. I know BIP also has a scheduler available but I do not know much about it.
Thanks,
Todd -
Long running query--- included steps given by Randolf
Hi,
I have done my best to follow Randolf instruction word-by-word and hope to get solution for my
problem soon. Sometime back I have posted a thread on this problem then got busy with other
stuff and was not able to follow it. Here I am again with same issue.
here is link for my previous post
long running query in database 10gHere is backgroud of my requriemment.
I am working on Oracle forms 10g which is using package given below. We want to display client information
with order count basd on different status like Pending, Error, back Order, expedited, std shipping.
Output will look something like.
client name pending error backorder expedited std shipping
ABC 24 0 674 6789 78900
XYZ 35 673 5700 0 798274
.There are total 40 clients . The long running query are expedited and std shipping.
When i run package from Oracle Form Developer it takes 3 mintues to run but when I run same query in our application using forms
(which uses Oracle Application Server) it takes around 1 hour, which is completly unacceptable.
User wants it be done in less than 1 mintue.
I have tried combining Pending,error and backorder queries together but as far as I know it will not
work in Oracle Form as we need a place holder for each status.
Please dont think it is Forms related question, it is a Performance problem.
PACKAGE BODY ORDER_COUNT_PKG IS
PROCEDURE post_query IS
BEGIN
BEGIN
SELECT count(*)
INTO :ORDER_STATUS.PENDING
FROM orders o
WHERE o.status = 'P'
AND (parent_order_id is null
OR (order_type='G'
AND parent_order_id=original_order_number))
AND o.client = :ORDER_STATUS.CLIENT_NUMBER;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
BEGIN
SELECT count(*)
INTO :ORDER_STATUS.ERROR
FROM orders o
WHERE o.status = 'E'
AND (parent_order_id is null
OR (order_type='G'
AND parent_order_id=original_order_number))
AND o.client = :ORDER_STATUS.CLIENT_NUMBER;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
BEGIN
SELECT count(*)
INTO :ORDER_STATUS.BACK_ORDER
FROM orders o
WHERE o.status = 'B'
AND (parent_order_id is null
OR (order_type='G'
AND parent_order_id=original_order_number))
AND o.client = :ORDER_STATUS.CLIENT_NUMBER;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
BEGIN
SELECT count(*)
INTO :ORDER_STATUS.EXPEDITE
FROM orders o,shipment_type_methods stm
WHERE o.status in ('A','U')
AND (o.parent_order_id is null
OR (o.order_type = 'G'
AND o.parent_order_id = o.original_order_number))
AND o.client = stm.client
AND o.shipment_class_code = stm.shipment_class_code
AND (nvl(o.priority,'1') = '2'
OR stm.surcharge_amount <> 0)
AND o.client = :ORDER_STATUS.CLIENT_NUMBER
GROUP BY o.client;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
BEGIN
SELECT count(*)
INTO :ORDER_STATUS.STD_SHIP
FROM orders o,shipment_type_methods stm
WHERE o.status in ('A','U')
AND (o.parent_order_id is null
OR (o.order_type = 'G'
AND o.parent_order_id = o.original_order_number))
AND nvl(o.priority,'1') <> '2'
AND o.client = stm.client
AND o.shipment_class_code = stm.shipment_class_code
AND stm.surcharge_amount = 0
AND o.client = :ORDER_STATUS.CLIENT_NUMBER
GROUP BY o.client;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END post_query;
END ORDER_COUNT_PKG;one of the query which is taking long time is
SELECT count(*)
FROM orders o,shipment_type_methods stm
WHERE o.status in ('A','U')
AND (o.parent_order_id is null
OR (o.order_type = 'G'
AND o.parent_order_id = o.original_order_number))
AND nvl(o.priority,'1') <> '2'
AND o.client = stm.client
AND o.shipment_class_code = stm.shipment_class_code
AND stm.surcharge_amount = 0
AND o.client = :CLIENT_NUMBER
GROUP BY o.clientThe version of the database is 10.2.1.0.2
SQL> alter session force parallel dml;These are the parameters relevant to the optimizer:
SQL> show parameter user_dump_dest
NAME TYPE VALUE
user_dump_dest string /u01/app/oracle/admin/mcgemqa/
udump
SQL> show parameter optimizer
NAME TYPE VALUE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.4
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
SQL> show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 16
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
SQL> show parameter cursor_sharing
NAME TYPE VALUE
cursor_sharing string EXACTHere is the output of EXPLAIN PLAN:
SQL> explain plan for
2 SELECT count(*)
3 FROM orders o,shipment_type_methods stm
4 WHERE o.status in ('A','U')
5 AND (o.parent_order_id is null
6 OR (o.order_type = 'G'
7 AND o.parent_order_id = o.original_order_number))
8 AND nvl(o.priority,'1') <> '2'
9 AND o.client = stm.client
10 AND o.shipment_class_code = stm.shipment_class_code
11 AND stm.surcharge_amount = 0
12 AND o.client = :CLIENT_NUMBER
13 GROUP BY o.client
14 /
Explained.
Elapsed: 00:00:00.12
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 559278019
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 35 | 46764 (3)| 00:09:22 |
| 1 | SORT GROUP BY NOSORT | | 1 | 35 | 46764 (3)| 00:09:22 |
|* 2 | TABLE ACCESS BY INDEX ROWID | ORDERS | 175K| 3431K| 25979 (3)| 00:05:12 |
| 3 | NESTED LOOPS | | 25300 | 864K| 46764 (3)| 00:09:22 |
|* 4 | TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS | 1 | 15 | 2 (0)| 00:00
|* 5 | INDEX RANGE SCAN | U_SHIPMENT_TYPE_METHODS | 2 | | 1 (0)| 00:00:01 |
|* 6 | INDEX RANGE SCAN | ORDERS_ORDER_DATE | 176K| | 2371 (8)| 00:00:29 |
Predicate Information (identified by operation id):
2 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
"O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE")
4 - filter("STM"."SURCHARGE_AMOUNT"=0)
5 - access("STM"."CLIENT"=:CLIENT_NUMBER)
6 - access("O"."CLIENT"=:CLIENT_NUMBER)
filter("O"."STATUS"='A' OR "O"."STATUS"='U')
24 rows selected.
Elapsed: 00:00:00.86
SQL> rollback;
Rollback complete.
Elapsed: 00:00:00.07Here is the output of SQL*Plus AUTOTRACE including the TIMING information:
SQL> SELECT count(*)
2 FROM orders o,shipment_type_methods stm
3 WHERE o.status in ('A','U')
4 AND (o.parent_order_id is null
5 OR (o.order_type = 'G'
6 AND o.parent_order_id = o.original_order_number))
7 AND nvl(o.priority,'1') <> '2'
8 AND o.client = stm.client
9 AND o.shipment_class_code = stm.shipment_class_code
10 AND stm.surcharge_amount = 0
11 AND o.client = :CLIENT_NUMBER
12 GROUP BY o.client
13 /
Elapsed: 00:00:03.09
Execution Plan
Plan hash value: 559278019
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 35 | 46764 (3)| 00:09:22 |
| 1 | SORT GROUP BY NOSORT | | 1 | 35 | 46764 (3)| 00:09:22 |
|* 2 | TABLE ACCESS BY INDEX ROWID | ORDERS | 175K| 3431K| 25979 (3)| 00:05:12 |
| 3 | NESTED LOOPS | | 25300 | 864K| 46764 (3)| 00:09:22 |
|* 4 | TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS | 1 | 15 | 2 (0)| 00:00
|* 5 | INDEX RANGE SCAN | U_SHIPMENT_TYPE_METHODS | 2 | | 1 (0)| 00:00:01 |
|* 6 | INDEX RANGE SCAN | ORDERS_ORDER_DATE | 176K| | 2371 (8)| 00:00:29 |
Predicate Information (identified by operation id):
2 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
"O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE")
4 - filter("STM"."SURCHARGE_AMOUNT"=0)
5 - access("STM"."CLIENT"=:CLIENT_NUMBER)
6 - access("O"."CLIENT"=:CLIENT_NUMBER)
filter("O"."STATUS"='A' OR "O"."STATUS"='U')
Statistics
55 recursive calls
0 db block gets
7045 consistent gets
0 physical reads
0 redo size
206 bytes sent via SQL*Net to client
238 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> disconnect
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> The TKPROF output for this statement looks like the following:
SELECT count(*)
FROM orders o,shipment_type_methods stm
WHERE o.status in ('A','U')
AND (o.parent_order_id is null
OR (o.order_type = 'G'
AND o.parent_order_id = o.original_order_number))
AND nvl(o.priority,'1') <> '2'
AND o.client = stm.client
AND o.shipment_class_code = stm.shipment_class_code
AND stm.surcharge_amount = 0
AND o.client = :CLIENT_NUMBER
GROUP BY o.client
call count cpu elapsed disk query current rows
Parse 1 0.01 0.00 0 0 0 0
Execute 1 0.04 0.04 0 0 0 0
Fetch 2 2.96 2.91 0 7039 0 1
total 4 3.01 2.95 0 7039 0 1
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: 95
Rows Row Source Operation
1 SORT GROUP BY NOSORT (cr=7039 pr=0 pw=0 time=2913701 us)
91 TABLE ACCESS BY INDEX ROWID ORDERS (cr=7039 pr=0 pw=0 time=261997906 us)
93 NESTED LOOPS (cr=6976 pr=0 pw=0 time=20740 us)
1 TABLE ACCESS BY INDEX ROWID SHIPMENT_TYPE_METHODS (cr=2 pr=0 pw=0 time=208 us)
3 INDEX RANGE SCAN U_SHIPMENT_TYPE_METHODS (cr=1 pr=0 pw=0 time=88 us)(object id 81957)
91 INDEX RANGE SCAN ORDERS_ORDER_DATE (cr=6974 pr=0 pw=0 time=70 us)(object id 81547)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 2 0.00 0.00
SQL*Net message from client 2 0.02 0.02
********************************************************************************The DBMS_XPLAN.DISPLAY_CURSOR output:
SQL> variable CLIENT_NUMBER varchar2(20)
SQL> exec :CLIENT_NUMBER := '14'
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.06
SQL> SELECT /*+ gather_plan_statistics */ count(*)
2 FROM orders o,shipment_type_methods stm
3 WHERE o.status in ('A','U')
4 AND (o.parent_order_id is null
5 OR (o.order_type = 'G'
6 AND o.parent_order_id = o.original_order_number))
7 AND nvl(o.priority,'1') <> '2'
8 AND o.client = stm.client
9 AND o.shipment_class_code = stm.shipment_class_code
10 AND stm.surcharge_amount = 0
11 AND o.client = :CLIENT_NUMBER
12 GROUP BY o.client
13 /
COUNT(*)
91
Elapsed: 00:00:02.85
SQL> set termout on
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID 4nfj368y8w6a3, child number 0
SELECT /*+ gather_plan_statistics */ count(*) FROM orders o,shipment_type_methods stm WHERE
o.status in ('A','U') AND (o.parent_order_id is null OR (o.order_type = 'G'
AND o.parent_order_id = o.original_order_number)) AND nvl(o.priority,'1') <> '2' AND
o.client = stm.client AND o.shipment_class_code = stm.shipment_class_code AND
stm.surcharge_amount = 0 AND o.client = :CLIENT_NUMBER GROUP BY o.client
Plan hash value: 559278019
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
| 1 | SORT GROUP BY NOSORT | | 1 | 1 | 1 |00:00:02.63 | 7039 |
|* 2 | TABLE ACCESS BY INDEX ROWID | ORDERS | 1 | 175K| 91 |00:03:56.87 | 7039 |
| 3 | NESTED LOOPS | | 1 | 25300 | 93 |00:00:00.02 | 6976 |
|* 4 | TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS | 1 | 1 | 1 |00:00:00.01 | 2 |
|* 5 | INDEX RANGE SCAN | U_SHIPMENT_TYPE_METHODS | 1 | 2 | 3 |00:00:00.01 | 1 |
|* 6 | INDEX RANGE SCAN | ORDERS_ORDER_DATE | 1 | 176K| 91 |00:00:00.01 | 6974 |
Predicate Information (identified by operation id):
2 - filter((("O"."PARENT_ORDER_ID" IS NULL OR ("O"."ORDER_TYPE"='G' AND
"O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER"))) AND NVL("O"."PRIORITY",'1')<>'
"O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE"))
4 - filter("STM"."SURCHARGE_AMOUNT"=0)
5 - access("STM"."CLIENT"=:CLIENT_NUMBER)
6 - access("O"."CLIENT"=:CLIENT_NUMBER)
filter(("O"."STATUS"='A' OR "O"."STATUS"='U'))
32 rows selected.
Elapsed: 00:00:01.30
SQL> I'm looking forward for suggestions how to improve the performance of this statement.
Thanks
SandyPlease find explain plan for No hint
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 559278019
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 35 | 46764 (3)| 00:09:22 |
| 1 | SORT GROUP BY NOSORT | | 1 | 35 | 46764 (3)| 00:09:22 |
|* 2 | TABLE ACCESS BY INDEX ROWID | ORDERS | 175K| 3431K| 25979 (3)| 00:05:12 |
| 3 | NESTED LOOPS | | 25300 | 864K| 46764 (3)| 00:09:22 |
|* 4 | TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS | 1 | 15 | 2 (0)| 00:00
|* 5 | INDEX RANGE SCAN | U_SHIPMENT_TYPE_METHODS | 2 | | 1 (0)| 00:00:01 |
|* 6 | INDEX RANGE SCAN | ORDERS_ORDER_DATE | 176K| | 2371 (8)| 00:00:29 |
Predicate Information (identified by operation id):
2 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
"O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE")
4 - filter("STM"."SURCHARGE_AMOUNT"=0)
5 - access("STM"."CLIENT"=:CLIENT_NUMBER)
6 - access("O"."CLIENT"=:CLIENT_NUMBER)
filter("O"."STATUS"='A' OR "O"."STATUS"='U')
24 rows selected.
Elapsed: 00:00:00.86Explain Plan for Parallel Hint
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 559278019
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 35 | 46764 (3)| 00:09:22 |
| 1 | SORT GROUP BY NOSORT | | 1 | 35 | 46764 (3)| 00:09:22 |
|* 2 | TABLE ACCESS BY INDEX ROWID | ORDERS | 175K| 3431K| 25979 (3)| 00:05:12 |
| 3 | NESTED LOOPS | | 25300 | 864K| 46764 (3)| 00:09:22 |
|* 4 | TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS | 1 | 15 | 2 (0)| 00:00
|* 5 | INDEX RANGE SCAN | U_SHIPMENT_TYPE_METHODS | 2 | | 1 (0)| 00:00:01 |
|* 6 | INDEX RANGE SCAN | ORDERS_ORDER_DATE | 176K| | 2371 (8)| 00:00:29 |
Predicate Information (identified by operation id):
2 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
"O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_CODE")
4 - filter("STM"."SURCHARGE_AMOUNT"=0)
5 - access("STM"."CLIENT"='14')
6 - access("O"."CLIENT"='14')
filter("O"."STATUS"='A' OR "O"."STATUS"='U')
24 rows selected.
Elapsed: 00:00:08.92Explain Plan for USE_Hash hint
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1465232248
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 35 | 46786 (3)| 00:09:22 |
| 1 | SORT GROUP BY NOSORT | | 1 | 35 | 46786 (3)| 00:09:22 |
|* 2 | HASH JOIN | | 25300 | 864K| 46786 (3)| 00:09:22 |
|* 3 | TABLE ACCESS BY INDEX ROWID| SHIPMENT_TYPE_METHODS | 1 | 15 | 2 (0)| 00:00:0
|* 4 | INDEX RANGE SCAN | U_SHIPMENT_TYPE_METHODS | 2 | | 1 (0)| 00:00:01 |
|* 5 | TABLE ACCESS BY INDEX ROWID| ORDERS | 175K| 3431K| 46763 (3)| 00:09:22 |
|* 6 | INDEX RANGE SCAN | ORDERS_ORDER_DATE | 176K| | 4268 (8)| 00:00:52 |
Predicate Information (identified by operation id):
2 - access("O"."CLIENT"="STM"."CLIENT" AND "O"."SHIPMENT_CLASS_CODE"="STM"."SHIPMENT_CLASS_COD
E")
3 - filter("STM"."SURCHARGE_AMOUNT"=0)
4 - access("STM"."CLIENT"='14')
5 - filter(("O"."PARENT_ORDER_ID" IS NULL OR "O"."ORDER_TYPE"='G' AND
"O"."PARENT_ORDER_ID"=TO_NUMBER("O"."ORIGINAL_ORDER_NUMBER")) AND NVL("O"."PRIORITY",'1')<>'2
6 - access("O"."CLIENT"='14')
filter("O"."STATUS"='A' OR "O"."STATUS"='U')
25 rows selected.
Elapsed: 00:00:01.09
SQL> Thanks
Sandy
Maybe you are looking for
-
title says it all. I get a whole mess of faac/faad warnings and messages... libfaad: Unexpected channel configuration change any ideas?
-
Parent class not waiting for child class to finish
hi, i have class a and method x in class a which calls class b. its fine till there. but before my class b's action is completed, in which i have to choose a file and display those files in jtable, the remaining lines in method x getting executed. wh
-
My iPhone 5 restarts after a while
Hi, I am having this problem since today, 2 days ago my battery run out and I didn't have any charger. Today I charged the phone and it keeps restarting, during the charging process and even after it. It looks like something fails, the display shows
-
User exit to make the field 'Long text for UD' as mandatory
Hi Gurus, My requiremen is that while doing UD, I need to make the field 'Long text for UD' as mandatory for the rejected materials pls suggest. Thanks Ganesh
-
Difficulty installing dreamweaver with vista
I have gotten a new computer and it has vista, we have had difficulty installing dreamweaver, It just won't install. Has anyone had this problem before is there a patch etc... Thanks E