-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Auslesen von Datensaetzen und Collections ist extrem langsam
PostPosted: Fri Sep 16, 2005 6:35 am 
Newbie

Joined: Mon Mar 07, 2005 5:29 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.17c
Mapping documents:
Code:
<hibernate-mapping package="com.test.db">

   <class name="Data" table="ReceivedData" >

      <id name="id" column="UID" type="long" >
         <generator class="native"/>
      </id>

      <property name="dataOId">
         <column name="OID"/>
      </property>

      <property name="timestamp">
         <column name="TIMESTAMP"/>
      </property>

      <list name ="varBindings" table="ReceivedData_VarBindings">
         <key column="dataid"/>
         <index column="uid"/>
         <composite-element class="VarBindingData">
            <property name="oid"/>
            <property name="value"/>
            <property name="dataType"/>
         </composite-element>
      </list>

   </class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Code:

// Erster Durchlauf (alle bisherigen Eintrage auslesen)
this.searchTime = 0;

....

// Startzeit der Abfrage
long startTime = System.currentTimeMillis();

// Transaktion beginnen (damit ResultSet nicht immer das selbe ist)
Transaction tx = session.beginTransaction();

// Anzahl aller Eintraege der Data-Tabelle
Query query = session.createQuery(
   "from Data where timestamp > :sinceTimestamp" );

// Parameter versorgen
query.setLong( "sinceTimestamp", searchTime );

// Abfrage zu Liste umwandeln
List dataList = query.list();

// Beenden der Transaktion
tx.commit();

// Anzahl der ausgelesenen Datensaetze ermitteln
int rows = dataList.size();

// Wenn neue Datensaetze ausgelesen wurden
if( rows > 0 )
{
    Data lastEntry = (Data) dataList.get( rows -1 );
    this.searchTime = lastEntry.getTimestamp();
}

// Endezeitpunkt der Abfrage[/b] merken
[b]long endTime = System.currentTimeMillis();[/b]

if( rows > 0 )
{
    System.out.println( "<" +rows +"> neue Daten ausgelesen!" );
}

System.out.println(
"Dauer: searchNewData <" + (endTime - startTime) +">" );


Das Auslesen in der Tabelle fuer die Daten (sind 175 Eintraege und der zugehoerigen
Bindings 889 Eintraege) dauert 20-30 Sekunden.
Welche Fehler mache ich das die Performance so schlecht ist?

Sollte ich statt einer List ein Set, oder Bag verwenden?

thx


Top
 Profile  
 
 Post subject: Problem gefunden!
PostPosted: Fri Sep 16, 2005 9:22 am 
Newbie

Joined: Mon Mar 07, 2005 5:29 am
Posts: 8
Fuer Hibernate war der TraceLevel in der Log4j Konfiguration auf DEBUG!

Habs auf ERROR gesetzt und jetzt dauertn die Abfragen einen Bruchteil der Zeit!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.