How to tune sql query

Hi,
How I can tune sql query? what are the steps for tuning.

First important step: Infomation gathering. One part can be learning to use the powerful search engine. E.g. search this forum for: "When your query takes too long".
Second step: Information processing. Check the data you found and apply it to your problem
Third step: Testing. Compare the result of the applied change before and after. Was there any performance gain as expected?

Similar Messages

  • How do tune sql query? Can somebody help me in this? Atleast prescribe book

    how do tune sql query? Can somebody help me in this? Atleast prescribe a reference book.
    I am not able understand How to analyze tkproof output.

    Check out asktom.oracle.com
    Lot's of threads on interpreting tkprof output - no simple easy solution here.
    You need to understand what is happening and THINK. Then you can be a good engineer.
    As for good books...
    Tom Kyte's books are really, really good.
    http://www.amazon.com/Effective-Oracle-Design-Osborne-ORACLE/dp/0072230657/ref=sr_1_3?ie=UTF8&s=books&qid=1266783471&sr=8-3
    http://www.amazon.com/Expert-Oracle-Database-Architecture-Programming/dp/1590595300/ref=sr_1_1?ie=UTF8&s=books&qid=1266783471&sr=8-1
    Good luck!

  • How to tune the query...?

    Hi all,
    I am having a table with millions of records and the query is taking hours
    time. How to tune the query apart from doing the following things.
    1. Creating or Deleting indexes.
    2. Using Bind variables.
    3. Using Hints.
    4. Updating the Statitics regurarly.
    Actually, i have asked this question in interview how to tune the query.
    I told him the above 4 things. Then he told, these are not working, then
    how you will tune this query.
    Thanks in advance,
    Pal

    user546710 wrote:
    Actually, i have asked this question in interview how to tune the query.
    I told him the above 4 things. Then he told, these are not working, then
    how you will tune this query.It actually depends on the scenario/problem given.
    You may want to read this first.
    When your query takes too long ...
    When your query takes too long ...
    HOW TO: Post a SQL statement tuning request - template posting
    HOW TO: Post a SQL statement tuning request - template posting

  • How to tune a query

    how to tune a query . what are the procedures?

    Following are the steps
    1. Learn about RDBMS.
    2. Learn how Oracle works. Oracle Architecture and other stuff.
    3. Learn how SQL works (because parsing makes difference)
    4. Learn about the tools provided by oracle for tuning (explain plan, sqltrace, tkprof etc.)
    One you have all these knowledge. You are all set for tuning.
    Thanks,
    Karthick.

  • How to use sql query in java ?

    i don't know how to use sql query in java code.
    who can give me some advice?
    thanks

    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/

  • How to Use SQL Query having IN Clause With DB Adapter

    Hi,
    I am using 11.1.1.5 want to find out how to Use SQL Query having IN Clause With DB Adapter. I want to pass the IN values dynamically. Any ideas.
    Thanks

    invoke a stored procedure, it's safer than trying to put together an arbitrary SQL statement in the JCA adapter

  • How to execute SQL Query in Code behind Using infopath 2010?

    Hi,
    I've repeatable on infopath form, and want bind it throuth code behind from SQL table. My question is that how to execute SQL Query in code behind from infopath as well as how would get Query result to bind repeatable control?
    Thanks In Advance
    Shoeb Ahmad

    Hello,
    You first need to add new SQL DB connection then you need execute connection from code behind.
    See below link to create new connection
    http://office.microsoft.com/en-in/infopath-help/add-a-data-connection-to-a-microsoft-sql-server-database-HP010092823.aspx:
    http://www.bizsupportonline.net/infopath2010/connect-infopath-2010-sql-server-2008-table.htm
    Then use below code to execute this connection:
    AdoQueryConnection conn = (AdoQueryConnection)(this.DataConnections["Data connection name"]);
    string origCommand = Select * from tablename;
    conn.Command = origCommand;
    conn.Execute();
    Finally bind your table:
    http://www.bizsupportonline.net/infopath2007/4-way-programmatically-add-row-repeating-table.htm
    http://stevemannspath.blogspot.in/2010/09/infopath-20072010-populate-repeating.html
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to write sql query with many parameter in ireport

    hai,
    i'm a new user in ireport.how to write sql query with many parameters in ireport's report query?i already know to create a parameter like(select * from payment where entity=$P{entity}.
    but i don't know to create query if more than 1 parameter.i also have parameter such as
    $P{entity},$P{id},$P{ic}.please help me for this.
    thanks

    You are in the wrong place. The ireport support forum may be found here
    http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&func=showcat&catid=9

  • How to tune this query for the improve performance ?

    Hi All,
    How to tune this query for the improve performance ?
    select a.claim_number,a.pay_cd,a.claim_occurrence_number,
    case
    when sum(case
    when a.payment_status_cd ='0'
    then a.payment_est_amt
    else 0
    end
    )=0
    then 0
    else (sum(case
    when a.payment_status_cd='0'and a.payment_est_amt > 0
    then a.payment_est_amt
    else 0
    end)
    - sum(case
    when a.payment_status_cd<>'0'
    then a.payment_amt
    else 0
    end))
    end as estimate
    from ins_claim_payment a
    where a.as_of_date between '31-jan-03' and '30-aug-06'
    and ( a.data_source = '25' or (a.data_source between '27' and '29'))
    and substr(a.pay_cd,1,1) IN ('2','3','4','8','9')
    group by a.claim_number, a.pay_cd, a.claim_occurrence_number
    Thank you,
    Mcka

    Mcka
    As well as EXPLAIN PLAN, let us know what proportion of rows are visited by this query. It may be that it is not using a full table scan when it should (or vice versa).
    And of course we'd need to know what indexes are available, and how selective they are for the predicated you have in this query ...
    Regards Nigel

  • How to create sql query for item master with operator LIKE with variables?

    hi all,
    How to create sql query for item master with
    operator LIKE(Contains,Start With,End With) with variables using query generator in SAP B1 ?
    Jeyakanthan

    Hi Jeyakanthan,
    here is an example (put the like statement into the where field)
    SELECT T0.CardCode, T0.CardName FROM OITM T0 WHERE T0.CardName Like '%%test%%'
    The %% sign is a wildcard. If you need start with write 'test%%' and otherwise ends with '%%test'. For contains you need '%%test%%'. You also could combinate this statements like 'test%%abc%%'. This means starts with test and contains abc.
    Regards Steffen

  • How to write sql query for counting pairs from below table??

    Below is my SQL table structure.
    user_id | Name | join_side | left_leg | right_leg | Parent_id
    100001 Tinku Left 100002 100003 0
    100002 Harish Left 100004 100005 100001
    100003 Gorav Right 100006 100007 100001
    100004 Prince Left 100008 NULL 100002
    100005 Ajay Right NULL NULL 100002
    100006 Simran Left NULL NULL 100003
    100007 Raman Right NULL NULL 100003
    100008 Vijay Left NULL NULL 100004
    It is a binary table structure.. Every user has to add two per id under him, one is left_leg and second is right_leg... Parent_id is under which user current user is added.. Hope you will be understand..
    I have to write sql query for counting pairs under id "100001". i know there will be important role of parent_id for counting pairs. * what is pair( suppose if any user contains  both left_leg and right_leg id, then it is called pair.)
    I know there are three pairs under id "100001" :-
    1.  100002 and 100003
    2.  100004 and 100005
    3.  100006 and 100007
        100008 will not be counted as pair because it does not have right leg..
     But i dont know how to write sql query for this... Any help will be appreciated... This is my college project... And tommorow is the last date of submission.... Hope anyone will help me...
    Suppose i have to count pair for id '100002'. Then there is only one pair under id '100002'. i.e 100004 and 100005

    Sounds like this to me
    DECLARE @ID int
    SET @ID = 100001--your passed value
    SELECT left_leg,right_leg
    FROM table
    WHERE (user_id = @ID
    OR parent_id = @ID)
    AND left_leg IS NOT NULL
    AND right_leg IS NOT NULL
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to transport SQL Query from SQVI Tcode?

    Dear Friends,
    Can any one tell me how to transport SQL Query from <b>SQVI</b> Tcode.
    Full Points will be rewarded.
    Thanks & Reagrds
    Ravi

    go to sqvi tool .....
    select u r query name ......in the menubar ....quickview....> additianal functions.......>generate program
    after doing generate program ....go to again same menu path as i have mentioned above [quickview....> additianal functions.......>display report name it will give the report name of the select query ..........copy the report name and give it abap editor[se38] u will get u r query program......with all authority checks.....
    in start of selection event of u r program u will find u r select query.
    reward points if helpful

  • How to write sql query for below mentioned eaxmple.

    Hi,
    I have requirement.
    There are number of rows and I need the result through query as follows.Please help me to proved sql query for below mentioned requirement.
    example: table TEST.
    COLA COLB COLC COLD COLE COLF MANAGER 5 NULL NULL 3 NULL
    SR.MANAGER 6 3 NULL NULL NULL
    VP 5 5 4 5 5
    I have to write the sql query if COLA IS MANAGER THEN CONSIDER MANGER RECORD,AND IF ANY COLUMN FILED IS NULL FOR MANGER THEN CONSIDER COLA IS SR.MANGER, AND IF ANY COLUMN FILED IS NULL FOR SR,MANGER THEN CONSIDER VP records.
    I need output as below.
    COLB COLC COLD COLE COLF
    5(manager) 3(sr.manger) 4(vp) 3(manger) 3(vp)
    Please provide the for above mentioned output.
    Thanks

    Duplicate thread. please view the answer posted in your first thread.
    how to write sql query.
    And, please don't post any duplicate thread.
    Regards.
    Satyaki De.

  • How will write SQL query to fetch data from  each Sub-partition..

    Hi All,
    Anyone does have any idea about How to write SQL query to fetch data from Sub-partition.
    Actually i have one table having composite paritition(Range+list)
    Now if i want to fetch data from main partition(Range) the query will be
    SELECT * FROM emp PARTITION(q1_2005);
    Now i want to fetch data at sub-partition level(List) .But i am not able to get any SQL query for that.
    Pls help me to sort out.
    Thanks in Advance.
    Anwar

    SELECT * FROM emp SUBPARTITION(sp1);

  • How does a SQL query work

    Hi all...
    How does a SQL query basically work? Is there any pseudocode for it?
    How ro calculate the cost of query?
    Can we find out what would be the execution time for a query before it is executed?
    Thanks in advance.
    Ameya

    Hi Avinash,
    Look closely mate!!!
    You have done set autotrace on... meaning you are executing the statement while i am doing set autotrace traceonly explain meaning the statement would never get executed actually.. oracle optimizer will just select the desired plan and will show the output..
    You can even ESTIMATE how many rows the qeury will return before even executing the statement using the same above tech.. i will show you how:
    The explain plan gives this -- as long as you are using the CBO (cost based
    optimizer). Doesn't matter if you have 1 or 50 tables. The last part of the
    plan is the estimate output.
    consider:
    SQL> set autotrace traceonly explain
    SQL> select e1.*, e2.* from emp e1, emp e2;
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=15 Card=196 Bytes=12544)
    1 0 MERGE JOIN (CARTESIAN) (Cost=15 Card=196 Bytes=12544)
    2 1 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=448)
    3 1 SORT (JOIN) (Cost=14 Card=14 Bytes=448)
    4 3 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=448)
    196 = 14 * 14 -- thats right....
    SQL> select emp.ename, mgr.ename from
    2 emp, emp mgr
    3 where emp.mgr = mgr.empno;
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=5 Card=13 Bytes=208)
    1 0 MERGE JOIN (Cost=5 Card=13 Bytes=208)
    2 1 SORT (JOIN) (Cost=3 Card=14 Bytes=112)
    3 2 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=112)
    4 1 SORT (JOIN) (Cost=3 Card=14 Bytes=112)
    5 4 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=112)
    Here is estimated that about 13 rows would be returned...
    SQL> select count(*) from emp;
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1)
    1 0 SORT (AGGREGATE)
    2 1 INDEX (FULL SCAN) OF 'EMP_PK' (UNIQUE) (Cost=1 Card=14)
    one row...
    SQL> select ename, dname
    2 from emp, dept where emp.deptno = dept.deptno;
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=5 Card=14 Bytes=252)
    1 0 NESTED LOOPS (Cost=5 Card=14 Bytes=252)
    2 1 TABLE ACCESS (FULL) OF 'DEPT' (Cost=1 Card=4 Bytes=44)
    3 1 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=14 Bytes=98)
    14 rows...
    1 select ename, dname
    2* from emp, dept where emp.deptno = dept.deptno and emp.ename like '%A%'
    SQL> /
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=18)
    1 0 NESTED LOOPS (Cost=2 Card=1 Bytes=18)
    2 1 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=1 Bytes=7)
    3 1 TABLE ACCESS (BY INDEX ROWID) OF 'DEPT' (Cost=1 Card=4 Bytes=44)
    4 3 INDEX (RANGE SCAN) OF 'DEPT_IDX' (NON-UNIQUE)
    1 rows.....
    and this was all done without executing the query. See EXPLAIN plan and the
    PLAN_TABLE.

Maybe you are looking for

  • Multiple Quizzes in One Project

    I'm developing a project that teaches 4 different standards, then has a overall assessment quiz at the end of the course. The problem I'm running into is that the "pre" quiz after each of the four standards cannot be independently "scored" without ad

  • Call PDF Javascript Function from External HTML Document

    Greetings, Forgive me if this information has been posted previously - I've searched quite a bit and haven't quite found anything specific or similar. We have LiveCycle Designed forms, and are including the Form in an IFRAME within an HTML page.  Fro

  • Array of Matches

    Hello all. I'm trying to figure out the best way to get the following information: Column A is filled with items, say Gold, Silver, Copper, Brass, Aluminum Column C and to the right has references to items in Column A. Each row is different and conta

  • ABAP HR - Populating fields on Infotype screen

    Hi I have the foll. requirement. In Infotype 8 when an employee enters the ANSAL field ie. the value for Annual Salary all the wage types should get populated on their own in the wage type table control in the screen based on the following calulation

  • How do I have pages of my docs automatically numbered consecutively

    I have a questions re Pages. How do I have the number of pages of my docs automatically numbered consecutively? <Email Edited by Host>