How to cancel long running query by client
Hi,
I have the following problem:
The user calls a service function (business logic) by an application client. Inside the function call an SQL-Query is generated and started on the database (JDBC). Depending on comlexity of the query or search parameter (e.g. search for chemical structures with SYMYX or Accord) the statement is running very long. In this case the user would like to cancle the search by pressing a button in the client application.
Using preparedStatements there is a cancle method. Because the preparedStatement is inside the called business logic function the preparedStatement is not accessible fom the client or other service methods the normal way. If I understand this correct, I have to make all started preparedStatements public inside my service and then try to access the correct statement by an additional service call (other thread). This sounds a bit like a hack.
Has anyone this constellation running or is there an other way?
I would be happy about any hints or suggestions.
Thanks, Antje.
Best to post this in the Java > SQL/JDBC Forum
Similar Messages
-
In forms how to cancel long running process or query in 10g
We have application which is hosted on 10g AS. Some forms has lot of processing to be done and sometimes user wants to cancel the processing in between maybe because he wants to change some value and refire processing.
Based on the search on net 'Esc' key was used in earlier version of forms to function as User requested Cancel operation. How can same be done in 10g. Do we have to do anything in fmrweb.res for this. Is there some setting to be done in forms or in AS for this functionality.
Does this matter on whether JInitiator is used or JPI is used for running the application?
Edited by: suresh_mathew on May 21, 2013 1:36 AMHi,
Exit can be used to cancel query mode i.e. in case you go into query mode by Exit you can cancel query mode. Suppose you went into query mode and you have fired query which will take some time to fetch how can I abort it.
In earlier version of form there was 'Cancel' facility wherein if triggered it used to fire an error message 'Ora--01013 user requested cancel of current operation"
With this facility you can abort any query which is executing or any long running process which forms is currently performing.
fmrweb.res would have entry like
27 : 0 : "Esc" : 1001 : "Cancel"
The above entry I picked from OPN
Java Function Numbers And Key Mappings For Forms Deployed Over Web [ID 66534.1]
Unfortunately this is not working for us even if I put this in frmweb.res of 10g AS
Basically I want ability to Abort/Cancel a long running process be it query execution or standard process triggered in the form.
Any advise or help is highly appreciated.
Suresh -
How to Cancel Long Running Report
Hello
I'm looking for a way to cancel the printing of a long running report programatically? I'm using the CrystalDecisions.CrystalReports.Engine.ReportDocument() class.
Thanks for your helpHi Syed,
The old viewer was COM based and the new viewer is .NET. CR has the ability if the DB server supports Async communication. Most DB's don't so it wasn't of much use. For those that did the functionality was through custom coding within the Designer only. Async would allow CR to send a stop processing command to the DB server. If the server did not have the ability then CR can only wait for the data to start coming back before stopping the viewer from updating.
In any event I don't believe the Windows Viewer in .NET has the ability but I will suggest it to the Product group to add the ability in some future version.
Thank you
Don -
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 -
Canceling long running queries
This definitely occurs in 1.5.5 - in my particular case, and this is really strange, if one uses Task Manager to shut down SQLDeveloper because it is just taking forever to get a Data view (via the + expand sign on the side of a given admittedly big table, then clicking on the Data tab), SQLDeveloper freezes. Even if I start a new instance of SQLDeveloper, and ask for a Data view again, it freezes - I've waited as much as 1/2 hour, where as in prior days I'd get a response within say 1 min.
I've even uninstalled and re-installed. Same deal. This is what's the strangest by far. How can it be that SQLDeveloper remembers that a long running query was once canceled even after an uninstall / reinstall ? I could not find anything remotely related to this in the Registry after the uninstall either.
[By the way, if on the other hand, I say SELECT * FROM {table_name}, I get an instant response !] -
Explain for a very long running query
Dear gurus,
I have an issue with a long running query which takes around 2 hrs to execute. The tables being used here pertains to 11i, so there is no scope of indexing.
SELECT peia.expenditure_item_id, DECODE (peia.system_linkage_function, 'ST', 'TIME', 'EXP' ) AS CATEGORY,
pea.incurred_by_person_id AS employee_id, emp.attribute6 AS q_number, NVL (emp.employee_number, npw_number) AS employee_number, emp.full_name AS employee_name, peia.project_id,
ppa.segment1, ppa.NAME, func_get_proj_attribute (peia.project_id, NULL, 'PROJECT ENTITY NAME' ) AS project_entity,
func_get_proj_attribute (peia.project_id, NULL, 'PROJECT MANAGER') AS project_manager,
DECODE (ppa.distribution_rule, 'WORK/WORK', 'TM', 'WORK/EVENT', 'TM with Milestone' ) AS project_classification,
ppa.project_type AS funding_type, func_get_proj_attribute(peia.project_id, NULL, 'CUSTOMER GROUP' ) AS customer_group,
func_get_proj_attribute(peia.project_id, NULL, 'ACCOUNT MANAGER' ) AS account_manager,
pt.top_task_id, func_get_task_attribute(pt.top_task_id, 'TASK NUMBER' ) AS task_number,
func_get_task_attribute (pt.top_task_id, 'TASK NAME' ) AS task_name, peia.expenditure_item_date, peia.projfunc_raw_revenue AS func_raw_revenue,
peia.accrued_revenue AS func_accrued_revenue, peia.projfunc_currency_code,
DECODE (peia.project_raw_revenue, NULL,
DECODE (peia.system_linkage_function, 'ST', peia.quantity* NVL (peia.bill_rate, func_get_emp_billrate (pea.incurred_by_person_id, peia.project_id, peia.task_id,
peia.expenditure_item_date )
peia.quantity
peia.project_raw_revenue
( peia.accrued_revenue
/ peia.projfunc_raw_revenue
* peia.project_raw_revenue
) AS project_accrued_revenue,
ppa.project_currency_code,
NVL(peia.bill_rate, func_get_emp_billrate (pea.incurred_by_person_id, peia.project_id, peia.task_id, peia.expenditure_item_date)
) AS bill_rate,
peia.rev_dist_rejection_code, SYSDATE AS generated_date
FROM pa_expenditures_all pea
INNER JOIN (SELECT * FROM per_all_people_f WHERE SYSDATE BETWEEN effective_start_date AND effective_end_date) emp ON NVL(pea.incurred_by_person_id, 61) =emp.person_id
INNER JOIN (SELECT * FROM pa_expenditure_items_all WHERE billable_flag = 'Y' AND quantity <> 0) peia ON pea.expenditure_id =peia.expenditure_id
INNER JOIN (SELECT * FROM pa_projects_all WHERE project_status_code = 'APPROVED' AND distribution_rule IN ('WORK/WORK', 'WORK/EVENT')) ppa ON peia.project_id =ppa.project_id
INNER JOIN pa_tasks pt ON peia.task_id = pt.task_id;
The explain plan for this is:
SELECT STATEMENT CHOOSECost: 26,758 Bytes: 53,373,971 Cardinality: 245,963
9 HASH JOIN Cost: 26,758 Bytes: 53,373,971 Cardinality: 245,963
1 TABLE ACCESS FULL TABLE HR.PER_ALL_PEOPLE_F Cost: 67 Bytes: 546,900 Cardinality: 9,115
8 HASH JOIN Cost: 26,581 Bytes: 20,174,029 Cardinality: 128,497
2 TABLE ACCESS FULL TABLE PA.PA_TASKS Cost: 596 Bytes: 856,370 Cardinality: 85,637
7 HASH JOIN Cost: 25,691 Bytes: 18,889,059 Cardinality: 128,497
3 TABLE ACCESS FULL TABLE PA.PA_EXPENDITURES_ALL Cost: 1,524 Bytes: 5,220,330 Cardinality: 522,033
6 HASH JOIN Cost: 23,701 Bytes: 17,604,089 Cardinality: 128,497
4 TABLE ACCESS FULL TABLE PA.PA_PROJECTS_ALL Cost: 91 Bytes: 49,059 Cardinality: 621
5 TABLE ACCESS FULL TABLE PA.PA_EXPENDITURE_ITEMS_ALL Cost: 23,575 Bytes: 68,913,570 Cardinality: 1,188,165
Can anyone suggests what can be done to improve this query?
Thanks in advance
SA
Edited by: user593719 on Oct 5, 2010 10:29 AM
Edited by: user593719 on Oct 5, 2010 10:30 AM1) Your inner joins are doing record selections that could be done on the Join's ON clause.
2) Look at your functions to see if you can get performance improvements using parameterized CURSORs & adding DETERMINISTIC to the definition.
3) Consider using WITH to first pull your data & then running your functions.
For example:
with
smiths as (
select *
from hr.per_all_people_f papf
where papf.first_name='Smith'
select *
from smiths
where trunc(sysdate) between effective_start_date and effective_end_date;
In general, pare down your data first. Whatever will restrict your data most, start with selecting that table/view. -
On JDBC statement, there is the method 'cancel' to instruct the database to cancel an executing statement. This works fine on Oracle server database, but not on Oracle lite database. The method call 'cancel' just blocks and the running statement is never interrupted.
The example I tried is very simple. There is a thread started which executes a long running statement. I noticed, that when moving the cursor forward by calling rs.next(), it just blocks. That would be ok, if the statement could be canceled from within the main thread by stmt.cancel. But this call blocks as well with no implact on the running statement. Why is that? Do I miss something or is it not possible to cancel a long running statements in Oracle Lite?
In the following my code snipped:
public class CancelStatement {
private static final String PATH_DB = "XX";
private static final String PATH_LIB = "XX";
private static final String CON_STRING = "jdbc:polite:whatever;DataDirectory=" + PATH_DB + ";Database=XX;IsolationLevel=Read Committed;Autocommit=Off;CursorType=Forward Only";
private static final String USER = "XX";
private static final String PASSWORD = "XX";
public static void main(String args[]) throws Exception {
System.setProperty("java.library.path", PATH_LIB);
Class.forName("oracle.lite.poljdbc.POLJDBCDriver");
Connection con = DriverManager.getConnection(CON_STRING, USER, PASSWORD);
Statement stmt = con.createStatement();
Thread thread = new Thread(new LongStatementRunnable(con, stmt));
thread.start();
Thread.sleep(3000);
// stop long running statement
System.out.println("cancel long running statement");
stmt.cancel(); // XXX does not work, as call is blocked until out of memory
System.out.println("statement canceled");
private static class LongStatementRunnable implements Runnable {
private Connection con;
private Statement stmt;
public LongStatementRunnable(Connection con, Statement stmt) {
this.con = con;
this.stmt = stmt;
@Override
public void run() {
try {
System.out.println("start long running statement...");
// execute long running statement
ResultSet rs = stmt.executeQuery("SELECT * FROM PERSON P1, PERSON P2");
while (rs.next()) { // here the execution gets blocked
System.out.println("row"); // is never entered
rs.close();
stmt.close();
con.close();
System.out.println("long running statement finished...");
} catch (Exception e) {
e.printStackTrace();
}I would be very glad if you could help me.
Thanks a lot
Daniel
Edited by: 861793 on 26.05.2011 14:29Unfortunately Oracle Lite doesn't have this option. You can call your statement from a second thread as you have done, but you won't be able to kill or cancel this operation. The only way to get fix this is by rebooting. You can use process explorer to find the dll process that is executing the SQL, but the tables will be locked and sync would be locked as well until the process is finished running in shared memory.
-
Hi Gurus,
I wanted to know how to cancel an running load..is it to change the status into red n deleted it from the cube..??
once i did it like this in my system but after sometime the laod again automatically converted into green n continue its loading..
can anyone tell me on how to cancel an running load...
waiting for reply
RaviHi,
First and foremost let me advice you to be very careful while doing this.
You can start from SM37, find the process WID/PID then go to SM50 or SM51 and kill it. Once its done come back to RSMO and check the request, it should be red but again manually force to red and save by clicking on the total status button in the status tab. This shuld ensure that the process is killed properly.
The next step will be to go to targets that you were loading and remove the red requests from those targets.
Note: For source system loads you may have to check if the request is running in the source system and kill if needed and pull it again.
But for BW datamart delta loads u may have reset the datamarts in case u are going to pull the delta again.
Thanks,
JituK -
How can i cancel long running queries (red x doesnt work)
hi there
i am trying to work with some long running queries - it would be very nice to be able to cancel them (like toads cancel button)
I have tried the red X in the circle but it doesnt seem to work - it appears to have cancelled it (the cylon-eye style comfort bar stops ocillating) but if i try to use the connection again, or disconnect or open another connection it says:
"connection currently busy. Try again?"
i have tried this in the latest release vanilla & the latest release plus patch 2
thanks
MartinGood news that this will be improved. Can't resist to post this Link: [plsql forum thread about start/stop.. | http://forums.oracle.com/forums/thread.jspa?forumID=75&threadID=927697]
I have experienced the same and also noted that it feels better to execute stored procedures in sqldeveloper
- by editing
- compiling (might hang if already busy)
- run from the same dialog just to get the the cylon's eye for emergency stops (which waits .... ) meanwhile jump to apex to fiddle with small table triggering exception to stop the procedure.
If stored procedure is executed from the list via 'right mouse click'-style then you see in the log-region "connecting to databse ... ." but no method to stop nor cancel or cylon's eye is well hidden.
When such "busy" is running I also noted that the database-connection right mouse click has greyed/inactivated the selections "connect/disconnect" so the next logical step for stopping via "disconnect" is out of the question.
I think this also boils down also to question whether the user has rights to see gv$session and be able to drop/stop busy/jamming sessions. E.g. public synonyms listing has small icons with mystic red :)
/paavo
Java(TM) Platform 1.6.0_14
Oracle IDE 1.5.4.59.40 -
How to terminate the running query for a report?
Hi,
When I run a report, the SQL query takes too long.
This causes an overload on database.
How do I stop query from running after some time?It is NOT possible in OBIEE 10g.
In OBIEE 11g, When a scheduled report job is in running status, you can now cancel the running job from the Report Job History page.
Check this Section 6.9, ["Canceling a Running Job." |http://docs.oracle.com/cd/E23943_01/bi.1111/e22257/view_manage_rpt_his.htm#cancel_runj]
And only possible since 11.1.1.5
regards
Jorge
p.s If this answers your question then please mark my answer as "Correct" or "Helpful" -
Hi Folks,
Is it possible to submit a SELECT statment using OraSqlStmt object and retrieve the data so generated?
I want to submit a long-running SELECT query against Oracle, and have the option to cancel the query.
I can submit the query asynchronously NONBLK option of OraSqlStmt and then be able to cancel it. However, I also want to display the dataset returned by the query. But I think it is not possible to create a dataset / recordset or dynaset using OraSqlStmt.
THe question is:
How can I submit a long running Select query, be able to cancel it and if the query is not cancelled then be able to display the records in a grid? I am using VB6.
ThanksGood news that this will be improved. Can't resist to post this Link: [plsql forum thread about start/stop.. | http://forums.oracle.com/forums/thread.jspa?forumID=75&threadID=927697]
I have experienced the same and also noted that it feels better to execute stored procedures in sqldeveloper
- by editing
- compiling (might hang if already busy)
- run from the same dialog just to get the the cylon's eye for emergency stops (which waits .... ) meanwhile jump to apex to fiddle with small table triggering exception to stop the procedure.
If stored procedure is executed from the list via 'right mouse click'-style then you see in the log-region "connecting to databse ... ." but no method to stop nor cancel or cylon's eye is well hidden.
When such "busy" is running I also noted that the database-connection right mouse click has greyed/inactivated the selections "connect/disconnect" so the next logical step for stopping via "disconnect" is out of the question.
I think this also boils down also to question whether the user has rights to see gv$session and be able to drop/stop busy/jamming sessions. E.g. public synonyms listing has small icons with mystic red :)
/paavo
Java(TM) Platform 1.6.0_14
Oracle IDE 1.5.4.59.40 -
How to cancel a running search
Hi
Is it possible to cancel a running search? Sometimes a search may take a long time to complete and may be the user would like to cancel the search. When the user uses the quick search I display a popup to prohibit user input based on the documentation here:
[DF Code Corner: How-to show a glasspane and splash screen for long running queries|http://www.google.com/url?sa=t&rct=j&q=displaying+popup+for+long+running+queries&source=web&cd=1&ved=0CFUQFjAA&url=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fdeveloper-tools%2Fadf%2Flearnmore%2F27-long-running-queries-169166.pdf&ei=48LWT8SAOcmg4gTfj6DGAw&usg=AFQjCNH5T8wNP7MJtaCHf5chVHqy82aq1w]
Now, I am considering to put a cancel button in the popup and cancel the search when the button is clicked. How could I do that if it is possible.
I am using JDev 11.1.1.4 and JHs 11.1.1.3.35
Regards,
FerezFerez,
this is really an ADF issue, not JHeadstart. I think there's not much you can do beyond setting timeout parameters on your view objects ( http://docs.oracle.com/cd/E28389_01/apirefs.1111/e10653/oracle/jbo/ViewObject.html#setQueryTimeOut%28int%29 ), but you might get better answers on the ADF forum. -
How to cancel payment run?
Hi,
Is there a way to cancel a complete payment run? I know how to cancel individual payments (and clearing) but how to do it for a run which includes e.g. +1000 payments?
Thanks!
Regards, AkiHI,
Hi
If you haven't yet run the payment proposal, go to Edit/Parameters/Delete.
If you have run the payment proposal go to Edit/Proposal/Delete.
REGARDS,
SANTHOSH -
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 -
V$session_longops not displaying a long running query
Hi,
There is a certain query that runs as a part of a stored procedure which when run takes about 1 and half hours to get completed and there is a hint in this query to use certain indexes on few tables.
This time was unacceptable as it was much much longer than what it should have taken so I tried to monitor it through v$session_longops using the following query
select * from v$session_longops where time_remaining > 0
It shows no rows selected but the query is still running.
When I changed the hint in the query to use the full table scan on these tables instead of the indexes it began to show up on the v$session_longops and it took like only 15 mins for the procedure execution to get completed.
My questions are two fold
1) Why did the first time with the Hint on the indexes not show up on v$session_longops with time_remaining > 0 and why did it show up only when i did a full table scan?
2) Secondly is'nt a scan on a table faster using indexes if the index has unique values on the columns we are trying to get data from than the Full Table Scans. And if so then why is it behaving differently in this case.
Thanks a lot in advance for any answers/suggestions1. v$session_longops only reports long running operations. The CBO assumes that the index scan is a tiny operation (nested loop joins), hence it is not displaying the query, but when you have a full table scan, the CBO assumes this to be a long operation, and hence it is visible in v$session_longops.
2. Allow me to quote from
"http://asktom.oracle.com/pls/ask/f?p=4950:8:17968334624783495563::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:9422487749968"
"full scans are not evil, indexes are not good"
"full scans are not evil, indexes are not good"
"full scans are not evil, indexes are not good"
Click that link for more information. :)
The gist of it is, your CBO is smart, and hence generating a better plan than when you force it to use indexes. Yes, the plan has full table scans, but that is not a crime. What you can do is use optimizer parameters - "optimizer_index_cost_adj" to tune for a better performance, but you should not force an index unless you are sure that the index gives you a lower cost.
You could paste the plan for you queries with and without hints and also paste the optimizer hints - show parameter optimizer.
Maybe you are looking for
-
If I change a file name, how can I get all the links to update?
I've recently finished my webpage (kensingtonconcertseries.com),.....then my client wanted to change the name of one of his pages from 'Marold Duo' to 'Rodewald-Morebello Duo.' All of my links to that page are to the original page(MaroldDuo.html). Ar
-
Static File in Exploded Application
I am trying to read a gif from an exploded application. The exploded application is recognized ( I can view it's index.html page. ), but I can not view a gif that is part of the app. Any suggestions? Is there some special configuration that is necess
-
Pantone 2196 C how to convert to CMYK it is not in CS6
Pantone 2196 C how to convert to CMYK it is not in CS6
-
Click 40gb cannot restore at all
Click wheel 40GB Windows XP iPod worked fine for ages until the first time I came to connect it to Kensington RDS FM Transmitter/Car Charger for iPod, eventually got it to work after a couple of mins – all seemed ok – did notice it skipping songs tha
-
Register Control events?
Hallo, I've discovered that I can connect a control reference to the EventSource input of the RegisterForEvents function. This event (e.g Button1:MouseUp) appears as dynamic event in the EventStructure editor. Up to this point it seems to be possible