Long running threads (Jasper Reports) and AM-Pooling
Hi,
we are developing quite large application with ADF an BC. We have quite a lot of reports generated through Jasper that take quite long time to complete. The result is a PDF document that user gets on the UI so he can download it over download link. Reports that take over an hour to finish are never completed and returned to the user on UI. I think the problem is in AM-Polling because we are using default AM-Polling settings:
<AM-Pooling jbo.ampool.maxinactiveage="600000" jbo.ampool.monitorsleepinterval="600000" jbo.ampool.timetolive="3600000"/>
The AM is destroyed or returned to pool before reports finishes. How to properly configure those settings that even long running threads will do there jobs to the end.
We also modified web.xml as follows:
<session-config>
<session-timeout>300</session-timeout>
</session-config>
Any help appreciated.
Regards, Tadej
Your problem is not related to ADF ApplicationModules. AMs are returned to the pool no earlier than the end of request, so for sure they are not destroyed by the framework while the report is running. The AM timeout settings you are referring to are applicable only to idle AMs in the pool but not to AMs that have been checked out and used by some active request.
If you are using MS Internet Explorer, then most probably your problem is related to the IE's ReceiveTimeout setting, which defines a timeout for receiving a response from the server. I have had such problems with long running requests (involving DB processing running for more than 1 hour) and solved my problem by increasing this timeout. By default this timeout is as follows:
IE4 - 5 minutes
IE5, 6, 7, 8 - 60 minutes
I cannot find what the default value is for IE9 and IE10, but some people claim it is only 10 seconds, although this information does not sound reasonable and reliable! Anyway, the real value is hardly greater than 60 minutes.
You should increase the ReceiveTimeout registry value to an appropriate value (greater than the time necessary for your report to complete). Follow the instructions of MS Support here:
Internet Explorer error "connection timed out" when server does not respond
I have searched Internet for similar timeout settings for Google Chrome and Mozilla Firefox, but I have not found anything, so I instructed my customers (who execute long-running DB processing) to configure and use IE for these requests.
Dimitar
Similar Messages
-
Hello everyone,
Thanks for your interest in this post. I have a design question on a feature we are currently working on - I have described it below as best as I can. I would be thankful for any direction or guidance from all the good and experienced folks here in this forum :)
We have a system which receives some input data (say in the form of files or a db update) from external sources. We have a job which wakes up periodically, checks for the presence of new data and then does some parsing/data manipulation. I have posted it below and for the sake of brevity and conciseness kept it simple.
public class Work{
private SomeVar _var;
//constructor here
public void doWork(){
//run job
} Note we have multiple kind of input (so multiple Work classes each of which have different parse logic).
So far so good.
We have jdk 1.4 (no java.util.concurrent) and we dont have an option to use a scheduling f/w like quartz
Its simple enough and we dont have a need for Listeners, dynamic scheduling etc.
That leaves us with 2 options to implement this
Option 1
Create a thread for each kind of job on startup.
Each thread checks for presence of input data and creates a Work object to process the job.
public class WorkThread extends Thread{//some common functionality here}
public class SpecificWorkThread extends WorkThread{
private MetaInfo _meta;
//constructor
public void run(){
while(true){
//check for presence of input data
Work _w = new Work();
_w.doWork();
//sleep for some time
pulic class Controller{
psv main(String args[]){
//for each job{
WorkThread t = new SpecificWorkThread();
t.start();
//join on all threads
} As you can see this would create (from the main), a long running thread for each job type
Option 2
Have the input data check in the controller clas. When there is input data to parse, create a Thread which does the parsing.
The thread in its run method parses and comes out. So for each parse cycle, a short lived thread is created, somthing like below
public class WorkController{
psv main(String args[]){
while(true){
//check for input condition
new SpecificWorkThread(new Work()).start();
//sleep for sometime
public class SpecificWorkThread extends Thread{
private Work _work;
//constructor
public void run(){
_work.doWork();
The difference between the two is that while the first creates long running threads per job type, in option(2) a thread is created on demand. Each thread is short lived (it does its job and dies), but then a thread needs to be created every time for a job.
Both would work and work correctly. What I would like to understand is if the options presented above just a programmer's prefence or is one option better than the other (performance, memory considerations) etc?
Thanks for your patience in reading this post.
cheers,
ram.Generally creating a new thread is an expensive process. Well, everything is relative. My laptop can create & run & stop 7,000+ threads per second, test program below, YMMV. If you are dealing with thousands of thread creations per second, pooling may be sensible; if not, premature optimization is the root of all evil, etc.
public class ThreadSpeed
public static void main(String args[])
throws Exception
System.out.println("Ignore the first few timings.");
System.out.println("They may include Hotspot compilation time.");
System.out.println("I hope you are running me with \"java -server\"!");
for (int n = 0; n < 5; n++)
doit();
System.out.println("Did you run me with \"java -server\"? You should!");
public static void doit()
throws Exception
long start = System.currentTimeMillis();
for (int n = 0; n < 10000; n++) {
Thread thread = new Thread(new MyRunnable());
thread.start();
thread.join();
long end = System.currentTimeMillis();
System.out.println("thread time " + (end - start) + " ms");
static class MyRunnable
implements Runnable
public void run()
}Edited by: sjasja on Jan 14, 2010 2:20 AM -
Problem in debuging jasper reports and ADF
Hi
I am using JDeveloper 11.1.2.2.0. Inside I created Fusion Web Application ADF, and on the index page created Go button. Now I created Servlet with doGet methode and conncected it to Go button. It is working OK.
Now I want to run simple jasper report from servlet. Jasper report is based on empty dataset. Here is servlet code:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ServletOutputStream servletOutputStream =response.getOutputStream();
InputStream reportStream = getServletConfig().getServletContext()
.getResourceAsStream("C:/Users/myDomain/Desktop/Reporting/ReportPDFPrazan.jasper");
try
JasperRunManager.runReportToPdfStream(reportStream,servletOutputStream,null, new JREmptyDataSource());
response.setContentType(CONTENT_TYPE);
servletOutputStream.flush();
servletOutputStream.close();
catch (JRException e)
// display stack trace in the browser
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
response.setContentType("text/plain");
response.getOutputStream().print(stringWriter.toString());
When I hit Go button here what I get:
java.lang.NullPointerException
at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2265)
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2278)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)
at java.io.ObjectInputStream.(ObjectInputStream.java:279)
at net.sf.jasperreports.engine.util.ContextClassLoaderObjectInputStream.(ContextClassLoaderObjectInputStream.java:53)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:214)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:632)
at net.sf.jasperreports.engine.JasperRunManager.runToPdfStream(JasperRunManager.java:428)
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdfStream(JasperRunManager.java:849)
at view.com.lanaco.servlets.PrviServlet.doGet(PrviServlet.java:35)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
and so on(I can put whole stack if necery)
I also imported this libraries inside ViewControl project:
Jasperreports-4.7.1.jar
Commons-beanutils-1.8.0.jar
Commons-collections-2.1.1.jar
Commons-digester-2.1.jar
Commons-logging-1.1.1.jar
IText-2.1.7.jar
Groovy-all-1.7.5.jar
Poi-3.7-20101029.jar
Can someone help me with debuging. Please
Edited by: MarcusO on 2012.10.23 05:18I found solution. It should be used like this:
InputStream reportStream = new FileInputStream(new File("C:/Users/myDomain/Desktop/Reporting/ReportPDFPrazan.jasper"));
So problem was in input stream. It works fine now. -
Hi,
I use jasper report with an XML datasource. I have an image in the xml stream encode as a string with a class name Base64.
I want to display the image in my report but I dont know how to do this. Does someone know something about this ?
Help, please.
Thanks.
Guillaume.use iReport to edit you reports
and insert images..
ireport link .
http://ireport.sourceforge.net/
it's simple to add new images -
How to generate jasper report and how to integrate jasper report in ADF11g
Hi All,
I want to generate jasper report in ADF11g Jdeveloper.and how to integrate jasper report in adf11g.give any link and simple example of jasper report with adf11g.then please help me and send example.
Thanks&Regards
AnupHa, that's incredibly useful :-) Of course every response can be simplified to: http://lmgtfy.com/?q=let+me+google+that+for+you
CM. -
Jasper reports and bpel?
Is it possible (somehow) to generate pdf document using jasper reports (or any other framework for that matter) from bpel process?
Can anybody guide me to any tutorial or something that adresses this kind of "problem"?
I'm quite a newbie in Oracle BPEL and SOA. Maybe there is already some mechanism for doing this?
Thanks in advance :)I want to generate pdf file based on xml based result from bpel process and save that file to a file system.
Creating web service for that purpose is, in my opinion, quite elegant solution. I'll go with that for now since I know web service and jasper reports technologies. -
how can i plugin the jasper reports into IBM websphere 5
please helphow can i plugin the jasper reports into IBM websphere 5
please help -
Long running threads in DB2 DBSM/ job triggered by DDIC
Hi Basis Gurus,
I have ECC 6.0 , DB2 8.1.5 and SM 4.0.
Every day a job kicks up on the SM with user id DDIC and consumes a lot of CPU.This job fires up again at some irreular intervals 2-3 times in a day.And whenevrer it runs, takes a lot of CPU.
In sm50 it shows up as: CL_SQL_STATEMENT===CP
When you go into the details of it , it says
Loading DB library 'D:\usr\sap\SLM\DVEBMGS01\exe\dbdb2slib.dll' ..
Library 'D:\usr\sap\SLM\DVEBMGS01\exe\dbdb2slib.dll' loaded
After that it calls DB connect , and tries to monitor something.
and gives the following error...
C Monitor for DB2 system not started. Retrieving EBCDIC CCSID from SYSIBM.SYSSTRINGS.
C EBCDIC CCSID calculated from SYSIBM.SYSSTRINGS is 37 .
Then it tries to do something, and gets disconnected ..
C *** ERROR => DB2 Call 'SQLEndTran' Error: sqlcode = -900 : [IBM][CLI Driver] SQL0900N The application state is in error. A data
and again tries to connect....and monitor and the process continues...
=============================================
In omega Mon for DB2, i can see the following 3 sql statements being triggered over and over again..
SELECT COUNT(*) FROM "BC_SLD_INST" WHERE "APPL" = ? AND "NA_KEY" = ? AND
"INST_HASH" = ?
SELECT "INST_HANDLE","INSTNAME_BYTES" FROM "BC_SLD_INST" WHERE "APPL" =
? AND "NA_KEY" = ? AND "INST_HASH" = ?
INSERT INTO "BC_SLD_ASSINST" ("APPL","NA_KEY","ASSINST_HASH","ASSINST_HA
NDLE","INST_HASH","INST_HANDLE","ROLE_HASH","ROLE_HANDLE") VALUES (?,?,?
I am not sure as to :
1.) What this process is, what it is trying to do.
2.)How is it getting triggered, as it does not show up as scheduled task in sm36.Only time i can monitor it in sm37, is when it is running..
3.)And is it really necessary to run it everyday 2-3 times.if not how can i stop it from running.
Please advice.......
Regards....Hi Guys,
Did you found a solution for this issue?
I am making a DB Export on DB2 V8.1 FixPak14 and I am getting error SQLCODE -429 SQLSTATE 54028 on the same table "BC_SLD_INST".
Do you know what is the porpose of this table? Which kind of data does it record?
I have looked everywhere and there is any documentation about this table.
Thanks in advance.
Regards,
Jose Flores -
Jasper Reports and ADF: JRDataSource question
Hi all,
I am stuck with a problem creating a dynamic report with jasper. I want to use data from a VO or binding, not via a select in my report. Here is were i am at right now:
BindingContainer bc = this.getBindings();
DCIteratorBinding iterBinding = (DCIteratorBinding) bc.get("VO1Iterator");
RowSetIterator iter = iterBinding.getRowSetIterator();
Row[] matrix = new Row[iter.getRangeSize()];
int i=0;
while(iter.hasNext())
matrix[i] = iter.next();
//output to my msg facet:
fc.addMessage(null, new FacesMessage("Hour FROM: " + matrix.getAttribute("HourFrom") + " TO: " + matrix[i].getAttribute("HourTo") + " FACTOR: " + matrix[i].getAttribute("Factor")));
i++;
iter.closeRowSetIterator();
JRDataSource myDS = new JRBeanArrayDataSource(matrix);
In my report i am using $F{HourFrom} to access my values, but i keep getting:
Jasper Error:Error retrieving field value from bean : HourFrom
I'm using Jdev 10.1.3 with oracle 10g .
I understand that i'm not accessing the JRDataSource correctly. Hopefully someone can point me in the right direction.
Regards,
ArnaudHi all,
I am stuck with a problem creating a dynamic report with jasper. I want to use data from a VO or binding, not via a select in my report. Here is were i am at right now:
BindingContainer bc = this.getBindings();
DCIteratorBinding iterBinding = (DCIteratorBinding) bc.get("VO1Iterator");
RowSetIterator iter = iterBinding.getRowSetIterator();
Row[] matrix = new Row[iter.getRangeSize()];
int i=0;
while(iter.hasNext())
matrix[i] = iter.next();
//output to my msg facet:
fc.addMessage(null, new FacesMessage("Hour FROM: " + matrix.getAttribute("HourFrom") + " TO: " + matrix[i].getAttribute("HourTo") + " FACTOR: " + matrix[i].getAttribute("Factor")));
i++;
iter.closeRowSetIterator();
JRDataSource myDS = new JRBeanArrayDataSource(matrix);
In my report i am using $F{HourFrom} to access my values, but i keep getting:
Jasper Error:Error retrieving field value from bean : HourFrom
I'm using Jdev 10.1.3 with oracle 10g .
I understand that i'm not accessing the JRDataSource correctly. Hopefully someone can point me in the right direction.
Regards,
Arnaud -
ProgressIndicator and hourglass for long running processes
Hi all,
Iam using Oracle ADF 10g with EJBs.
I have a long running process for which I want to give the user an indication of its progress. The process is run upon clicking a submit button.
I have tested the use of the combination of progressIndicator + poll according to the example of Gerger consulting( http://gergerconsulting.blogspot.com/2007/04/adf-faces-progressindicator-example-for.html) but it did not work. The problem is that my long running process hangs the page and the progress bar does not work until the process has finished.
I have seen a similar post in this foum (Re: How to run long background jobs in ADF applications where a user complains that there is not an Oracle method for running asynchronous processes from Oracle ADF.
I've tested to isolate my asynchronous process with the progressIndicator + poll in a single ADF page. The process is being activated from an invokeAction from the executables of the pagedef file. But again the process hangs the page and the progressIndicator does not display at all.
So I have abandoned the idea of the progress indicator and Iam thinking of using an hourglass.
Is there an example or guidelines of how I can do it?Thanks John for your reply,
Iam still working on the progressIndicator. I have read the discussion thoroughly quite many times.
One thing I have not yet figured out from your discussion is how you manage to create the long-running-process thread within an action method within the managed bean and make the thread still be active, while the parent action method has finished.
Usually the managed beans attached to a .jspx pages has request scope. So a commandButton's action method (that will spawn the long running thread) will finish much earlier than the thread and it will kill the thread.
Thanks,
Dimitris -
Integrate jsf, jboss and jasper reports
Hi there!
I've a problem with integration jboss with jasper reports and jsf. Which jasper classes do I have to place on a server and what jboss files do I need to configure? How can I run jasper report from the jsf page? Any information on this subject will be very usefull.
Thanx for help in advance.
AdamUnless I have totally misunderstood your question, I think you have posted this question in the wrong forum. This forum is dedicated to developer questions about JSR 208 (Java Business Integration), a specification from the JCP that describes a service-oriented integration architecture. In this realm, integration means getting separate applications and messaging systems to interoperate, when they were never designed to do so. Your question sounds like you want to install particular technologies into jboss; this is a very different use of the term "integration".
-
Apex and Jasper Report Integration
Hi all,
If someone was interested to try another way for pdf generation from an apex application can try our Report Chunker based on Jasper Report and now avaiable to download on :
[http://sourceforge.net/projects/reportchunker/]
The latest release includes an APEX DEMO APPLICATION.
Any feedback will be welcome.
Edited by: NeOGeO on 23-set-2008 1.28A few points here.
Documentation:
You need to state what permissions are required.
eg create table, create sequence, create trigger, read/write directory.
You should also mention the authentication method you use.
Fortunately I could figure that out myself.
Now bearing in mind I am your typical target audience, I have no knowledge of Jasper reports, and very little knowledge of java and xml. So I'm now stuck as I don't know what to use for the xml layout or how to write my report.
At least provide an example xml layout, a example report and a link to where the reports cab be obtained.
If we need to have anything on the system before we start (eg jasper reports) then this should also be stated (including minimum required version)
Thats it. Unfortunately I can't go any further until I know more. -
Hi,
I have just begun to use Jasper Reports, and I am trying to load a sample JR xml file into a jsp in my web application.
report.jsp
<%@ page
import="java.io.*,
java.util.*,
java.sql.Connection,
javax.sql.DataSource,
javax.naming.InitialContext,
net.sf.jasperreports.engine.*,
net.sf.jasperreports.engine.design.JasperDesign,
net.sf.jasperreports.engine.xml.JRXmlLoader,
net.sf.jasperreports.engine.export.*"
%><%@page import="com.energyts.ebench.*"
%><%@page import="com.energyts.db.*"
%><%@page import="java.sql.ResultSet"
%>
<%
out.println("Attempting to create Jasper report");
try{
// read in xml design
InputStream input = new FileInputStream(new File("c:\\Tomcat 5.5\\webapps\\eBench\\report.xml"));
JasperDesign design = JRXmlLoader.load(input);
// compile design
JasperReport report = JasperCompileManager.compileReport(design);
// Database connection
Statement statement = EbenchUtils.getStatement(session);
JasperPrint print
= JasperFillManager.fillReport(report, new HashMap(), statement.getConnection());
JasperExportManager.exportReportToPdfFile(
print, "reports/simple_report.pdf");
}catch (JRException e){
out.println("failed");
e.printStackTrace();
%>I am using Tomcat 5.5 and JasperReports 2.04
I am getting this error:
HTTP Status 404 - reports\report.xml (The system cannot find the path specified)
type Status report
message reports\report.xml (The system cannot find the path specified)
description The requested resource (.\reports\report.xml (The system cannot find the path specified)) is not available.
Is the way I declare my path not declared correctly (the file is in the directory)? do the Tomcat settings need to be changed for this to work?
Any suggestions
Thanks
JI learned that my mistake was that I am not using the .jasper file. I have a new error now although I already put the needed file inside the classes folder. This is the error:
java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.fill.JRVerticalFiller
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:147)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:83)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:582)
at net.sf.jasperreports.engine.JasperRunManager.runReportToPdfStream(JasperRunManager.java:368)
at EmptyDSReportServlet.doGet(EmptyDSReportServlet.java:25)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:253)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:170)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:619) -
Help required: Cannot open pdf using Jasper Report in Weblogic workshop 9.2
This message was accepted by the [email protected] mailing list. Hi ,
I am new to jasper reports and I am using them in Java Page Flow in bea workshop 9.2
In one of my action methods
ServletOutputStream servletOutputStream = getResponse().getOutputStream();
InputStream reportStream = getServlet().getServletConfig().getServletContext().getResourceAsStream("/classic.jasper");
JasperRunManager.runReportToPdfStream(reportStream, servletOutputStream, new HashMap() ,connection);
getResponse().setContentType("application/pdf");
servletOutputStream.flush();
servletOutputStream.close();
connection.close();
When I invoke this action method from another page on click of submit , the pdf file opens fine for the first time( first submit) , and then if I click on submit again, it fails to open the pdf with the error message ,
There was an error opening this document . This file cannot be found.
Please help me resolve the issue, its urgent.
Thanx in advanceThanks for the reply David. The problem we're having is that when you are in Workshop, there is the option, under the "File" menu to "Refresh" (F5) You sometimes need to do this to refresh your workspace. I'm sorry, I'm not a developer, so I don't know the details behind what that actually does, other than it "refreshes the workspace" so we can pick up the changes made and checked into subversion.
Without performing this step, you don't always build from the latest and greatest code.
The problem we're facing is that it seems that you need to be in Workshop to perform this step. There is a scripted way to do the refresh, but it requires you to open Workshop and run the script. What we're trying to accomplish is a truly scripted solution. All the other steps in the build process can be performed without opening Workshop, but because we can't figure out a way to do this one piece, we cannot have an automated build process.
- Brian -
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
-
I have an iPhone 4 with iOS 5.1. I want to upgrade it to iOS 6. How can I do that when iOS 7 is available in the market. I fear upgrading to ios 7 will make my phone pretty slow. Gene I want to upgrade to iOS 6. Pls advise
-
Wrt54gp2 -- using 110v in country with 220v
I purchased a universal ac/dc adapter set to 12 volts, positive polarity, and a "load current" of 1000mA in order to run my wrt54gp2 in Israel. After i plug it in, the power light will flicker for a few seconds and then go out. Based upon my rather
-
HT5437 Is it necessary to use a computer to set up Apple TV?
I only use an iPad and would like to install Apple TV. Is it necessary to configure with A computer with a USB port?
-
Kern Protection Failure HELP!
Please help, I had a power failure while using my Mac (battery life was low, got error message saying I was on reserve power and before I could do anything my computer shut down), now I cannot open Safari at all, below is the error message I get when
-
Computer won't turn on all the way
When I turn the computer on, it goes to the gray screen with the apple icon with the "blinking" circle under it. Eventually it makes a loud sound, like an airplane is going to take off, but won't go any further. Any suggestions?