How to tune a oracle sql query to make it run faster ...
Hi Guys,
I am very new to this tuning of sql queries. It is taking a lot of time to run a query and give the output. I have a tool called TOAD[ Tool for oracle application development ] and i ran a query in that tool. Its showing that the query is taking 7sec to get its output. I donno the exact procedure what to follow in order to tune that query. What are these actually like : explain plan, sqltrace, tkprof and how to use these to tune the query. I want my query to run faster like in msec.
Help Appreciated.
Thanks
http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96533/toc.htm
http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96533/sqltrace.htm#1018
Similar Messages
-
My Mac Mini, which I bought last December 2011, seems to have slowed a bit. Is there something I can do to tune it up to get it to run faster?
Hi Annie,
Hello, see how many of these you can answer...
See if the Disk is issuing any S.M.A.R.T errors in Disk Utility...
http://support.apple.com/kb/PH7029
Open Activity Monitor in Applications>Utilities, select All Processes & sort on CPU%, any indications there?
How much RAM & free space do you have also, click on the Memory & Disk Usage Tabs.
Open Console in Utilities & see if there are any clues or repeating messages when this happens.
In the Memory tab, are there a lot of Pageouts? -
How to use connection pool of datasource to make applications run faster?
Hi, erveryone
I prepare to implement a servlet that access database and do sync with client.
When I access database, I would like to configure a datasource in weblogic and use connection pool.
In order to make servlet application run significantly faster, my servet how to use connection poo is much moreresonable?
For example, my servlet has many times database access. Is it true that geting and close a connection whenever
one time database access finished?
If from the servlet begins, the db connection is hold till servlet finalize. Will the solution affect the servlet performance? Is there any official document to introduce connection pool program? I search some documents.
<The Java EE 6Tutorial> introduce some simple intruduction about connection pool.1. Use WebLogic Servers Data Source for Database Connections.
2. Open and close the connections where you need it. Dont open it in begin and close in finalise. That is bad practice.
3. Even when you invoke Connection.close () webLogic will not close the connection. it will commit the transaction and return it back to the pool rather than physically closing the DB connection.
4. You can tune data source for minimum, maximum and increments of connections that you need based on your application requirement. -
How to tune the following sql statements which has two unions in oracle 10g
It takes a long time to run the following sql statement in 10g. Each select brings back about 4 million rows and there will be about 12 million rows. When I run each select statements seprately in sqlplus I can see the data immedaitely but when I run it as whole with two unions in the select it just takes very very long time? I want to know how to make this run faster? Can we add hints? or is it because of any table space? Any help is appreciated.
select
D.EMPLID
,D.COMPANY
,'CY'
,D.CALENDAR_YEAR
,D.QTRCD
,D.ERNCD
,D.MONTHCD
,D.MONTHCD
,D.GRS_MTD
,D.GRS_QTD
,D.GRS_YTD
,D.HRS_MTD
,D.HRS_QTD
,D.HRS_YTD
from PS_EARNINGS_BAL D
where D.SPCL_BALANCE = 'N'
union
select
D.EMPLID
,D.COMPANY
,'FY'
,(case when D.MONTHCD > '06' then D.CALENDAR_YEAR + 1 else D.CALENDAR_YEAR end)
,ltrim(to_char(to_number(D.QTRCD) + decode(sign(3-to_number(D.QTRCD)),1,2,-2),'9'))
,D.ERNCD
,ltrim(to_char(to_number(D.MONTHCD) + decode(sign(7-to_number(D.MONTHCD)),1,6,-6),'09'))
,D.MONTHCD
,D.GRS_MTD
,D.GRS_QTD
,(select sum(F.GRS_MTD) from PS_EARNINGS_BAL F where
F.EMPLID = D.EMPLID and
F.COMPANY = D.COMPANY and
F.ERNCD = D.ERNCD and
F.SPCL_BALANCE = D.SPCL_BALANCE and
(case when F.MONTHCD < '07' then F.CALENDAR_YEAR -1 else F.CALENDAR_YEAR end)
= (case when D.MONTHCD < '07' then D.CALENDAR_YEAR -1 else D.CALENDAR_YEAR end)
and to_number(F.MONTHCD) + decode(sign(7-to_number(F.MONTHCD)),1,6,-6)
<= to_number(D.MONTHCD) + decode(sign(7-to_number(D.MONTHCD)),1,6,-6))
,D.HRS_MTD
,D.HRS_QTD
,(select sum(F.HRS_MTD) from PS_EARNINGS_BAL F where
F.EMPLID = D.EMPLID and
F.COMPANY = D.COMPANY and
F.ERNCD = D.ERNCD and
F.SPCL_BALANCE = D.SPCL_BALANCE and
(case when F.MONTHCD < '07' then F.CALENDAR_YEAR -1 else F.CALENDAR_YEAR end)
= (case when D.MONTHCD < '07' then D.CALENDAR_YEAR -1 else D.CALENDAR_YEAR end)
and to_number(F.MONTHCD) + decode(sign(7-to_number(F.MONTHCD)),1,6,-6)
<= to_number(D.MONTHCD) + decode(sign(7-to_number(D.MONTHCD)),1,6,-6))
from PS_EARNINGS_BAL D
where D.SPCL_BALANCE = 'N'
union
select
D.EMPLID
,D.COMPANY
,'FF'
,(case when D.MONTHCD > '09' then D.CALENDAR_YEAR + 1 else D.CALENDAR_YEAR end)
,ltrim(to_char(to_number(D.QTRCD)+decode(sign(4-to_number(D.QTRCD)),1,1,-3),'9'))
,D.ERNCD
,ltrim(to_char(to_number(D.MONTHCD)+decode(sign(10-to_number(D.MONTHCD)),1,3,-9),'09'))
,D.MONTHCD
,D.GRS_MTD
,D.GRS_QTD
,(select sum(F.GRS_MTD) from PS_EARNINGS_BAL F where
F.EMPLID = D.EMPLID and
F.COMPANY = D.COMPANY and
F.ERNCD = D.ERNCD and
F.SPCL_BALANCE = D.SPCL_BALANCE and
(case when F.MONTHCD < '10' then F.CALENDAR_YEAR -1 else F.CALENDAR_YEAR end)
= (case when D.MONTHCD < '10' then D.CALENDAR_YEAR -1 else D.CALENDAR_YEAR end)
and to_number(F.MONTHCD)+decode(sign(4-to_number(F.MONTHCD)),1,9,-3)
<= to_number(D.MONTHCD)+decode(sign(4-to_number(D.MONTHCD)),1,9,-3))
,D.HRS_MTD
,D.HRS_QTD
,(select sum(F.HRS_MTD) from PS_EARNINGS_BAL F where
F.EMPLID = D.EMPLID and
F.COMPANY = D.COMPANY and
F.ERNCD = D.ERNCD and
F.SPCL_BALANCE = D.SPCL_BALANCE and
(case when F.MONTHCD < '10' then F.CALENDAR_YEAR -1 else F.CALENDAR_YEAR end)
= (case when D.MONTHCD < '10' then D.CALENDAR_YEAR -1 else D.CALENDAR_YEAR end)
and to_number(F.MONTHCD)+decode(sign(4-to_number(F.MONTHCD)),1,9,-3)
<= to_number(D.MONTHCD)+decode(sign(4-to_number(D.MONTHCD)),1,9,-3))
from PS_EARNINGS_BAL D
where D.SPCL_BALANCE = 'N'
Edited by: user5846372 on Mar 11, 2009 8:55 AMHi,
What i observed is that your table name and where clause is same in all the thress SELECTs whereas columns having some manipulations that is not going to be unique. I guess you can easily replace UNION with UNION ALL.
from PS_EARNINGS_BAL D
where D.SPCL_BALANCE = 'N'Note: I am not aware of your data and business requirement. Please test the result before removing. It is just a suggetion
Cheers,
Avinash -
Re: How to converting from PL/SQL query to T-SQL query
How to converting from PL/SQL query to T-SQL query... Its Urgent
Download the
SQL Server Migration Assistant for Oracle. It will convert whole Oracle databases, or single queries or PL/SQL stored procedures.
With caution that If your database is using Collation which is case sensitive SSMA will not work.SSMA doesnt guarantees 100% for conversion of Queries/stored proc /database if it fails to do so for some queries you will have to do it manually.
But you can try
Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers -
How to compare result from sql query with data writen in html input tag?
how to compare result
from sql query with data
writen in html input tag?
I need to compare
user and password in html form
with all user and password in database
how to do this?
or put the resulr from sql query
in array
please help me?Hi dejani
first get the user name and password enter by the user
using
String sUsername=request.getParameter("name of the textfield");
String sPassword=request.getParameter("name of the textfield");
after executeQuery() statement
int exist=0;
while(rs.next())
String sUserId= rs.getString("username");
String sPass_wd= rs.getString("password");
if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
exist=1;
if(exist==1)
out.println("user exist");
else
out.println("not exist"); -
Is there a program in mac to make my macbook pro run faster? On my PC I would defrag it but on my mac, I don't know how to do it. Can someone suggest the best way to tune up my macbook pro to delete unnecessary files and make it run faster?
joyvdk wrote:
Is there a program in mac to make my macbook pro run faster? On my PC I would defrag it but on my mac, I don't know how to do it. Can someone suggest the best way to tune up my macbook pro to delete unnecessary files and make it run faster?
There are no degragmenters bundled with Mac OS X, however there is iDefrag a third party defragmenter utility. That said, I highly doubt that defragmentation will bump your computer speed. According to this Apple KB article, Mac OS X is very capable at preventing fragmentation and even the way now hard drives are being manufactured circumvent the possibility of fragmentation.
Hope this helps. -
How can I safely clean my Mac of old folders etc to make it run faster?er
How can I safely clean my Mac of old folders, etc to make it run faster?
The only real and safe way to do this is to do it manually looking through each folder individually.
Many third party utilities claim to clean out a hard drive of various detritus, but some times will delete data that it shouldn't and delete any other important data that it shouldn't have.
The only "safe" way to accomplish what you need to accomplish is to do this manually.
Stay away from the OS X system folder!!!!!
Hard drive getting full?
You can download an app called OmniDiskSweeper.
This app will allow you to see where files maybe able to be delete are located.
If your Mac is running a fairly recent version of OS X, here are some general guidelines.
Follow some of my tips for cleaning out, deleting and archiving data from your Mac's internal hard drive.
Have you emptied your iMac's Trash icon in the Dock?
If you use iPhoto, iPhoto has its own trash that needs to be emptied, also.
If you have images stored in iPhoto,,the only way to weed out duplicates is to do this manually.
When you delete them, they go to iPhoto's Trash. Remember to empty this when you are done.
If you store images in other locations other than iPhoto, then you will have to weed through these to determine what are duplicates and what isn't
If you use Apple Mail app, Apple Mail also has its own trash area that needs to be emptied, too!
Other things you can do to gain space.
Delete any old or no longer needed emails and/or archive to disc, flash drives or external hard drive, older emails you want to save.
Look through your Documents folder and delete any type of old useless type files like "Read Me" type files.
Again, archive to disc, flash drives, ext. hard drives or delete any old documents you no longer use or immediately need.
Look in your Applications folder, if you have applications you haven't used in a long time, if the app doesn't have a dedicated uninstaller, then you can simply drag it into the OS X Trash icon. IF the application has an uninstaller app, then use it to completely delete the app from your Mac.
Download an app called OnyX for your version of OS X.
When you install and launch it, let it do its initial automatic tests, then go to the cleaning and maintenance tabs and run the maintenance tabs that let OnyX clean out all web browser cache files, web browser histories, system cache files, delete old error log files.
Typically, iTunes and iPhoto libraries are the biggest users of HD space.
move these files/data off of your internal drive to the external hard drive and deleted off of the internal hard drive.
If you have any other large folders of personal data or projects, these should be archived or moved, also, to the optical discs, flash drives or external hard drive and then either archived to disc and/or deleted off your internal hard drive.
Good Luck! -
How to clean up my mac and make it run faster
I want to know how to clean up my mac and make it run faster.. seems very bogged down lately and doesnt do stuff very fast anymore..
macworld.com/mac-troubleshooting-what-to-do-when-your -computer-is-too-slow.
Basically... Make sure you have enough Free Hard Drive space for your Mac to Perform as expected...
This is what Apple has to say.
http://support.apple.com/kb/PH10798
More Info Here...
ds store > Why is my computer slow?
Thomas A Reed > Mac Performance Guide
To keep your Mac Happy... See Here...
http://support.apple.com/kb/HT1147
http://www.thexlab.com/faqs/maintainingmacosx.html
Mac OS X: About background maintenance tasks -
Hi, I have a iMac Tiger running slowly, how can I make it run faster?
Hi, I have a iMac Tiger 10.4.11 running slowly, how can I make it run faster?
Look at what is happenning with your Mac when you run Activity Monitor.
Macintosh-HD -> Applications -> Utilities -> Activity Monitor
Click on the CPU tab on the lower half of the window to see how much time you are using.
Click on System Memory to get statistics on memory usage. You should have some free memory.
When you have lots of page outs more memory will be helpful. My entry for entry for Page ins/outs is:
Page ins/outs: 29163/0
Notice I have 0 pageouts which says that I am not using my harddrive for extra memory space. Thus, I have enough memory.
Activity Monitor has a neat feature where it can display a dynamic dock icon. In Activity Monitor View > Dock icon > Show cpu history.
"Reading system memory usage in Activity Monitor :"
http://docs.info.apple.com/article.html?artnum=107918
<a href="http://developer.apple.com/documentation/Performance/Conceptual/ManagingMemory/A rticles/AboutMemory.html#//apple_ref/doc/uid/20001880"
>Managing Memory</a>
See Kappy
http://discussions.apple.com/message.jspa?messageID=8025223#8025223
Problems from insufficient RAM and free hard disk space
http://thexlab.com/faqs/lackofram.html -
How to set fetchsize of sql Query when using Database Adapter.
Hi All,
I am using DatabaseAdapter to connect to database and retriving huge amount of data.For improvement in the performance I want to set the "fetchsize" of sql query. I know fetchsize can be preset in Java using Jdbc 2.0 API.Please let me know how to set this value in BPEL when using DBAdapter?
Thanks
ChandraI talked to the developer of the db adapter - and he told me this feature will be available in BPEL PM 10.1.3 (which is supposed to be production later this year, and a public beta soon). If this is an emergency I would recommend going throug Oracle support and have them file an enhancement for 10.1.2.0.2
hth clemens -
Oracle Sql Query issue Running on Different DB Version
Hello All,
I have come into situation where we are pruning sql queries on different DB version of Oracle and have performance issue. Let me tell you in brief and i really appreciate for your prompt response as its very imperative stuff.
I have a query which is running on a DB of version 7.3.4 and it takes around 30 mins where as the same query when run on 8i it takes 15sec., its a huge difference. I have run the statistics to analyze on 7.3 and its comparatively very high. Question here is, the sql query trys to select data from same schema table and 2 tables from another DB using DB link and 2 other tables from another DB using DB link.So,how can we optimize this stuff and achieve this run as same time as 8i DB in 7.3. Hope i am clear about my question, Eagerly waiting for your replies.
Thanks in Advance.
Message was edited by:
Ram8Difficult to be sure without any more detailed information, but I suspect that O7 is in effect copying the remote tables to local temp space, then joining; 8i is factoring out a better query to send to the remote DBs, which does as much work as possible on the remote DB before shipping remaining rows back to local.
You should be able to use EXPLAIN PLAN to identify what SQL is being shipped to the remote DB, If you can't (and it's been quite a while since I tried DB links or O7) then get the remote DBs to yourself, and set SQL_TRACE on for the remote instances. Execute the query and then examine the remote trace files, And don't forget to turn off the tracing when you're done.
Of course it could just be that the CBO got better,,,
HTH - if not, post your query and plans for the local db, and the remote queries.
Regards Nigel -
Oracle SQL Query from EXCEL 2007 with prompt
Hello,
I have many excel reports where I am pulling information from our Oracle 9 db through Excel using the following method:
http://blog.mclaughlinsoftware.com/microsoft-excel/how-to-query-oracle-from-excel-2007/
http://blog.mclaughlinsoftware.com/2009/11/30/sql-query-in-excel-2007/
However, I am having trouble when I try the following query due to the prompt:
SELECT
IM.ITEM_GROUP,
IM.ITEM,
IM.DESCRIPTION
FROM
LAWSON.ITEMMAST IM
WHERE
IM.ITEM = '&ITEM';
Does any one know how I can connect a prompt to an excel cell and then pass the query on to Oracle, or have a PL SQL prompt work from Excel?
Thanks,
BenThe 'prompt' as you call it is a sqlplus feature, so does not belong to the SQL language
You would need to write a stored procedure returning a resultset.
create or replace procedure foo(rc in out sys_refcursor, p_item) as
begin
open rc for
'SELECT
IM.ITEM_GROUP,
IM.ITEM,
IM.DESCRIPTION
FROM
LAWSON.ITEMMAST IM
WHERE
IM.ITEM = '||p_item;
end;
and call that using ODBC or asp.net
Obviously this is profusely documented.
Sybrand Bakker
Senior Oracle DBA -
How i can execute the sql query in java code
I already have sql query in jave plateform i need to execute this code how i can do that. i have unix env and with oracle database. should i just run this query in my sqlplus. this file has extention .java. thanks
you can create a project in JDeveloper add the java file to it, add the Oracle JDBC library to the project properties and then hit the run button.
-
How to backup database using sql query?
Hello,i'm student, i'm researching oracle database,i want to backup database that using sql query (like backup query in SQL SERVER) ,how to do that ??
Thank!No, database backups cannot be done from within the database.
Commands for backups are outside of the database.
See the "2 Day DBA Guide" http://download.oracle.com/docs/cd/E11882_01/server.112/e10897/toc.htm
and the "Backup and Recovery Users's (actually Adminsitrator's) Guide : http://download.oracle.com/docs/cd/E11882_01/backup.112/e10642/toc.htm
Hemant K Chitale
Maybe you are looking for
-
Query to determine which customer invoices are subjected to apply payment
Hi you all experts. I have two tables (OINV and a custom made named DEPOSITS) the first one as you know keeps the record of all customer invoices. The second one keeps record of last payment from customers (this table is filled before applying paymen
-
Music's appearing on my iPhone that I didn't put there -- and DON'T EVEN OWN.
I've got a bizarre problem that keeps getting stranger, and have no clue how to fix it. General setup: Computer: OS 10.6.8, iTunes version 11.1.5 iPhone: 7.1 iTunes on the computer: set to manually update my music library Music settings on phone: Sho
-
My camera on my new iPad is fuzzy what do i do to fix it?
MyMy camera on my new iPad is fuzzy what do i do to fix it?
-
How can I compile all functions, procedures and packages with a script?
I need to compile all functions, procedures and packages of 5 schemas (users) with a script. How can I do it? Thanks!
-
Need an idea about the opportunity
Hi! I have a vast experience in Sales and Marketing over 20 years consisting of Logistics field from 2007. May age is now around 41. need to know if its advisable to take up SAP SD module to peruse my future career through it.