Hello,

I have such a query:

public class Main
{
  private static final String sql=
    "SELECT  LIMIT 0 1 'eportfel.db.Transakcja' AS NUCMETADATA, "+
             "THIS.\"DATA\" AS
JPOXORDER0,THIS.DATA_NA,THIS.DATA_Z,THIS.ID AS JPOXORDER1, "+
             "THIS.KOMPOZYT_NA_BILANS,THIS.KOMPOZYT_ZBILANS, "+
             "THIS.KONTO_NA_BILANS,THIS.KONTO_ZBILANS, "+
             "THIS.KWOTA_NA,THIS.KWOTA_NA_KOMPOZYT, "+
             "THIS.KWOTA_Z,THIS.KWOTA_ZKOMPOZYT, "+
             "THIS.NETSVRACCNUMNA,THIS.NETSVRACCNUMZ, "+
             "THIS.NETSVRIDNA,THIS.NETSVRIDZ, "+
             "THIS.NETSVRKONTRNAME,THIS.NET_SVR_KWOTA_PLN, "+
             "THIS.OPIS,THIS.TYP,THIS.UZGODNIONA "+
     "FROM TRANSAKCJA THIS "+
     "WHERE ((1 = THIS.KONTO_Z_ID_KONTO_OID OR 1 =
THIS.KONTO_NA_ID_KONTO_OID)) "+
     "  AND THIS.\"DATA\" <= '2008-12-25 13:37:57.415' "+
     "ORDER BY JPOXORDER0 DESC,JPOXORDER1 DESC";

  public static void main(String[] args) throws SQLException,
ClassNotFoundException
  {
    Class.forName("org.h2.Driver");
    Connection conn=DriverManager.getConnection("jdbc:h2://home/...");
    Statement stmt=conn.createStatement();
    stmt.execute(sql);
    conn.close();
  }
}

If I run above code, the query execution lasts about 5 to 6 seconds. I
run it in debugger and almost all this time is taken by stmt.execute
(sql) statement.

However if I take the query text (exactly the same) and run it via
database IDE tool like NetBeans or H2 console, the query execution is
much faster - about half to 1 second.

I came to this problem by trying to optimize my application which
works slowly in some cases.

What could be the reason that causes the code to be slow and H2
console to be fast? How can I simulate the way in which H2 console
executes the query so I can see what is the difference?

Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to