Query Tuning-very Urgent

Beloq query is taking time to execute and cost is 934.
The db in which it is run has lesser volume of data compared to that of prod.
There is a full table scan on psd
inspite of a pk present on table psd columns (psd_id,psd_serial_no)
also a pk present on table ltc_iss_rec columns(ltc_iss_rec_id,psd_serial_num)
Pl help to optimize the query.
select a.psd_id,a.psd_serial_no,a.sys_id,a.cosmos_ref_no,a.src_sys_asgn_ref_no,
a.bank_id,b.lc_expr_dt
from psd a,ltc_iss_rec b
where ((b.ltc_iss_rec_id >= 'T200203140731163') and (b.ltc_iss_rec_id <= 'T200606224485207'))
and a.psd_id = b.ltc_iss_rec_id
and a.psd_serial_no = b.psd_serial_num
and a.psd_typ_cod = 'ISS'
and b.lc_expr_dt <= '13-Mar-07'
and a.psd_serial_no =
select nvl(max(link_psd_ser_no),'000') from psd_link c,psd_lcs d
where c.psd_id = d.psd_id
and c.psd_serial_no = d.psd_serial_num
and c.link_psd_id = a.psd_id
and c.link_psd_id >= 'T200203140731163' and c.link_psd_id <= 'T200606224485207'
and d.update_serial_num = (
select max(update_serial_num) from psd_lcs e
where e.psd_id = d.psd_id
order by a.psd_id
Explain plan for the query :
Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
SELECT STATEMENT Optimizer Mode=CHOOSE          1           934                     
SORT ORDER BY          1      96      900                     
FILTER                                        
NESTED LOOPS          1      96      898                     
PARTITION RANGE ALL                                   1     2
TABLE ACCESS FULL     IWH_OWNER.PSD     61      4 K     837                1     2
TABLE ACCESS BY GLOBAL INDEX ROWID     IWH_OWNER.LTC_ISS_REC     1      26      1                1     1
INDEX UNIQUE SCAN     IWH_OWNER.XPKLTC_ISS_REC     1                               
SORT AGGREGATE          1      112                          
HASH JOIN          1      112      34                     
TABLE ACCESS BY GLOBAL INDEX ROWID     IWH_OWNER.PSD_LCS     1      40      2                ROWID     ROW L
NESTED LOOPS          1      82      5                     
TABLE ACCESS BY GLOBAL INDEX ROWID     IWH_OWNER.PSD_LINK     1      42      3                ROWID     ROW L
INDEX RANGE SCAN     IWH_OWNER.XIE1PSD_LINK     1           2                     
INDEX RANGE SCAN     IWH_OWNER.XIE1PSD_LCS     2           1                     
VIEW     SYS.VW_SQ_1     134 K     3 M     26                     
SORT GROUP BY          134 K     4 M     26                     
INDEX FULL SCAN     IWH_OWNER.XIE1PSD_LCS     217 K     7 M     26

Read this link.
When your query takes too long ...
If you really need help from any of the forum members then you should avoid using the word "urgent" and give more useful information (check the above link what I meant by useful information) rather than simply saying it's very urgent please help me. It's of no use to anybody.
Regards
Raj

Similar Messages

  • Query Issue(Very Urgent)

    Hi,
         I have issue with select statement to pull the records from two tables. Here I have two tables one is with Billing Document Items and Service Order Operations.
    I have service order as unique field in both tables, When I execute select statement with one service order I got 10 records like
    S Ord Oper                           Billing Document Items
    Oper    Repair Code                 Item    Oper    Repair Code
    10        AD01                           1         10        AD01
    20        AD01                           2         20        AD01  
    30        OT01                           3         10        AD01
    40        RE01                           4         20        AD01
    50        RP01                           5         20        AD01
                                                   6        20         AD01
                                                    7        30         OT01
                                                    8        40         RE01  
                                                    9        50         RP01
                                                   10      50         RP01
                 This are the records with same Service order number, and my select statement giving data like
    O/P
    Service Order =  60001212
    OPER    ITEM    REPAIR TYPE
    10         1           AD01
    20         1           AD01
    10         2           AD01
    20         2           AD01
    10         3           AD01
    20         3           AD01
    10         4           AD01
    20         4           AD01
    10         5           AD01
    20         5           AD01
    10         6           AD01
    20         6           AD01
    30         7           OT01
    40         8           RE01
    50         9           RP01
    50         10         RP01
    But I need output like this
    Item  Oper                   Rep Code
    1      10                      AD01
    2      20                      AD01
    3      10                      AD01
    4      20                      AD01
    5      20                      AD01
    6      20                      AD01
    7      30                      AD01
    8      40                      RE01
    9      50                      RP01
    10    50                      RP01
             Please give me the select statement which gives the above output. I need very urgent please....
    Thanks
    Robbie

    hi robert,
    The ouput u want is just a little away from the one u r actually getting. it is the two fields OPER and ITEM interchangeably..
    U just have to use GROUP BY ITEM..........if u want the desired output with ITEM as first field.
    <group-by-clause> &#8594; GROUP BY [<column-ref>,*]<column-ref>
    if it helps please reward points.
    thanks

  • Urgent Sql Query Problem - -Very Urgent

    Hi Guys,
    I need a urgent solution for a problem.I am
    using the following query
    select ename from emp where deptno =10
    Now I will declare a bind variable and if user passes 'A'
    then the query will run as it is and if he passes B
    then it should run the above query with this additional clause -> birthdate - hiredate >15.
    Please can any one help its very urgent

    Assuming that you have a birthdate column in your emp table, the following will do what you are asking for:
    VARIABLE bind_var VARCHAR2(1)
    EXECUTE :bind_var := '&bind_variable'
    SELECT ename FROM
    (SELECT 'A' AS selection, ename FROM emp WHERE deptno = 10
    UNION ALL
    SELECT 'B' AS selection, ename FROM emp WHERE deptno = 10 AND birthdate - hiredate > 15)
    WHERE selection = :bind_var
    However, the clause "birthdate - hiredate > 15" will only retrieve rows for employees who were born more than 15 days after they were hired. I doubt that this is what you really want, since this is impossible.

  • Error During Business Content Query Activation- Very Urgent

    Hi All,
    I am trying to install few queries in business cube 0pur_c01, which is already in production and already lot many queries are running.
    As per requirement i have to install  New quries in the 0Pur_C01
    0PUR_C01_Q0012 : Ordering Activities
    0PUR_C01_Q0015 : Purchase Order Values
    0PUR_C01_Q0013 : Vendor Comparison re Purchase Values
    0PUR_C01_Q0004 : Values – Purchase Order – Delivery – Invoice
    0PUR_C01_Q0023 : Total and Average Order Value
    Out of these five quries i am unable to install  0PUR_C01_Q0012 : Ordering Activities and geeting error message during simulate install rest queries has been installed already without any issue once i have unselected the already transported
    element.
    I am doing the same for  query 0PUR_C01_Q0012 : Ordering Activities but getting error message
    Error when activating element 9W6JIW7YMO04XVOZ5ATLLFLPB
    BEx transport request 'SBDK900497' is not available or not suitable
    Regards
    Premanshu Gupta

    Hi,
    To rectify this error,
    <i>BEx transport request 'SBDK900497' is not available or not suitable</i>
    Go to Transport Connection, there click on "BEX" "Create tranport request for BEX", there insert a new row, and create a new request. This is the default request for BEX queries.
    While transporting , dont tranport this request, collect the objects which you want to tranport and create a new request.
    <i>Error when activating element 9W6JIW7YMO04XVOZ5ATLLFLPB</i>
    For this error, check the object in meta data repository, whether the object is in active version or not.I think this object is not in Active version thats why you are getting this error.
    Assign points if it helps....

  • SQL SELECT Query Help   ..Please its very Urgent!!

    Hi All,
    I am having Oracle Database whice is storing 1000's of records daily.
    I need to select some information based on date and time.
    I am having two coloumns for Date and time. The first column(testDate) of type Date stores date as MM/DD/YY format and the second column(testTime)of type Numeric stores the time in seconds.
    The Example data is :
    testDate ------=-- testTime
    11/12/2002 --- 35000
    11/12/2002 --- 43000
    11/12/2002 --- 45000
    11/12/2002 --- 75000
    11/13/2002 --- 2000
    11/13/2002 --- 3500
    11/13/2002 --- 4300
    11/13/2002 --- 9800
    11/13/2002 --- 23000
    11/14/2002 --- 5000
    11/14/2002 --- 10000
    11/14/2002 --- 15000
    How can i write a SELECT Query to get the records of specific date and seconds to next day specific date and seconds.I mean i want all the records between 11/12/2002 --- 43000 seconds to 11/14/2002 --- 1000 seconds.
    If any one helps me in this regard iam very thank full to them.Its very urgent for me.
    Thanks

    Hi m7nra,
    I used the query as
    SELECT * FROM table
    WHERE testDate + (testTime/(24*60*60)) BETWEEN TO_DATE('MM/DD/YYYY','12.11.2002') AND TO_DATE('MM/DD/YYYY','14.11.2002')
    its giving DATE FORMAT NOT RECOGNIZED error.
    The Example data is :
    testDate ------=-- testTime
    11/12/2002 --- 35000
    11/12/2002 --- 43000
    11/12/2002 --- 45000
    11/12/2002 --- 75000
    11/13/2002 --- 2000
    11/13/2002 --- 3500
    11/13/2002 --- 4300
    11/13/2002 --- 9800
    11/13/2002 --- 23000
    11/14/2002 --- 5000
    11/14/2002 --- 10000
    11/14/2002 --- 15000
    infact i need all the records between 11/12/2002 --- 43000 seconds to 11/14/2002 --- 1000 seconds.
    Please help me to find a full query beacuse iam very new to Oracle.
    Thanks,
    S R Mannava

  • Very Urgent Help , ABAP SQL Query

    Guys,
    Please suggest.I have a table(custom_table1) with a field say A which is of date type = c and length = 9. And i want to query this table.Following is the query.
    Select substr(A,0,5) B C into itab From table custom_table1
    where b = ( select b from cusstom_table2 )
    and substr(A,0,5) = Input_A.
    That is i want to equate an Input_A (which is of 5 character length) with field A (only first 5 character of the 9 length). But it seems the query is wrong. Kindly help ,very urgent
    Thanks

    Thanks guys, U have helped me to fill up the where condition as
    but what about the column A in the select query ?I need only 5 characters from the field populated into Itab.
    CONCATENATE  srch_str '%' INTO srch_str.  -- bcos i want it to be 'InputA%'
    Select Substr(A,0,5) , B C Into Itab From CustomTable 1 where B = (Select B from customtable2) and A Like SrchStr
    Is there any means i can populate only the 5 characters from the select field A into Itab without using Substr (becos it doesnt work) ? Please help.

  • SQL Query, please help very urgent

    I am a newbie is sql.
    I have two tables called test_master and test_detail.
    Both tables contains pos_id as common field.
    In test_detail got sub_id and to get the people under a given pos_id, I join with pos_id of test_master.
    In the where condition, when I give the pos_id, it's returning only
    the first level. How can I get the second level and get all the levels?
    Any help is highly appreciable.It's very urgent.
    Looking forward to hear from you.
    Thanks
    Newbie

    Ok, I am pasting the description of the master and detail in the order.
    Master
    EMPLOYEE_NO VARCHAR2(30)
    ORGANIZATION_ID NUMBER(15)
    ORGANIZATION_NAME VARCHAR2(240)
    POSITION_ID NUMBER(15)
    POSITION_NAME VARCHAR2(240)
    Detail
    POSITION_ID NUMBER(15)
    SUBORDINATE_ID NUMBER(15)
    ORGANIZATION_ID NUMBER(15)
    POSITION_NAME VARCHAR2(50)
    Here is the sql, I want to get all the subordinates under a given position_id of the master.
    Looking forward to hear from you.
    select a.employee_no,a.POSITION_ID,a.POSITION_NAME,a.EMPLOYEE_NAME,
    b.position_id,b.subordinate_id from portal_employee_master_test a,
    portal_structure_test b
    where a.POSITION_ID = b.POSITION_ID and a.POSITION_ID='xyz'
    and b.position_ID=a.POSITION_ID

  • Very Very Urgent Issue: Restricted Key Figure does not return any data

    Hi all,
    Please help me solving this urgent issue.
    created customer exit variable on characterstics version and also
    other customer exit variable on Value type.
    I coded that in variable exit. Problem is when I include these in
    restrickted keyfigure My query does not return me any data.
    But if I remove from restrickted key firgure and put it as normal
    charaterstics I see the variable is getting populated.
    Also in RSRT the SQl generated when these are included in RKF is not
    correct.
    I debugged and know they are getting populated. As when included in RKF
    I can also see the values of customer exit variables from information
    tab.
    I also know that there is data in cube for those restrictions.
    I posted one OSS Notes regarding this urgent issue. But got no reply from SAP.
    FYI: We are using BEx 3.5 Browser SAP GUI 6.4 Patch 20 BW Patch 11
    Thanks
    SAP BW
    **Please do not post the same question twice: Very Urgent Issue: Restricted Key Figure does not return any data

    Hi,
    Everyone out there this is very urgent. If someone can help me solving this problem.
    We are using BEx 3.5 Browser SAP GUI 6.4 Patch 20 BW Patch 11.
    I posted one oss notes also regarding this issue. But got no reply from SAP.
    So, Please help me solving this issue.
    Thanks
    SAP BW

  • XML SQL utility ( Very Urgent)

    Hi,
    Running the Client side Front-End works for me....Thank you
    very much. These are all my questions.
    1. As far as my understanding goes XML Parsers are used to parse
    the incoming XML documents before updating the database. But
    when I used the Oraxle XML class(getXML option)I found one
    command line option called -useDOMDoc( Use the DOM API to
    generate the XML doc). I am not clear about it's functionality.
    Why it's being used to create a XML document? Or explain me
    clearly about the functionality of getXML option?
    2.With the help of putXML command line option I could insert one
    XML document into Oracle 8i ( I could insert one table only). My
    question is if I have a XML document which contains elements
    from two tables( emp and detail) and tags from the same two
    table too. In that case how could I insert into two tables? what
    I should do?
    For example my DTD has columns for two tables emp and detail.
    Here is my xml document, and the command which I am going to use
    in the command line would be
    java OracleXML putXML -user "scott/tiger" -filename xxxxx emp,
    details
    <?xml version="1.0"?>
    <!DOCTYPE ROWSET [
    <!ELEMENT ROWSET (ROW)*>
    <!ELEMENT ROW (EMPNO, ENAME?, JOB?, MGR?, HIREDATE?, SAL?,
    COMM?, DEPTNO?)>
    <!ATTLIST ROW num CDATA #REQUIRED>
    <!ELEMENT EMPNO (#PCDATA)>-----------To Table EMP
    <!ELEMENT ENAME (#PCDATA)>-----------To Table EMP
    <!ELEMENT JOB (#PCDATA)>-------------To Table EMP
    <!ELEMENT MGR (#PCDATA)>-------------To Table EMP
    <!ELEMENT HIREDATE (#PCDATA)>--------To Table EMP
    <!ELEMENT SAL (#PCDATA)>-------------To Table EMP
    <!ELEMENT COMM (#PCDATA)>------------To Table EMP
    <!ELEMENT DEPTNO (#PCDATA)>----------To Table EMP
    <!ELEMENT LOCATION (#PCDATA)>--------To Table DETAILS
    <!ELEMENT ALLOWANCE (#PCDATA)>-------To Table DETAILS
    ]>
    <ROWSET>
    <ROW num="1">
    <EMPNO>88</EMPNO>
    <ENAME>cmos</ENAME>
    <LOCATION>usa</LOCATION>
    <ALLOWANCE>1000</ALLOWANCE>
    </ROW>
    </ROWSET>
    Thanks,
    Chan...
    null

    Hi Chan,
    Hello Mr. "very urgent" Chan,
    1- The command line front end of the XSU, besides being useful
    for you users, it is also a great tool for us to test the XSU.
    Basically the -useDOMDoc makes the XSU use OracleXMLDocGenDOM to
    generate the doc. When using the query API you can pass the
    OracleXMLDocGenDom class to the getXML request and instead of a
    string contining the xml document you will get back a DOM tree
    (i.e. Document object).
    2- This issue is visited at:
    http://f2.dejanews.com/oracletechnet/members/index.cgi?do=showmsg
    &conf=Oracl1.XML&msg=1431&show=all&depth=all
    Chan (guest) wrote:
    : Hi,
    : Running the Client side Front-End works for me....Thank you
    : very much. These are all my questions.
    : 1. As far as my understanding goes XML Parsers are used to
    parse
    : the incoming XML documents before updating the database. But
    : when I used the Oraxle XML class(getXML option)I found one
    : command line option called -useDOMDoc( Use the DOM API to
    : generate the XML doc). I am not clear about it's functionality.
    : Why it's being used to create a XML document? Or explain me
    : clearly about the functionality of getXML option?
    : 2.With the help of putXML command line option I could insert
    one
    : XML document into Oracle 8i ( I could insert one table only).
    My
    : question is if I have a XML document which contains elements
    : from two tables( emp and detail) and tags from the same two
    : table too. In that case how could I insert into two tables?
    what
    : I should do?
    : For example my DTD has columns for two tables emp and detail.
    : Here is my xml document, and the command which I am going to
    use
    : in the command line would be
    : java OracleXML putXML -user "scott/tiger" -filename xxxxx emp,
    : details
    : <?xml version="1.0"?>
    : <!DOCTYPE ROWSET [
    : <!ELEMENT ROWSET (ROW)*>
    : <!ELEMENT ROW (EMPNO, ENAME?, JOB?, MGR?, HIREDATE?, SAL?,
    : COMM?, DEPTNO?)>
    : <!ATTLIST ROW num CDATA #REQUIRED>
    : <!ELEMENT EMPNO (#PCDATA)>-----------To Table EMP
    : <!ELEMENT ENAME (#PCDATA)>-----------To Table EMP
    : <!ELEMENT JOB (#PCDATA)>-------------To Table EMP
    : <!ELEMENT MGR (#PCDATA)>-------------To Table EMP
    : <!ELEMENT HIREDATE (#PCDATA)>--------To Table EMP
    : <!ELEMENT SAL (#PCDATA)>-------------To Table EMP
    : <!ELEMENT COMM (#PCDATA)>------------To Table EMP
    : <!ELEMENT DEPTNO (#PCDATA)>----------To Table EMP
    : <!ELEMENT LOCATION (#PCDATA)>--------To Table DETAILS
    : <!ELEMENT ALLOWANCE (#PCDATA)>-------To Table DETAILS
    : ]>
    : <ROWSET>
    : <ROW num="1">
    : <EMPNO>88</EMPNO>
    : <ENAME>cmos</ENAME>
    : <LOCATION>usa</LOCATION>
    : <ALLOWANCE>1000</ALLOWANCE>
    : </ROW>
    : </ROWSET>
    : Thanks,
    : Chan...
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Very Urgent, files, threads, and swing !!!!

    Dear friends, i have a swing application, in that application i have a class that extends a thread, that thread will do nothing but read the contents of my data file and puts them in an array, but i am getting a NullpointerException in my thread, could any friend help me please, it is very urgent, i will post my code below.
    import java.awt.*;
    import java.awt.event.*;
    import java.text.DateFormat;
    import java.util.*;
    import javax.swing.*;
    import java.sql.*;
    import java.net.URL;
    import java.io.*;
    public class FinalMachine extends JFrame
    private JPanel MainPanel, ThicknessPanel, MainManager,fieldsPanel, sub_panel;
    private Container c;
    private CardLayout CardManager;
    private String timezone;
    private static final int ONE_SECOND = 1000;
    private JLabel welcome_label, label1, label2, label3,field_label;
    private JTextField data_entry;
    private Connection connection;
    public JPanel thick_figure;
    public int num_of_hits, next_index, recCount;
    public int dataBuffer[];
    public FileReader data_file;
    public BufferedReader b_data_file;
    public File tem_file;
    final int num_of_rec = 20;
    public FinalMachine()
    super("PHOENIX MACHINERY s.a.l");
    /* Start all threads */
    /* Start filling data file in global array */
         loadData dataFile = new loadData();
         dataFile.start();          
    /* Adding control to window application */
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent windowevent)
    // setDefaultCloseOperation(0);
              System.exit(0);
    public void windowDeiconified(WindowEvent eve)
    setState(0);
    addComponentListener(new ComponentAdapter() {
    public void componentResized(ComponentEvent componentevent)
    setSize(500, 500);
    Dimension dimension1 = Toolkit.getDefaultToolkit().getScreenSize();
    if(dimension1.width == 800 && dimension1.height == 600)
    setLocation(150, 25);
    else
    if(dimension1.width == 1024 && dimension1.height == 768)
    setLocation(200, 100);
    /* Setting the location of the application on the screen */
    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    if(dimension.width == 800 && dimension.height == 600)
    setLocation(150, 25);
    else
    if(dimension.width == 1024 && dimension.height == 768)
    setLocation(200, 100);
    /* Constructing the main menu */
         JMenuBar bar = new JMenuBar();
         setJMenuBar( bar );
         JMenu fileMenu = new JMenu( "File");
         fileMenu.setMnemonic( 'F' );
         JMenuItem mainItem = new JMenuItem( "Main page" );
         mainItem.setMnemonic( 'M' );
         mainItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                   CardManager.show(MainManager, "main");
         fileMenu.add( mainItem );
         JMenuItem dataItem = new JMenuItem( "Database page" );
         dataItem.setMnemonic( 'D' );
         dataItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                   CardManager.show(MainManager, "data_base");
         fileMenu.add( dataItem );
         JMenuItem printItem = new JMenuItem( "Print" );
         printItem.setMnemonic( 'P' );
         printItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                   PrintUtilities.printComponent(MainManager);
         fileMenu.add( printItem );
         JMenuItem exitItem = new JMenuItem( "Exit" );
         exitItem.setMnemonic( 'P' );
         exitItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                        System.exit(0);
         fileMenu.add( exitItem );
         bar.add( fileMenu );
         JMenu figureMenu = new JMenu( "Figures");
         figureMenu.setMnemonic( 'G' );
         JMenuItem thicknessItem = new JMenuItem( "Thickness" );
         thicknessItem.setMnemonic( 'T' );
         thicknessItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                   CardManager.show(MainManager, "thickness");
         figureMenu.add( thicknessItem );
         bar.add( figureMenu );
         JMenu helpMenu = new JMenu( "Help");
         helpMenu.setMnemonic( 'H' );
         JMenuItem aboutItem = new JMenuItem( "About us" );
         aboutItem.setMnemonic( 'A' );
         aboutItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                   JOptionPane.showMessageDialog(null, "Engineer Bilal Haidar (Computer & "+                     "Communication Engineering)\n\n All Rights Reserevd. @ 2002",
                        "About me...", JOptionPane.PLAIN_MESSAGE);
         helpMenu.add( aboutItem );
         bar.add( helpMenu );
    /* Intializing global values */
    dataBuffer = new int[60];
    /* Initializing the panels */
    c = getContentPane();
    c.setLayout(new FlowLayout());
    CardManager = new CardLayout();
    MainManager = new JPanel(false);
    MainManager.setLayout(CardManager);
    c.add(MainManager);
    javax.swing.border.Border border = BorderFactory.createEmptyBorder(10, 10, 5, 10);
    MainPanel = new JPanel(false);
    MainPanel.setLayout(new BoxLayout(MainPanel, 1));
    MainPanel.setBorder(border);
    ThicknessPanel = new JPanel(false);
    ThicknessPanel.setLayout(new BoxLayout(ThicknessPanel, 1));
    ThicknessPanel.setBorder(border);
    fieldsPanel = new JPanel(false);
    fieldsPanel.setLayout( new BoxLayout( fieldsPanel,1));
    fieldsPanel.setBorder(border);
    sub_panel = new JPanel(false);
    sub_panel.setLayout( new BoxLayout(sub_panel,0) );
    sub_panel.setBorder(border);
    thick_figure = new JPanel(false);
    thick_figure.setBorder(border);
    /* Filling the main panel */
    JLabel jlmain = new JLabel("Main Page");
    MainPanel.add(jlmain);
    timezone = showTime(new Locale("en", "US"));
    JLabel jltime = new JLabel(" " + timezone);
    MainPanel.add(jltime);
    MainManager.add(MainPanel, "main");
    /* Filling the thickness panel */
    num_of_hits = 0;
    next_index = 0;
    /* fill in with ero values for everything*/
    /*display the figure*/
    ThicknessPanel.add(thick_figure);
    JLabel blanklabel = new JLabel(" ");
    ThicknessPanel.add(blanklabel);
    JButton build_fig = new JButton("Draw Figure");
    build_fig.addActionListener(
         new ActionListener() {  // anonymous inner class
         public void actionPerformed( ActionEvent e )
    if ( num_of_hits == 0 )
    /* draw figure based on first 20 points in the array */
    next_index = num_of_rec;
    else
    if ( num_of_hits > 3 )
    JOptionPane.showMessageDialog(null,"No more data to draw","Error Drawing",JOptionPane.ERROR_MESSAGE);
    else
    /* draw the figure starting the data from index 20*/
    next_index = next_index + num_of_rec;
    num_of_hits += 1;
    ThicknessPanel.add(build_fig);
    MainManager.add(ThicknessPanel, "thickness");
    /* filling the database panel */
    label1 = new JLabel(" ",SwingConstants.CENTER);
    welcome_label = new JLabel(" Database Page ",SwingConstants.CENTER);
    label2 = new JLabel(" ",SwingConstants.CENTER);
    fieldsPanel.add( label1 );
    fieldsPanel.add( welcome_label );
    fieldsPanel.add( label2 );
    field_label = new JLabel(" Enter your name: ");
    data_entry = new JTextField( 10 );
    sub_panel.add( field_label );
    sub_panel.add( data_entry );
    fieldsPanel.add( sub_panel );
    JButton add_data = new JButton( "Add me" );
    add_data.addActionListener(
         new ActionListener() {  // anonymous inner class
         public void actionPerformed( ActionEvent e )
    // try {
    //          url = "jdbc:odbc:DataEntry";
    //          Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    //          connection = DriverManager.getConnection( url );
    //               System.out.println( "Connection Suucessfull");
    // Statement statement = connection.createStatement();
    //                String get_field;
    //               get_field = data_entry.getText();
    //               String query = "INSERT INTO data (anyField) VALUES ('get_field')";
    //                int result1 = statement.executeUpdate( query );
    //           if ( result1 == 1 )
    // JOptionPane.showMessageDialog(null, "Thanks for the info..."," Data Entry Success",JOptionPane.INFORMATION_MESSAGE);
    //                else
    //                     JOptionPane.showMessageDialog(null, "Sorry, your name was not added...","Data entry error",JOptionPane.ERROR_MESSAGE);
    //     catch ( ClassNotFoundException cnfex ) {
    //          // process ClassNotFoundExceptions here
    //          cnfex.printStackTrace();
    //               System.out.println( "Connection UN Suucessfull");
    //          catch ( SQLException sqlex ) {
    //     // process SQLExceptions here
    //          sqlex.printStackTrace();
    //                System.out.println( "Connection UN Suucessfull");
    //          catch ( Exception ex ) {
    //          // process remaining Exceptions here
    //          ex.printStackTrace();
    //               System.out.println( "Connection UN Suucessfull");
    fieldsPanel.add(add_data);
    MainManager.add(fieldsPanel, "data_base");
    /* display time */
    Timer timer = new Timer(1000, new ActionListener() {
    public void actionPerformed(ActionEvent actionevent)
    timezone = showTime(new Locale("en", "US"));
    setTitle("PHOENIX MACHINERY s.a.l " + timezone);
    timer.start();
    public static void main(String args[])
    FinalMachine finalmachine = new FinalMachine();
    finalmachine.setSize(500, 500);
    ImageIcon imageicon = new ImageIcon("images/pc.gif");
    finalmachine.setIconImage(imageicon.getImage());
    finalmachine.show();
    public static String showTime(Locale locale)
    java.util.Date date = new java.util.Date();
    byte byte0 = 2;
    DateFormat dateformat = DateFormat.getTimeInstance(byte0, locale);
    String s = dateformat.format(date);
    return s;
    /* Thread loadData starts here */
    class loadData extends Thread
    public void run()
    try {
              readMyFile();
    catch( Exception x )
    System.out.println("The following error occured in LoadData thread : "+x.toString() ); }
    } // run() ends here
    /* method read file inside thread loadData */
    void readMyFile() {
    String record = " ";
    recCount = 0;
    try {
              tem_file = new File("mydata.dat");
              data_file = new FileReader(tem_file);
              b_data_file = new BufferedReader( data_file );
              record = new String();
              while ( (record = b_data_file.readLine()) != null ) {
              dataBuffer[recCount] = Integer.parseInt(record);
              recCount += 1; }
         b_data_file.close();     
              catch (IOException e) {
         System.out.println("Uh oh, got an IOException error!");
         e.printStackTrace();
         } // end of readMyFile()
    } // thread loadData ends
    mydata.dat
    2
    4
    3
    1
    2
    3
    5
    2
    4
    1
    6
    3
    2
    5
    4
    1
    2
    5
    8
    2
    6
    9
    7
    4
    2
    1
    0
    2
    5
    4
    8
    7
    5
    6
    3
    2
    1
    4
    3
    0
    2
    3
    6
    5
    2
    1
    4
    5
    6
    9
    8
    5
    2
    1
    6
    8
    3
    1
    7
    5

    Thank you Mr. jobuck, you helped me a lot, i wonder if you can provide me with a tutorial on how threads work and how runnables work too. i fixed the error ut old me about but still when i try to add another thread to my program i got an error saying that, i must decalre the new thread in a seperate file please can u have a look on what i have:
    import java.awt.*;
    import java.awt.event.*;
    import java.text.DateFormat;
    import java.util.*;
    import javax.swing.*;
    import java.sql.*;
    import java.net.URL;
    import java.io.*;
    public class FinalMachine extends JFrame
    private JPanel MainPanel, ThicknessPanel, MainManager,fieldsPanel, sub_panel;
    private Container c;
    private CardLayout CardManager;
    private String timezone;
    private static final int ONE_SECOND = 1000;
    private JLabel welcome_label, label1, label2, label3,field_label;
    private JTextField data_entry;
    private JPanel thick_figure;
    private int num_of_hits, next_index, recCount, read_flag;
    private int dataBuffer[];
    private FileReader data_file;
    private BufferedReader b_data_file;
    private File tem_file;
    private Connection connection;     
    final int num_of_rec = 20;
    public FinalMachine()
    super("PHOENIX MACHINERY s.a.l");
    /* load JDBC drivers */
    try {
    String url = "jdbc:odbc:DataEntry";
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
         connection = DriverManager.getConnection( url );
         System.out.println( "Connection Suucessfull");
    catch ( ClassNotFoundException cnfex ) {
    // process ClassNotFoundExceptions here
    cnfex.printStackTrace();
         System.out.println( "Connection UN Suucessfull");
    catch ( SQLException sqlex ) {
    // process SQLExceptions here
    sqlex.printStackTrace();
         System.out.println( "Connection UN Suucessfull");
    catch ( Exception ex ) {
    // process remaining Exceptions here
    ex.printStackTrace();
         System.out.println( "Connection UN Suucessfull");
    /* Intializing global values */
    dataBuffer = new int[60];
    /* Start all threads */
    /* Start filling data file in global array */
         loadData dataFile = new loadData();
         dataFile.start();          
         setData setdata = new setData();
         setdata.start();          
    /* Adding control to window application */
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent windowevent)
    // setDefaultCloseOperation(0);
              System.exit(0);
    public void windowDeiconified(WindowEvent eve)
    setState(0);
    addComponentListener(new ComponentAdapter() {
    public void componentResized(ComponentEvent componentevent)
    setSize(500, 500);
    Dimension dimension1 = Toolkit.getDefaultToolkit().getScreenSize();
    if(dimension1.width == 800 && dimension1.height == 600)
    setLocation(150, 25);
    else
    if(dimension1.width == 1024 && dimension1.height == 768)
    setLocation(200, 100);
    /* Setting the location of the application on the screen */
    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    if(dimension.width == 800 && dimension.height == 600)
    setLocation(150, 25);
    else
    if(dimension.width == 1024 && dimension.height == 768)
    setLocation(200, 100);
    /* Constructing the main menu */
         JMenuBar bar = new JMenuBar();
         setJMenuBar( bar );
         JMenu fileMenu = new JMenu( "File");
         fileMenu.setMnemonic( 'F' );
         JMenuItem mainItem = new JMenuItem( "Main page" );
         mainItem.setMnemonic( 'M' );
         mainItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                   CardManager.show(MainManager, "main");
         fileMenu.add( mainItem );
         JMenuItem dataItem = new JMenuItem( "Database page" );
         dataItem.setMnemonic( 'D' );
         dataItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                   CardManager.show(MainManager, "data_base");
         fileMenu.add( dataItem );
         JMenuItem printItem = new JMenuItem( "Print" );
         printItem.setMnemonic( 'P' );
         printItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                   PrintUtilities.printComponent(MainManager);
         fileMenu.add( printItem );
         JMenuItem exitItem = new JMenuItem( "Exit" );
         exitItem.setMnemonic( 'P' );
         exitItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                        System.exit(0);
         fileMenu.add( exitItem );
         bar.add( fileMenu );
         JMenu figureMenu = new JMenu( "Figures");
         figureMenu.setMnemonic( 'G' );
         JMenuItem thicknessItem = new JMenuItem( "Thickness" );
         thicknessItem.setMnemonic( 'T' );
         thicknessItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                   CardManager.show(MainManager, "thickness");
         figureMenu.add( thicknessItem );
         bar.add( figureMenu );
         JMenu helpMenu = new JMenu( "Help");
         helpMenu.setMnemonic( 'H' );
         JMenuItem aboutItem = new JMenuItem( "About us" );
         aboutItem.setMnemonic( 'A' );
         aboutItem.addActionListener (
              new ActionListener() {
                   public void actionPerformed( ActionEvent e )
                   JOptionPane.showMessageDialog(null, "Engineer Bilal Haidar (Computer & "+                     "Communication Engineering)\n\n All Rights Reserevd. @ 2002",
                        "About me...", JOptionPane.PLAIN_MESSAGE);
         helpMenu.add( aboutItem );
         bar.add( helpMenu );
    /* Initializing the panels */
    c = getContentPane();
    c.setLayout(new FlowLayout());
    CardManager = new CardLayout();
    MainManager = new JPanel(false);
    MainManager.setLayout(CardManager);
    c.add(MainManager);
    javax.swing.border.Border border = BorderFactory.createEmptyBorder(10, 10, 5, 10);
    MainPanel = new JPanel(false);
    MainPanel.setLayout(new BoxLayout(MainPanel, 1));
    MainPanel.setBorder(border);
    ThicknessPanel = new JPanel(false);
    ThicknessPanel.setLayout(new BoxLayout(ThicknessPanel, 1));
    ThicknessPanel.setBorder(border);
    fieldsPanel = new JPanel(false);
    fieldsPanel.setLayout( new BoxLayout( fieldsPanel,1));
    fieldsPanel.setBorder(border);
    sub_panel = new JPanel(false);
    sub_panel.setLayout( new BoxLayout(sub_panel,0) );
    sub_panel.setBorder(border);
    thick_figure = new JPanel(false);
    thick_figure.setBorder(border);
    /* Filling the main panel */
    JLabel jlmain = new JLabel("Main Page");
    MainPanel.add(jlmain);
    timezone = showTime(new Locale("en", "US"));
    JLabel jltime = new JLabel(" " + timezone);
    MainPanel.add(jltime);
    MainManager.add(MainPanel, "main");
    /* Filling the thickness panel */
    num_of_hits = 0;
    next_index = 0;
    /* fill in with ero values for everything*/
    /*display the figure*/
    ThicknessPanel.add(thick_figure);
    JLabel blanklabel = new JLabel(" ");
    ThicknessPanel.add(blanklabel);
    JButton build_fig = new JButton("Draw Figure");
    build_fig.addActionListener(
         new ActionListener() {  // anonymous inner class
         public void actionPerformed( ActionEvent e )
    if ( num_of_hits == 0 )
    /* draw figure based on first 20 points in the array */
    next_index = num_of_rec;
    else
    if ( num_of_hits > 3 )
    JOptionPane.showMessageDialog(null,"No more data to draw","Error Drawing",JOptionPane.ERROR_MESSAGE);
    else
    /* draw the figure starting the data from index 20*/
    next_index = next_index + num_of_rec;
    num_of_hits += 1;
    ThicknessPanel.add(build_fig);
    MainManager.add(ThicknessPanel, "thickness");
    /* filling the database panel */
    label1 = new JLabel(" ",SwingConstants.CENTER);
    welcome_label = new JLabel(" Database Page ",SwingConstants.CENTER);
    label2 = new JLabel(" ",SwingConstants.CENTER);
    fieldsPanel.add( label1 );
    fieldsPanel.add( welcome_label );
    fieldsPanel.add( label2 );
    field_label = new JLabel(" Enter your name: ");
    data_entry = new JTextField( 10 );
    sub_panel.add( field_label );
    sub_panel.add( data_entry );
    fieldsPanel.add( sub_panel );
    JButton add_data = new JButton( "Add me" );
    add_data.addActionListener(
         new ActionListener() {  // anonymous inner class
         public void actionPerformed( ActionEvent e )
              try {
    Statement statement = connection.createStatement();
                   String get_field;
              get_field = data_entry.getText();
              String query = "INSERT INTO data (anyField) VALUES ('"+get_field+"')";
              int result1 = statement.executeUpdate( query );
              if ( result1 == 1 )
              JOptionPane.showMessageDialog(null, "Thanks for the info..."," Data Entry Success",JOptionPane.INFORMATION_MESSAGE);
                        data_entry.setText(" ");     
              else
                        JOptionPane.showMessageDialog(null, "Sorry, your name was not added...","Data entry error",JOptionPane.ERROR_MESSAGE);
         catch ( SQLException sqlex ) {
         // process SQLExceptions here
              sqlex.printStackTrace();
                   System.out.println( "Connection UN Suucessfull");
              catch ( Exception ex ) {
              // process remaining Exceptions here
              ex.printStackTrace();
                   System.out.println( "Connection UN Suucessfull");
    fieldsPanel.add(add_data);
    MainManager.add(fieldsPanel, "data_base");
    /* display time */
    Timer timer = new Timer(1000, new ActionListener() {
    public void actionPerformed(ActionEvent actionevent)
    timezone = showTime(new Locale("en", "US"));
    setTitle("PHOENIX MACHINERY s.a.l " + timezone);
    timer.start();
    public static void main(String args[])
    FinalMachine finalmachine = new FinalMachine();
    finalmachine.setSize(500, 500);
    ImageIcon imageicon = new ImageIcon("images/pc.gif");
    finalmachine.setIconImage(imageicon.getImage());
    finalmachine.show();
    public static String showTime(Locale locale)
    java.util.Date date = new java.util.Date();
    byte byte0 = 2;
    DateFormat dateformat = DateFormat.getTimeInstance(byte0, locale);
    String s = dateformat.format(date);
    return s;
    /* Thread loadData starts here */
    public class loadData extends Thread
    public void run()
    try {
              readMyFile();
              read_flag = 1;
              notify();
    catch( Exception x )
    System.out.println("The following error occured in LoadData thread : "+x.toString() );
    } // run() ends here
    /* method read file inside thread loadData */
    void readMyFile() {
    String record = " ";
    recCount = 0;
    try {
              tem_file = new File("mydata.dat");
              data_file = new FileReader(tem_file);
              b_data_file = new BufferedReader( data_file );
              record = new String();
              while ( (record = b_data_file.readLine()) != null ) {
              dataBuffer[recCount] = Integer.parseInt(record);
              recCount += 1; }
         b_data_file.close();     
              catch (IOException e) {
         System.out.println("Uh oh, got an IOException error!");
         e.printStackTrace();
         } // end of readMyFile()
    } // thread loadData ends
    public class setData extends Thread {
    public void run()
    try {
              while ( !read_flag ) {
                   try {     wait(); }
                   catch( InterruptedException e ) {
                        e.printStackTrace();
              } // end while
              for(int index = 0; index < 60; index++)
              System.out.println("Array["+index+"] = "+dataBuffer[index]);
    catch( Exception x )
    System.out.println("The following error occured in LoadData thread : "+x.toString() );
    } // run() ends here
    the only added thing is the setData thread, i want this thread to start printing out the array whenever, loadData thread has finished filling the data inside the array please i need ur help.

  • Query tuning : you can do it yourself

    Hello,
    This thread is not a question.
    How tune my query ?
    My query didn't use indexes why ?
    I have indexes on table, stats are up-to-date why Oracle does a full scan on table ?
    What are the hint which I can use ?
    etc...
    I would like try to answer to many such questions posted in this forum about query tuning.
    And explain that tuning is not always complicated, is not always reserved to some consultants, is not always solved by hints usage, and not require to buy some books which would give some magic solutions.
    By this thread, I would explain to people which have some query performance issues, that the solution is maybe here, in front of their eyes, inside the query itself. The solution may come from their own side, and that they can be happy to solve such question themself.
    I'll develop here below a case from a real word situation encountered some time ago.

    At this point, remove this huge and nightmarish hint. We'll use it only if no other ways may found.
    First, a look into the data model to see if the joins may be rewrite differently.
    Original joins :
        dw.AIRPORT_ROUTING_ID = ar.AIRPORT_ROUTING_ID and
        dw.COUNTRY_ROUTING_ID = cor.COUNTRY_ROUTING_ID and
        dw.REGION_ROUTING_ID = rr.REGION_ROUTING_ID and
        dw.CITY_ROUTING_ID  = cr.CITY_ROUTING_ID andAnd indeed, the join may be rewrite as below :
        and dw.AIRPORT_ROUTING_ID = ar.AIRPORT_ROUTING_ID
        and ar.CITY_ROUTING_ID    = cr.CITY_ROUTING_ID
        and cr.COUNTRY_ROUTING_ID = cor.COUNTRY_ROUTING_ID 
        and cor.REGION_ROUTING_ID = rr.REGION_ROUTING_IDNote the aliases were change here. Is it complicated to try to rewrite query like that ?
    Secondly, we will try to see how avoid or, at least, workaround the all OR conditions. It would be well if we could merge all the FROM (bind variable :a) in one column, same for all TO (bind variable :b), unfortunately, the data model cannot be change (of course). Ok, we will try to work with a temporary table by combining all the possiblities between the two conditions.
    create global temporary table REGION_ROUTING_TMP
    on commit preserve rows
    as
    select REGION_ROUTING_NAMES, REGION_ROUTING_ID, REGION_FROM as REGION_FROM, REGION_STOP1 as REGION_TO
    from   REGION_ROUTING
    where  1=2;And an index based on the two mains criteria of the query may help :
    create index IDX_REGION_ROUTING_TMP on REGION_ROUTING_TMP(REGION_FROM,REGION_TO);Then we'll populate table :
    insert into REGION_ROUTING_TMP
    select REGION_ROUTING_NAMES, REGION_ROUTING_ID, REGION_FROM as REGION_FROM, REGION_STOP1 as REGION_TO
    from   REGION_ROUTING
    union
    select REGION_ROUTING_NAMES, REGION_ROUTING_ID, REGION_FROM as REGION_FROM, REGION_STOP2 as REGION_TO
    from   REGION_ROUTING
    union
    select REGION_ROUTING_NAMES, REGION_ROUTING_ID, REGION_FROM as REGION_FROM, REGION_STOP3 as REGION_TO
    from   REGION_ROUTING
    union
    select REGION_ROUTING_NAMES, REGION_ROUTING_ID, REGION_FROM as REGION_FROM, REGION_TO as REGION_TO
    from   REGION_ROUTING
    union
    select REGION_ROUTING_NAMES, REGION_ROUTING_ID, REGION_STOP1 as REGION_FROM, REGION_STOP2 as REGION_TO
    from   REGION_ROUTING
    union
    select REGION_ROUTING_NAMES, REGION_ROUTING_ID, REGION_STOP1 as REGION_FROM, REGION_STOP3 as REGION_TO
    from   REGION_ROUTING
    union
    select REGION_ROUTING_NAMES, REGION_ROUTING_ID, REGION_STOP1 as REGION_FROM, REGION_TO as REGION_TO
    from   REGION_ROUTING
    union
    select REGION_ROUTING_NAMES, REGION_ROUTING_ID, REGION_STOP2 as REGION_FROM, REGION_STOP3 as REGION_TO
    from   REGION_ROUTING
    union
    select REGION_ROUTING_NAMES, REGION_ROUTING_ID, REGION_STOP2 as REGION_FROM, REGION_TO as REGION_TO
    from   REGION_ROUTING
    union
    select REGION_ROUTING_NAMES, REGION_ROUTING_ID, REGION_STOP3 as REGION_FROM, REGION_TO as REGION_TO
    from   REGION_ROUTING;The insert take near 9 seconds, which is a reasonnable elapse time.
    At this point, the query become :
    Select
       ap.AIRPORT_PAIR,  
       dw.DELIVERY_PERIOD,
       dw.TOTAL_PAX As Demand,
       od.GLOBAL_TOTAL_PAX as Total_OD_Demand,
       dw.REPORTED_PAX As ReportedPax,
       ap.AIRPORT_FROM,
       ap.AIRPORT_TO,
       ap.CITY_FROM,
       ap.CITY_TO,
       ap.COUNTRY_FROM_NAME,
       ap.COUNTRY_TO_NAME,
       ap.REGION_FROM_NAME,
       ap.REGION_TO_NAME,
       ar.AIRPORT_ROUTING,
       cr.CITY_ROUTING,
       cor.COUNTRY_ROUTING_NAMES,
       rr.REGION_ROUTING_NAMES,
       ar.NUMBER_OF_STOP,
       dw.PERCENT_OF_TOTAL_PAX_VS_OD,
       dw.AIRLINE1,
       dw.AIRLINE2,
       dw.AIRLINE3,
       dw.AIRLINE4,
       dw.NUMBER_OF_AIRLINE,
       dw.AIRCRAFTCLASS_NAME,
       dw.FARE
    From
       REGION_ROUTING_TMP rr, -- here we use now the temporary table instead of REGION_ROUTING table
       DETAILED_FLIGHTS dw,
       AIRPORT_PAIR ap,
       AIRPORT_ROUTING ar,
       CITY_ROUTING cr,
       COUNTRY_ROUTING cor,
       OD od
    where
            dw.DELIVERY_PERIOD  in ('2006-09','2006-08','2006-07')
    and dw.AIRPORT_PAIR_ID    = ap.AIRPORT_PAIR_ID
    and dw.OD_ID              = od.OD_ID
    and dw.AIRPORT_ROUTING_ID = ar.AIRPORT_ROUTING_ID
    and ar.CITY_ROUTING_ID    = cr.CITY_ROUTING_ID
    and     cr.COUNTRY_ROUTING_ID = cor.COUNTRY_ROUTING_ID 
    and cor.REGION_ROUTING_ID = rr.REGION_ROUTING_ID
    and rr.REGION_FROM        = '7'  |
    and rr.REGION_TO          = '8'  |-> these two lines replace all the OR conditions;And explain plan :
    | Id  | Operation                             |  Name                          | Rows  | Bytes | Cost  | Pstart| Pstop |
    |   0 | SELECT STATEMENT                      |                                |   469 |   174K|  3462 |       |       |
    |   1 |  NESTED LOOPS                         |                                |   469 |   174K|  3462 |       |       |
    |   2 |   NESTED LOOPS                        |                                |   458 |   166K|  3004 |       |       |
    |   3 |    NESTED LOOPS                       |                                |   454 |   127K|  2096 |       |       |
    |   4 |     NESTED LOOPS                      |                                |   258 | 58308 |   548 |       |       |
    |   5 |      NESTED LOOPS                     |                                |   246 | 48216 |    56 |       |       |
    |   6 |       NESTED LOOPS                    |                                |    26 |  4420 |     4 |       |       |
    |   7 |        TABLE ACCESS BY INDEX ROWID    | REGION_ROUTING_TMP             |     1 |   123 |   
    |*  8 |         INDEX RANGE SCAN              | IDX_REGION_ROUTING_TMP         |     1 |       |     1 |       | 
    |   9 |        TABLE ACCESS BY INDEX ROWID    | COUNTRY_ROUTING                |    32 |  1504 |     2
    |* 10 |         INDEX RANGE SCAN              | IX9_COUNTRY_ROUTING            |    32 |       |     1 |       | 
    |  11 |       TABLE ACCESS BY INDEX ROWID     | CITY_ROUTING                   |     9 |   234 |     2 | 
    |* 12 |        INDEX RANGE SCAN               | IX9_CITY_ROUTING               |    12 |       |     1 |    
    |  13 |      TABLE ACCESS BY INDEX ROWID      | AIRPORT_ROUTING                |     1 |    30 |     2
    |* 14 |       INDEX RANGE SCAN                | IX10_AIRPORT_ROUTING           |     1 |       |     1 |   
    |* 15 |     TABLE ACCESS BY GLOBAL INDEX ROWID| DETAILED_FLIGHTS               |     2 |   122 |   
    |* 16 |      INDEX RANGE SCAN                 | IX3_DETAILED_FLIGHTS           |     9 |       |     2 |    
    |  17 |    TABLE ACCESS BY INDEX ROWID        | AIRPORT_PAIR                   |     1 |    85 |     2 |  
    |* 18 |     INDEX RANGE SCAN                  | IX1_AIRPORT_PAIR               |     1 |       |     1 |       |
    |  19 |   TABLE ACCESS BY INDEX ROWID         | OD                             |     1 |    10 |     1 |       |   
    |* 20 |    INDEX UNIQUE SCAN                  | PK_OD                          |     1 |       |       |       |       |
    ----------------------------------------------------------------------------------------------------Ouf, this sound like better, isn't it ? Was it complicated to arrive as such result ?
    Ok, now launch the query and see the elapse time :
    104103 rows selected.
    Elapsed: 00:09:00.12
    Statistics
              0  recursive calls
              0  db block gets
        1214845  consistent gets
         272481  physical reads
              0  redo size
       11164355  bytes sent via SQL*Net to client
         257032  bytes received via SQL*Net from client
           6942  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
         104103  rows processedWoaw, developer is now very happy, less than 10 minutes instead of one hour... and without modify anything else in database and server settings, without add indexes, without add any hints...
    Ok, now the problem is in the number of returned lines. Have you see the number of return client/server ? We'll now to try to reduce this one. Increasing the number of line returned by fetch :
    set arraysize 5000
    --run the query
    104103 rows selected.
    Elapsed: 00:02:25.49
    Statistics
              0  recursive calls
              0  db block gets
        1150893  consistent gets
         271432  physical reads
              0  redo size
       11018641  bytes sent via SQL*Net to client
           1013  bytes received via SQL*Net from client
             22  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
         104103  rows processedOk, the number of retunr client/server is now low, and elapse time is ok user.

  • Query tuning and using the "better" index.

    I have a database table with about 40,000 records in it. Using
    a certain index first limits the number of rows to 11,000
    records. Using a different index first (by disabling the other
    index in the query) limits the number of rows to 2,500 records.
    Using the explain plan, the rest of the query is parsed the same
    way for both queries. What reasons can explain why when the
    index that returns 11,000 records first runs faster than
    the "better" index? I thought the whole idea behind query
    tuning is to use the index that limits the data the most.

    It looks like Oracle likes the equality condition more than the greater than -less than combination (which you might like to recode as a BETWEEN condition for clarity).
    There are a number of factors here.
    i) Are the "test names" equally distributed? Do some test names appear with greater frequency than others? If so, collecting column statistics might cause the BATCH_2 index to be used for some test names, and not for others.
    ii) Likewise, what is the distribution of cdates? How does the distribution of cdates vary by test name?
    iii) You could force the use of the BATCH_6 index over the BATCH_2 by using an optimizer hint instead of dropping the BATCH_2 index ...
    select /*+ index(batch batch_6) */ id, test, cdate
    from batch
    where test = 'Some test name'
    and cdate >= &start date&
    and cdate < &end date& + 1
    ... or even try prompting Oracle to use both indexes ...
    select /*+ index(batch batch_6) index(batch batch_2) */ id, test, cdate
    from batch
    where test = 'Some test name'
    and cdate >= &start date&
    and cdate < &end date& + 1
    ... and test the response times, then chose to use the optimizer hint in your application
    iv) You might like to replace the rather unselective BATCH_2 index with a BATCH_2_6 index on both test and cdate (in that order). That would probably give you an excellent result, and the BATCH_6 index can still be used to satisfy queries slective on cdate that are not selective on test (in very recent versions of Oracle the BATCH_2_6 index might be used for such an operation, and you could drop both BATCH_6 and BATCH_2)
    Well, see if any of this helps.

  • RE: (forte-users) Hi All....very urgent...Forte doesn'thandle La rge ar

    Okay, here's my three cents worth,
    Are you using Forte "Keep Alive" settings? If yes, you may simply have a
    time-out.
    While a partition is waiting for a reply from a database, it blocks and
    won't respond
    to anything, including pings to check if it's still alive. So, if the query
    takes longer to
    complete than the time-out period of the communication manager, then you
    will
    loose the connection to the partition.
    -----Original Message-----
    From: Aberdour George [SMTP:george.aberdourdet.nsw.edu.au]
    Sent: Sunday, February 13, 2000 11:39 AM
    To: 'Babu Raj'; kamranaminyahoo.com
    Subject: RE: (forte-users) Hi All....very urgent...Forte doesn't
    handle La rge array properly
    Hi,
    This sounds almost identical to a problem we have experienced.
    If it is the same problem it is because you have compiled a back-end
    load-balanced partition, but NOT the router that manages it.
    With such a configuration, attempts to send greater than a few thousand
    rows
    will fail - and it doesn't seem to matter what you set -fm to.
    You don't see the problem running distributed from your workspace because
    everything is interpreted.
    So just compile the router and try again.
    Hope this helps.
    George Aberdour
    (George.Aberdourdet.nsw.edu.au)
    -----Original Message-----
    From: Babu Raj [mailto:ibcsmartboyyahoo.com]
    Sent: Saturday, 12 February 2000 7:24
    To: kamranaminyahoo.com
    Subject: (forte-users) Hi All....very urgent...Forte doesn't handle
    Large array properly
    Hi All,
    Have anyone experienced problem of retrieving
    more than 1500 records from the database table, into
    the object.
    I use dynamic SQL statement, and populating Array
    object from the DBDataSet. When it runs from my
    workspace distributed, it works fine. But, when I make
    deployment, and install on the test bed, I face
    Network connection failure from the client machine. It
    looks like, server read the data from the Database,
    and while packaging it, to send it across to the
    client, server seems to run out ouf memory or couldn't
    maintain the connection with the client. I tried to
    set -fm flag on that partition, and separately setting
    FORTE_GC_SPECIAL too, but still no luck.
    we have increased, the rollback segment size on
    Oracle too, but still no luck.
    Appreciate, your suggestions, if you can,
    Thank you,
    Babu
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com

    Okay, here's my three cents worth,
    Are you using Forte "Keep Alive" settings? If yes, you may simply have a
    time-out.
    While a partition is waiting for a reply from a database, it blocks and
    won't respond
    to anything, including pings to check if it's still alive. So, if the query
    takes longer to
    complete than the time-out period of the communication manager, then you
    will
    loose the connection to the partition.
    -----Original Message-----
    From: Aberdour George [SMTP:george.aberdourdet.nsw.edu.au]
    Sent: Sunday, February 13, 2000 11:39 AM
    To: 'Babu Raj'; kamranaminyahoo.com
    Subject: RE: (forte-users) Hi All....very urgent...Forte doesn't
    handle La rge array properly
    Hi,
    This sounds almost identical to a problem we have experienced.
    If it is the same problem it is because you have compiled a back-end
    load-balanced partition, but NOT the router that manages it.
    With such a configuration, attempts to send greater than a few thousand
    rows
    will fail - and it doesn't seem to matter what you set -fm to.
    You don't see the problem running distributed from your workspace because
    everything is interpreted.
    So just compile the router and try again.
    Hope this helps.
    George Aberdour
    (George.Aberdourdet.nsw.edu.au)
    -----Original Message-----
    From: Babu Raj [mailto:ibcsmartboyyahoo.com]
    Sent: Saturday, 12 February 2000 7:24
    To: kamranaminyahoo.com
    Subject: (forte-users) Hi All....very urgent...Forte doesn't handle
    Large array properly
    Hi All,
    Have anyone experienced problem of retrieving
    more than 1500 records from the database table, into
    the object.
    I use dynamic SQL statement, and populating Array
    object from the DBDataSet. When it runs from my
    workspace distributed, it works fine. But, when I make
    deployment, and install on the test bed, I face
    Network connection failure from the client machine. It
    looks like, server read the data from the Database,
    and while packaging it, to send it across to the
    client, server seems to run out ouf memory or couldn't
    maintain the connection with the client. I tried to
    set -fm flag on that partition, and separately setting
    FORTE_GC_SPECIAL too, but still no luck.
    we have increased, the rollback segment size on
    Oracle too, but still no luck.
    Appreciate, your suggestions, if you can,
    Thank you,
    Babu
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com

  • Help plz.... its very urgent... plz

    Hi
    This is very urgent ….
    In a table:
    Select * from source_table;
    Datagrp_Name Query
    DG1 select emp_name,Emp_id from emp (Emp table has emp_name ,emp_id and dept_id)
    DG2 select dept_name from dept (dept table has dept_id and deptname)
    Column name is: (Datagrp_Name,Query)
    There r 2 records in the table
    Now I want to load the data in the target table:
    Select * from Target;
    0 records
    desc target; (it has 3 fields)Emp_name (insert the emp_name from emp)
    Emp_id ((insert the emp_id from emp)
    Dept_name (insert dept_name from dept)
    Now I want to load data in this target table from emp and dept
    Generally we will use: select emp_name,emp_id,dept_name from emp,dept where e.dept_id=d.dept_id;
    But in this case as select query is there in the source table
    So, I want the logic how to proceed pa….
    Can anyone help me in this/

    Hi,
    >>But in this case as select query is there in the source table
    I think you need to know about EXECUTE IMMEDIATE statement.
    take a look below:
    SGMS@ORACLE10> create table query (text varchar2(50));
    Table created.
    SGMS@ORACLE10> insert into query values ('select 1000 from dual');
    1 row created.
    SGMS@ORACLE10> commit;
    Commit complete.
    SGMS@ORACLE10> select * from query;
    TEXT
    select 1000 from dual
    SGMS@ORACLE10> set serveroutput on
    SGMS@ORACLE10>
    SGMS@ORACLE10> begin
      2  declare
      3    sql_cur varchar2(50);
      4    out varchar2(50);
      5  begin
      6    select text into sql_cur from query;
      7    execute immediate (sql_cur) into out;
    8 dbms_output.put_line (sql_cur);
    9 dbms_output.put_line (out);
    10  end;
    11  end;
    12  /
    select 1000 from dual
    1000
    PL/SQL procedure successfully completed.See if this link below help you:
    http://www.dbasupport.com/oracle/ora9i/execute_immediate.shtml
    Cheers

  • Getting the tablespace name(its very urgent)

    Hi,
    Can anyone help me to get the query to find the tablespace used by the users in the database
    Its Very urgent please
    Thanks,
    Murali.V

    @Murali,
    ...the tablespace used by the users...What did you mean exactly ?
    Default tablespace doesn't say that user cannot create a table in an other tablespace.
    You can see what tablespace are used by the user's segments :
    SQL> select default_tablespace
      2  from user_users;
    DEFAULT_TABLESPACE
    PSDEFAULT
    SQL> select tablespace_name, count(*)
      2  from user_segments
      3* group by tablespace_name
    SQL> /
    TABLESPACE_NAME                  COUNT(*)
    AAAPP                                 102
    AALARGE                                 4
    ADAPP                                 429
    AMAPP                                   2
    [...]@Talifhani,
    SELECT tablespace_name FROM dba_tablespaces; This give all tablespace from database.
    Nicolas.

Maybe you are looking for

  • Dependant lovs in jsp with mysql data

    hi to all. here is my doubt How to create dependant dynamic list of values in jsp where the data comes from mysql tables.(I mean i am storing all the details in mysql tables using foreign keys etc..). Ex.:country--->state--->district--->city---> we w

  • Problem deleting music on iOS 7

    I'm sure this question has been asked before, but i can't seem to find any information to help me. A while back I bought some music from the store which I don't want anymore and I had as a matter of fact deleted it from the iPhone, then when I update

  • Opening iPhoto file from other Mac in order to extract images

    My son got his first MacBook Pro trashed several months ago. He got another, but did not port his data from the iPhoto file backed up from his first MBP. Instead, he has an iPhoto file on his new MBP and has been adding pics and movies to it. The pro

  • GR based IV Indicator do not appear in PO for Raw material

    Dear All, I am creating a PO for material with cost center . Vendor is maintained with GR based IV and ERS Indicators. If a non valuated material (i.e. with quantity update and without value update)  is used in PO , I am able to  see  Tick for GR bas

  • SAP NetWeaver 7.0 ABAP Trial Version SP12 - Request Release Error

    When i choose "release" in context menu to release the request ID: NSPK900001, the IDE show the following error: "Cannot access file [my computer name]\sapmnt\trans\tmp\NSPE900001.NSP" How do i fix it? Thanks!