Prepared Statement too fast?

I have an app that performs thousands of inserts at a time via prepared statements. A batch of insert statements could contain 100's to 10,000's of insert statements in it. When a batch is completed, an execute batch is performed. Now when our users started moving to more data to process they said that the database locked up and they had to restart it( Informix 9.3 using the JDBC driver from IBM ). I switched to using standard executeUpdate() statements and they have not reported any problems yet, but could the prepared statement cause such a problem with the database? I have made sure that the preparedstatement is called once and closed at the end and I have not encountered this problem on my machine, but since my code was the only thing running at the time, I have to assume it was something that I am doing.
One thing to note:
I am inserting into a table that has over a million rows in it and contains about 7 indexes. I know doing an insert on such a big table that is heavily indexed could slow it down, but not to a point that its locking the database.
I do not know how prepared statements send the insert commands to the database, but could they be sent too many at a time and cause a flood of commands to overload the database?
We are evaluating a JDBC driver from a commercial vendor( DataDirect ). Could a more commercial JDBC driver implement this kind of load more efficiently?
Any information would be helpful. Thanks.

That sounds ok unless each item was big (no blobs right?)Correct. all primitive types except for two date values.
There are two possible scenarios. One there were
other processes running which is how the knew exactly
when the server locked up. Two there were no other
processes running so all they know is that it locked
up either during or after your process. If your
process completed then it has nothing to do with your
process. Or does your process run continually (if so
then why would it have not failed before?)It does not run as a daemon, but this process could take several hours. A good run will take 2 hours to process 250,000 source records. The reason they were checking the database is because without proper indexing, this process took over 24 hours. When I first wrote the app, I made the rookie mistake of putting the prepared statements in a while loop and what that did is create soo many locks that it overwhelmed the system, so the customer got use to checking for that to make sure that still was not an issue. I do not do that anymore, but they still check and if there is a locking issue, my code still gets the blame. Also keep in mind I have their production database here and I run the code on my machine and do not get any problems. My main reason for asking these questions is so I don't kill myself trying to figure out why their database is locking up and putting the blame in the wrong place. I rewrote the insert statements to fix the problem when I was not even sure the prepared statements was the problem. I was just checking to see if anyone out here has noticed any problems with using prepared statements at such a high volume.

Similar Messages

  • Proving prepared statements are being reused

    How can I prove that a prepared statement from a JDBC driver is being reused / pooled ?
    What essentially I want to do is to have prepared statements reused to reduce hard parsing ... but I also need to prove that the statements are being reused. If I query the statement in V$SQLAREA, the column PARSE_CALLS does not seem to be distinguish between hard parse and soft parse:
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/ch3204.htm#1126299
    I am only interested for now in proving the just ONE statement is being reused ... which mean that the number of hard parses is very low compared to the number of soft parses for that ONE statement.
    Regards,
    jms
    Message was edited by:
    jms

    Hi,
    No, parse calls is all soft and hard parse together. What you would see, if used absolutely correctly, would be 1 hard parse per session and many executions.
    But since v$sql is obviously not linked to v$session other than at the time of exection, you see the aggregated parse calls and executions for each cursor. So what you should see is parse calls go up relatively slowly to the number of exections.
    However, you can see soft and hard parses using the v$sesstat and v$statname views so you can see soft and hard parses on a session by session basis, be these are again aggregated, so you can't see soft / hard counts per cursor, only the total for a session.
    What I see a lot of the time is they don't get it quite right, so hard parses is low but soft parses are high, so they are still parsing when they don't need to, but at least they are binding and using shareable SQL, which is a step in the right direction.
    When I say 'they', it is a generic reference to all Java/.Nyet programmers writing front end code where they just don't 'get' parsing and binding because it's just too complicated and hey, SQL Server isn't like this...!
    HTH
    Chris

  • Connection/ResultSets/Prepared Statement opening and closing

    Hi all another question that was sparked by a thread that I recently read. I believe it was duffmo who got the code from jverd. The code I am referring to is to have an open and close connection specified in a Utility or Database class. I wanted to know if there was any issues with having methods that open and close connections/result sets/ preparedStatements. Currently I am putting the finally blocks inside each of my methods. There is obvious benefits to putting the methods in a class on their own (namely code re-use) but I wanted to know if there are any dangers. (This may seem like a dumb question, but I've found from experience it's the things that you don't know that will cost you loads of time).
    thanks again.

    Hi all another question that was sparked by athread
    that I recently read. I believe it was duffmo who
    got the code from jverd. Generally speaking it's fine.
    But as always you may have some long term design
    issues to think about. If you build a simple
    framework that consists of one class and that does
    all that your program does then great.
    Once you start add more complexity though you'll want
    to be careful that you aren't reinventing the Spring
    wheel or even ending up implementing your own
    connection pool. Both of which, judging from posts
    here seem to happen from time to time.
    So I guess all in all, yes it's much better than
    scattering the code all about but depending on what
    you are going to be doing with it you may want to
    look at the various ORM frameworks to see if they are
    really the direction you should be going in.Thanks for the information cotton. I just wanted to make certain that it was a sensible thing to do. When I had first asked about connections I was told they should be opened an closed in the same spot, unfortunately I took that explanation a little too much to heart, and started opening and closing every connection resultset and prepared statement in each of the DAO classes that I was using.
    Guess it's going to be a bit of work to refactor, but worth it for the cleaner code that will result.

  • Why would my video clips be running too fast when played on the monitor panel?

    I posted my problem earlier today, but re-reading it maybe I didn't explain myself well enough.
    My main question is: "why would my video clips be running too fast when played on the monitor panel ?".  This is occuring after I have selected my media from the Tasks Panel and placed them in correct order in the Timeline/Sceneline.  I knew something was wrong when I could see that the clips were not indicating their right length when viewed in the (expanded) timeline.  They were compressed into just a few seconds, whereas the clips should have been at least 5 minutes.  I ran the clips in the monitor and sure enough they ran too fast, with a lot of jerking movements.
    The 3 video clips I am trying to make into a HD PAL video were taken with my Nokia N8 mobile video camera. These are in mp4 format. Can this present a problem ?  Note that when I play these individual HD clips on my computer in (Windows Media Player) they run fine.
    After I placed the clips in my Project Panel (or before in the Organize Workspace), I have perforned no change or manipulation of the clips.  They are in their original state.
    Just too confirm that the clips did seem to be compressed, I burnt a DVD, the resultant video ran in a matter of seconds.
    Help would be greatly appreciated.

    Yes, that is what the problem was.
    Although the video camera on my Nokia N8, mobile was capturing at 25fps,
    for some reason once transfered over to PrE9 (via file transfer), the clip was interpreted as 500fps.  Once in Interpret Footage I was able to change the fps to 25.
    Thanks for the help.

  • Problem in inserting to MS Access using prepared statement

    I am inserting a record in MS Access db and I am using prepared statement. I am encountering an error.... any help I would really appreciate it. So much time figuring out what the problem is....
    ConvertText contxt = new ConvertText();
    String bday = (String)cbYear.getSelectedItem() +
    cbMonth.getItemCount()+(String)cbDay.getSelectedItem();
    try{
    // load MySQL driver
    Class.forName(driver);
    // Setup connection to DBMS
    Connection conn = DriverManager.getConnection(url);
    // Create statement     
    Statement stmt     = conn.createStatement();
    PreparedStatement insertPersons = conn.prepareStatement(
            "INSERT INTO PERSONS VALUES(" +
         "FIRST_NAME               = ?," +
         "LAST_NAME              = ?," +
         "MIDDLE_NAME               = ?," +
         "NICKNAME              = ?," +
         "GENDER              = ?," +
         "MARITALSTATUS           = ?," +
         "AGE                    = ?," +
         "BIRTHDATE                   = ?," +
         "ADDRESS                  = ?," +
         "RES_PHONE_NUMBER        = ?," +
         "OFFICE_PHONE_NUMBER     = ?," +
         "CELL_NUMBER               = ?," +
         "COMPANY_NAME               = ?," +
         "EMAIL_ADDRESS               = ?," +
         "TIMESTAMP               = ?)"
              insertPersons.setString   (1, tfFirstName.getText());
              insertPersons.setString   (2, tfLastName.getText());
              insertPersons.setString   (3, tfMiddleName.getText());
              insertPersons.setString   (4, tfNickName.getText());
              insertPersons.setString   (5, (String)cbGender.getSelectedItem());
              insertPersons.setString   (6, (String)cbMaritalStatus.getSelectedItem());
              insertPersons.setInt      (7, contxt.formatStringToInt(tfAge.getText()));
              insertPersons.setDate     (8, contxt.formatStringToSQLDate(bday));
              insertPersons.setString   (9, tfAddress.getText());
              insertPersons.setString   (10,tfResPhoneNumber.getText());
              insertPersons.setString   (11,tfOffPhoneNumber.getText());
              insertPersons.setString   (12,tfCellNumber.getText());
              insertPersons.setString   (13,tfCompanyName.getText());
              insertPersons.setString   (14,tfEmailAddress.getText());
              insertPersons.setTimestamp(15, new Timestamp(System.currentTimeMillis()));          
              insertPersons.executeUpdate();
              conn.close();          
    JOptionPane.showMessageDialog(null,"Record Inserted!", "INSERT",
                        JOptionPane.INFORMATION_MESSAGE);
    }catch (SQLException ex){
    System.err.println("==> SQLException: ");
    System.out.println("Message:   SQL Exception");
    System.out.println("Message:   " + ex.getMessage ());
    System.out.println("SQLState:  " + ex.getSQLState ());
    System.out.println("ErrorCode: " + ex.getErrorCode ());
    JOptionPane.showMessageDialog(null, ex.getMessage() + ex.toString(),"Error", JOptionPane.INFORMATION_MESSAGE);
    }catch(Exception ex){
    }          ERROR Displayed:
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 30. java.sql.SQLException     

    Hi cruzdhel,
    Your SQL looks incorrect to me.
    I am not familiar with that syntax.
    I think it should be like this:
    PreparedStatement insertPersons =
    conn.prepareStatement("INSERT INTO PERSONS (FIRST_NAME," +
                                               "LAST_NAME," +
                                               "MIDDLE_NAME," +
                                               "NICKNAME," +
                                               "GENDER," +
                                               "MARITALSTATUS," +
                                               "AGE," +
                                               "BIRTHDATE," +
                                               "ADDRESS," +
                                               "RES_PHONE_NUMBER," +
                                               "OFFICE_PHONE_NUMBER," +
                                               "CELL_NUMBER," +
                                               "COMPANY_NAME," +
                                               "EMAIL_ADDRESS," +
                                               "TIMESTAMP)" +
    "values (?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?)");Hope this helps.
    Good Luck,
    Avi.

  • SetString in Prepared Statement

    Help!
    I am trying to use a prepared statement and use a setString. It seems to work when I use a value as the parameter, but when I pass it a variable I get an error. Any ideas???
    THIS WORKS.....
    String buffer;
    String selectStmt1 = "SELECT veh_key_i FROM yzdbdat.mxtp010_veh " +
    "WHERE veh_chass_no = ?";
    PreparedStatement selectVehKey = connection.prepareStatement(selectStmt1);
    selectVehKey.setString(1,"2H412152");
    ResultSet getVehicle = selectVehKey.executeQuery();
    THIS DOESN'T...I GET A RIGHT TRUNCATION ERROR
    String buffer;
    String selectStmt1 = "SELECT veh_key_i FROM yzdbdat.mxtp010_veh " +
    "WHERE veh_chass_no = ?";
    PreparedStatement selectVehKey = connection.prepareStatement(selectStmt1);
    selectVehKey.setString(1,buffer);
    ResultSet getVehicle = selectVehKey.executeQuery();
    THANKS!!

    A right truncation error? I would have expected a NullPointerException, since you haven't assigned anything to that variable. But if your real code does assign something to it, then probably it is too long to fit in the database column.

  • Prepared Statement - Help pl

    Hi!
    Is there any disadvantage in using a Prepared statement to insert records in to the database.What is the difference in using Prepared Statement compared to Statement.Any disadavantage?I know the advantage of using Prepared statement where by I can insert values with special characters.Any disadavantage of using Prepared statement regularly?Please explain.Thanks

    hello all, i like the statement that some of u guys posting here..
    i have a puzzle here, if i have more than one query to table, lets say 3rd query are depends on result of 2nd query which taken from 1st query result.
    should i use prepared statement instead of statement? can we say that using of prepared statement can make our query result faster than using statement??
    i have a function here which goes well when using statement st,
    public void getMainlevelBcat(String loggedbizid){
    String query = " SELECT DISTINCT category2.mainlevel FROM bizcategory2, category2 "+
    " WHERE bizcategory2.catid = category2.catid "+
    " AND bizcategory2.bizid ='"+loggedbizid+"' ";
    try {
    st = con.createStatement();
    rs =st.executeQuery(query);
    catch (SQLException e) {
    System.out.println(e.getMessage());
    can anybody chance it to new function using prepared statement??

  • Set char in Prepared Statement

    Hi,
    Can any one let me know how to set Character value in Prepared Statement. I have my table in which the column is of Char type. Now in my prepared statment, I am saying
    PreparedStament pstmt = con.prepareStatement("select ticker from INSTRUMENT_TICKERXREF where ticker = ? ");
    pstmt.setString(1,'F');
    I even tried pstmt.setString(1,"F");
    It gives me incompatible types. Can any please help me on this asap.
    Regards,
    ..Raj

    Hi,
    I just tried using setString(), it does not seem to give any problems. But in any case, you could use setObject() too.
    I tried both setString() and setObject for an example table structure as below:
    create table testchar(col1 CHAR(3));
    insert into testchar('one');
    from java class:
    PreparedStatement pstmt = conn.prepareStatement("select col1 from testchar where col1 = ? ");
    //pstmt.setObject(1,"one");
    pstmt.setString(1,"one");
    Hope that helps.
    Savitha.
    OTN group@IDC

  • Executiong prepared statement with Like% in SQL Query?

    Hi,
    We are developing GUI project.In which we need to retrieve the contract details based on the Name which we enter in eVision page.Here we will not enter the whole name,we will enter only the part of the name,for example if the actual name is Sun Seebeyond,I will enter only Su.So if there are five records in data base which starts the name with Su.Then it should return the five names..
    For this I am using the prepared statement as
    select name,contractid from table1 where name Like '?%'.
    Here my runtime input value will set to this parameter ?.When I execute this qry in my project I am getting error as "Unable to set parameters on the Object: Invalid parameter index 1".
    If I replace the ? with Su in query itself ,then it works fine..
    Please let me know is there any effective way,using which I can solve..
    Thanks,
    Renga.S.

    Hi,
    This option I already tried and it work fine too.
    I am looking for an option ,where we can handle with in the Query,so we dont need to write any code appending % into the actual valus.
    Thanks,
    Renga.S.

  • Prepared Statement Slow. ~Baffled~. Will the sun rise again?

    HELP! (PANIC), Disaster
    Problem?: Its slow.
    How can you help?: Explain why and make suggestions to fix it.
    NOTES:
    1) there are indices on pd_idnum and pd_nappi_product_id
    2) over 92000 records in the product table
    Code Follows:
    import java.sql.*;
    import java.text.SimpleDateFormat;
    public class DBTest
    static PreparedStatement pstmtNewNappi = null;
    ResultSet rsNappi6=null;
    Connection myConn = null;
    int pd_idnum=0;
    SimpleDateFormat sDateFmt = new SimpleDateFormat("yyyyMMdd");
    SimpleDateFormat sTimeFmt = new SimpleDateFormat("hhmmss");
    * Constructor for DBTest.
    public DBTest()
    super();
    try
    Class.forName("org.gjt.mm.mysql.Driver");
    myConn = DriverManager.getConnection(
    "jdbc:mysql://carl-lin:3306/mxprod", "carl", "lrac1234");
    pstmtNewNappi = myConn.prepareStatement(
    "SELECT pd_idnum FROM product WHERE pd_nappi_prod_id=?");
    catch(ClassNotFoundException cnfe){cnfe.printStackTrace();}
    catch(SQLException sqle){sqle.printStackTrace();}
    public boolean isNewNappi(String nappi) throws SQLException
    if(nappi != null)
    pstmtNewNappi.setInt(1, Integer.parseInt(nappi));
    System.out.println("before execute"
    +new java.util.Date().getTime());
    // This single line of code takes 2 seconds!! Why?
    rsNappi6 = pstmtNewNappi.executeQuery();
    System.out.println("after execute"
    +new java.util.Date().getTime());
    if(rsNappi6.next())
    //if im in here the nappi is not new
    pd_idnum = Integer.parseInt(rsNappi6.getString("pd_idnum"), 10);
    return false;
    return true;
    public static void main(String[] args)
    try
    DBTest dbt = new DBTest();
    boolean yes = dbt.isNewNappi("43");
    System.out.println("yes: " + yes);
    catch(SQLException sqle)
    sqle.printStackTrace();
    Maybe PreparedStatements are only fast for inserts(Forgive me for guesing)
    Any help would be greatly appreciated

    Oh that came back like lighting allright but i got my hands on some more code here that (if my reasoning is correct) suggest that I'm using the prepared statement in the wrong way, but I can still not figure out why it is wrong. The DB is not the problem and I think the code below and its output is testament to that. Now that i've got fast code, I'm still not content because I still cant see what is wrong with the original code. In order for me to keep my sanity as a programmer I HAVE to know --WHAT IS WRONG aaaargh
    Thanx for the help so far
    Dewet
    optimal code follows:
    import java.sql.*;
    public class Fix
    public static void main(String[] args)
    ResultSet prodSet = null;
    String nappi = null;
    String sql = null;
    try
    Class.forName("org.gjt.mm.mysql.Driver");
    Connection myConn = DriverManager.getConnection("jdbc:mysql://carl:3306/mxprod?user=carl&password=lrac1234");
    sql = "select pd_prod_name, pd_prod_name_mk from product where pd_nappi_prod_id = ?";
    PreparedStatement stmt2 = myConn.prepareStatement(sql);
    nappi = "43";
    for (int i= 0; i < 10; i++)
                   System.out.println(i);
    System.out.println(new java.util.Date().getTime());
    stmt2.setString(1, nappi); // Nappi
    prodSet = stmt2.executeQuery();
    if(prodSet.next())
    {*nappi found*/}     
    System.out.println(new java.util.Date().getTime());
    if (stmt2 != null) stmt2.close();
    myConn.close();
    catch( Exception e )
    e.printStackTrace();
    output:
    0
    1055320536664
    1055320536694
    1
    1055320536694
    1055320536694
    2
    1055320536704
    1055320536704
    3
    1055320536704
    1055320536714
    4
    1055320536714
    1055320536714
    5
    1055320536714
    1055320536714
    6
    1055320536724
    1055320536724
    7
    1055320536724
    1055320536724
    8
    1055320536734
    1055320536734
    9
    1055320536744
    1055320536744

  • Prepared statement cache & Oracle

    Hi -
    Does Weblogic's prepared statement caching only work when using their
    type-2 Oracle driver? Are there any documents about using this
    Weblogic feature? I have only found small references in the Weblogic
    documentation so far -- nothing with much detail.
    Thanks for any help,
    - Mark

    "Joseph Weinstein" <[email protected]> wrote in message
    news:[email protected]..
    >
    >
    Mark Cassidy wrote:
    Hi -
    Does Weblogic's prepared statement caching only work when using their
    type-2 Oracle driver?No. It is generic to JDBC. Any JDBC driver should allow re-use ofPreparedStatements,
    and our pool will cache for any driver.
    Are there any documents about using this
    Weblogic feature? I have only found small references in the Weblogic
    documentation so far -- nothing with much detail.You are correct that there is too little documentation at this time.
    Thanks for any help,
    - Mark
    Thanks Joe!
    Do you know if each connection's cache is FIFO? Or do you use
    least-recently-used algorithm?
    I found one comment you made regarding XA pools. That means that if we are
    doing 2-phase commit processing that some of these benefits could erode? I
    didn't understand why. If we assume that the connections in a given pool
    after a time get a good sampling of popular prepared statements, would their
    being XA or not matter? Maybe I missed your point entirely.
    - Mark

  • Statement and Prepared Statement

    if i write a same query with statement and preparedStatement
    like
    Select * from emp_detail where emp_id =20;
    stmt= con.createStatment();
    rs = stmt.executeQuery(query);
    and using preparedStatement
    Select * from emp_detail where emp_id =?;
    pstmt= con.prepareStatement();
    pstmt.setInt(1,20);
    rs = stmt.executeQuery(query);
    Using which statment(Statement or Prepared Statement) the data will retrive fast and why.... in these case ????

    Statement should be quicker than Prepared Statement, because
    Statment do only one thing: send that sql to server or run that sql directly.
    Prepared Statement should do two (or more than two)things:
    1. parse your sql first, prepare a store procedure, then call that store procedure.
    Or
    2. prase your sql first, then use your value to replace "?" for getting a new sql, then work like Statement.
    Prepared Statement is quiker when you use it repeatedly.

  • Prepared Statement and Stored Procedure..

    I have about 200 SQL statement in my Java application
    I have two options either to convert into
    Stored procedures
    or to convert into prepared statement ....
    Please guide me which options should be best....
    I need difference
    1)in term of speed.
    2)Memory..
    Regards
    Mahesh
    Senior DBA

    club your statements on the basis of related functionalities and change it to stored procedures as it will redudce no. of calls to the database and will be faster to fetch data in one go and even reduce the memory requirements.

  • Sql server 2000 stored procs vs. prepared statements performance

    Hi
    I have observed that using stored procedure in sql server 2000 is much much faster than using a prepared statements. I had worked with oracle before and did not notice this much difference. I would like to use prepared statements or regular sql (for dynamic sql creation) in my apps. Does anyone have any suggestions ?.
    thanks

    Hi
    FYI
    I figured out the slowness problem in using prepared statement (db - sql server 2000)was due to the Microsoft typ4 4 jdbc driver. When I used the jdbc driver from atinav, my prepared statements worked as fast as stored procs.

  • Prepared statement takes much longer than statement..

    Hi community,
    At the moment I'm trying to migrate my j2ee application from DB2 to Oracle. I'm using database version 10.2.0.3 and driver version 10.2.0.4.
    After copying all data from DB2 to Oracle, I've started testing the application with the new database. During this process, a problem occurs when using prepared statements.
    For example, when I'm trying to execute the following sql statement:
    SELECT
    LINVIN.BBASE , INVINNUM , INVINNUMALT , LINVIN.LSUPPLIERNUM , LINVIN.COMPANYCODE , ACCOUNT , INVINTXT , INVINSTS , INVINTYP , INVINDAT , RECEIPTDAT , POSTED , POSTINGDATE , CHECKCOSTCENTER , WORKFLOWIDEXT , INVINREFERENCE , RESPONSIBLEPERS , INVINSUM , INVINSUMGROSS , VOUCHERNUM , HASPOSITIONS , LSUPPLIER.AADDRLINE1
    from LINVIN, LSUPPLIER
    where LINVIN.BBASE = LSUPPLIER.BBASE
    and LINVIN.LSUPPLIERNUM = LSUPPLIER.LSUPPLIERNUM
    and LINVIN.BBASE = ? and LINVIN.INVINNUM = ?
    order by LINVIN.BBASE, LINVIN.INVINDAT DESC
    The execution time, when using a simple java.sql.Statement, amounts to 100 millis. But if I execute the same statement with a java.sql.PreparedStatement it takes about 30.000 millis.
    I tried to do a explain plan on both types with the following results:
    With java.sql.Statement:
    PLAN_TABLE_OUTPUT
    Plan hash value: 1286706273
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    PLAN_TABLE_OUTPUT
    | 0 | SELECT STATEMENT | | 1 | 225 | 4 (0)| 00:00:01 |
    | 1 | NESTED LOOPS | | 1 | 225 | 4 (0)| 00:00:01 |
    | 2 | TABLE ACCESS BY INDEX ROWID| LINVIN | 1 | 136 | 3 (0)| 00:00:01 |
    |* 3 | INDEX UNIQUE SCAN | PK_2540516 | 1 | | 2 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    | 4 | TABLE ACCESS BY INDEX ROWID| LSUPPLIER | 16922 | 1470K| 1 (0)| 00:00:01 |
    |* 5 | INDEX UNIQUE SCAN | PK_177597 | 1 | | 0 (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
    3 - access("LINVIN"."BBASE"='PRAK' AND "LINVIN"."INVINNUM"='0010344820')
    5 - access("LSUPPLIER"."BBASE"='PRAK' AND
    "LINVIN"."LSUPPLIERNUM"="LSUPPLIER"."LSUPPLIERNUM")
    With java.sql.PreparedStatement:
    PLAN_TABLE_OUTPUT
    Plan hash value: 957014775
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    PLAN_TABLE_OUTPUT
    | 0 | SELECT STATEMENT | | 37 | 8325 | | 5850 (1)| 00:01:11 |
    | 1 | MERGE JOIN | | 37 | 8325 | | 5850 (1)| 00:01:11 |
    |* 2 | TABLE ACCESS BY INDEX ROWID| LINVIN | 34 | 4624 | | 3442 (1)| 00:00:42 |
    |* 3 | INDEX FULL SCAN | LINVOICE_LSUPPLIER_FK | 3410 | | | 999 (2)| 00:00:12 |
    PLAN_TABLE_OUTPUT
    |* 4 | SORT JOIN | | 101K| 8824K| 19M| 2408 (1)| 00:00:29 |
    | 5 | INDEX FAST FULL SCAN | LSUPPLIERAL1 | 101K| 8824K| | 329 (1)| 00:00:04 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
    2 - filter(SYS_OP_C2C("LINVIN"."INVINNUM")=:2)
    3 - filter(SYS_OP_C2C("LINVIN"."BBASE")=:1)
    4 - access("LINVIN"."BBASE"="LSUPPLIER"."BBASE" AND
    "LINVIN"."LSUPPLIERNUM"="LSUPPLIER"."LSUPPLIERNUM")
    filter("LINVIN"."LSUPPLIERNUM"="LSUPPLIER"."LSUPPLIERNUM" AND
    "LINVIN"."BBASE"="LSUPPLIER"."BBASE")
    I checked the tables and the indexes and everything looks fine. I have an index over the where clause (PK), the order by clause and the join criterias. I also analyzed the tables and the indexes and also started a rebuild on them.
    Indexes table LINVIN:
    PK_2540516 --> index on LINVIN(BBASE, INVINNUM)
    LINVOICE_LSUPPLIER_FK --> index on LINVIN(BBASE, LSUPPLIERNUM)
    LINV_INVDAT --> index on LINVIN(BBASE, INVINDAT DESC)
    Indexes table LSUPPLIER:
    PK_177597 --> index on LSUPPLIER(BBASE, LSUPPLIERNUM)
    LSUPPLIERAL1 --> index on LSUPPLIER(BBASE,LSUPPLIERNUM,AADDRESSLINE1) [why is Oracle using this index, when addressline1 isn't in the statement?]
    Can somebody tell me please, why the prepared statement takes a completely different way than the normal statement and how can I get the prepared statement working like the other?
    I would really appreciated, if somebody can help me with this issue, because I'm really getting more and more distressed...
    Thanks in advance,
    Tobias

    With java.sql.Statement:
    Predicate Information (identified by operation id):
    > 3 - access("LINVIN"."BBASE"='PRAK' AND
    "LINVIN"."INVINNUM"='0010344820')> 5 - access("LSUPPLIER"."BBASE"='PRAK' AND
    >
    LINVIN"."LSUPPLIERNUM"="LSUPPLIER"."LSUPPLIERNUM")
    With java.sql.PreparedStatement:
    Predicate Information (identified by operation id):
    > 2 - filter(SYS_OP_C2C("LINVIN"."INVINNUM")=:2)
    3 - filter(SYS_OP_C2C("LINVIN"."BBASE")=:1)> 4 - access("LINVIN"."BBASE"="LSUPPLIER"."BBASE"
    AND
    LINVIN"."LSUPPLIERNUM"="LSUPPLIER"."LSUPPLIERNUM")
    ilter("LINVIN"."LSUPPLIERNUM"="LSUPPLIER"."LSUPPLIERNU
    M" AND
    "LINVIN"."BBASE"="LSUPPLIER"."BBASE")
    the tables and the indexes and everything looks fine.Notice the SYS_OP_C2C function Oracle is applying in your code with the prepared statement, it is doing this because the bind variable is not of the same data type as your column. So it's taking your column in the table, applying a function to convert it into the same data type as your bind variable (which destroys any possibility of using an index).
    If you ensure the prepared statement is binding type for type this should magically go away.

Maybe you are looking for

  • I have an ipod touch and an hp computer. i was wondering how i can play apps using itunes on my computer

    I need help as fast as possible! i downloaded an app from itunes off of my computer and i can only use it on my computer. Does anyone know how i can use it on my computer? please help!:)

  • Adding Digital Signatures to PDFs

    Hi all, Sorry if I am posting this question in the wrong location, but hopefully someone who sees this message will still be able to answer or point me in the right direction. I did perform a search and could not find a definitive answer. There are d

  • Question about using TVARV in an ABAP program

    Hello gurus, Im sorry about the silly question. I have a question about using TVARV in an ABAP program. A program is presenting a problem and I think that in this code: SELECT SIGN OPTI LOW HIGH   FROM TVARV   INTO TABLE R_1_163431035_VELOCIDADE   WH

  • F4 selection screen layout - WAD 7

    Hi guys, We have a simple selection screen over a variable and we have a couple of questions regarding the layout of the selection screen. 1. Can we change the default to "Search" instead of "All"? 2.  When we scroll down in the list the width of the

  • BottleNeck for Large Messages

    i have envelope schema which debatches the messages and delivers to messages box, but if pass 1000 messages it give bottle neck as i am calling web service. How can avoid bottle neck???  any help please