-->
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: Slow query - every 10 records something delays the progress
PostPosted: Tue Oct 05, 2010 7:09 pm 
Newbie

Joined: Tue Oct 05, 2010 6:38 pm
Posts: 1
Hi all,

I ran several tests with em.createNativeQuery, where I select 1000 records from a table in Oracle.
The query takes about 10s to finish.

The same query run in pl/sql developer takes about 2.0 seconds. This is a massive difference.
As you see in the trace, there are delays of about 100ms. They appear always at the same place and always after 10 records.

Any help highly appreciated.

Wolfgang

2010-10-06 00:52:36,707 TRACE [org.hibernate.type.StringType] returning '172.27.9.25' as column: IP_STRING
2010-10-06 00:52:36,707 DEBUG [org.hibernate.loader.Loader] result set row: 497
2010-10-06 00:52:36,707 DEBUG [org.hibernate.loader.Loader] result row:
2010-10-06 00:52:36,707 TRACE [org.hibernate.type.StringType] returning 'Video Device-000456' as column: ID
2010-10-06 00:52:36,707 TRACE [org.hibernate.type.StringType] returning 'xxx' as column: LABEL
2010-10-06 00:52:36,707 TRACE [org.hibernate.type.StringType] returning 'Tabletop_HDX 4002' as column: TYPE
2010-10-06 00:52:36,707 TRACE [org.hibernate.type.StringType] returning 'Polycom' as column: MANUFACTURER
2010-10-06 00:52:36,707 TRACE [org.hibernate.type.StringType] returning 'Table Top' as column: DEVICE_SUBTYPE
2010-10-06 00:52:36,707 TRACE [org.hibernate.type.StringType] returning null as column: DEBUGMESSAGE
2010-10-06 00:52:36,707 TRACE [org.hibernate.type.DateType] returning null as column: DISTRIBUTIONDATE
2010-10-06 00:52:36,707 TRACE [org.hibernate.type.StringType] returning '172.27.9.26' as column: IP_STRING
2010-10-06 00:52:36,707 DEBUG [org.hibernate.loader.Loader] result set row: 498
2010-10-06 00:52:36,707 DEBUG [org.hibernate.loader.Loader] result row:
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning 'Video Device-000457' as column: ID
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning 'xxx' as column: LABEL
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning 'Tabletop_HDX 4002' as column: TYPE
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning 'Polycom' as column: MANUFACTURER
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning 'Table Top' as column: DEVICE_SUBTYPE
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning null as column: DEBUGMESSAGE
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.DateType] returning null as column: DISTRIBUTIONDATE
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning '172.27.9.27' as column: IP_STRING
2010-10-06 00:52:36,708 DEBUG [org.hibernate.loader.Loader] result set row: 499
2010-10-06 00:52:36,708 DEBUG [org.hibernate.loader.Loader] result row:
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning 'Video Device-000458' as column: ID
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning 'xxx' as column: LABEL
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning 'Tabletop_VSX 3002' as column: TYPE
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning 'Polycom' as column: MANUFACTURER
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning 'Table Top' as column: DEVICE_SUBTYPE
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning null as column: DEBUGMESSAGE
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.DateType] returning null as column: DISTRIBUTIONDATE
2010-10-06 00:52:36,708 TRACE [org.hibernate.type.StringType] returning '172.27.33.11' as column: IP_STRING
2010-10-06 00:52:36,817 DEBUG [org.hibernate.loader.Loader] result set row: 500

2010-10-06 00:52:36,817 DEBUG [org.hibernate.loader.Loader] result row:
2010-10-06 00:52:36,817 TRACE [org.hibernate.type.StringType] returning 'Vi


Top
 Profile  
 
 Post subject: Re: Slow query - every 10 records something delays the progress
PostPosted: Fri Oct 08, 2010 5:12 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
I ran several tests with em.createNativeQuery, where I select 1000 records from a table in Oracle.
The query takes about 10s to finish.
The same query run in pl/sql developer takes about 2.0 seconds. This is a massive difference.


Does pl/sql developer also show the 1000 records within this 2.0 seconds?
I ask you this, because there are 2 different measures in querying which often are confound:
1. The first measure is the time which the database takes to execute the query and to build up the result set.
Some sql-tool show only this measure (for pl/sql developer I don't know how it behavior is)
2. The second measure is the time it takes to fetch the result-set from the database to your client.
On large result set the fetching of the data takes more time than building up the result set in the database engine.
In Hibernate the returned relational data must be transformed in java objects (OR-mapping) so this takes a little more time.
Consider also that the enabled Tracing itself consumes considerable time.

Quote:
As you see in the trace, there are delays of about 100ms. They appear always at the same place and always after 10 records.


This delays indeed are suspicious. Can it be that there are Full garbage collections starting each 10 seconds?
If not I suggest you to try to create some stack-traces while this delays (see jstack command),
and to look at this stacks. You can also report them here, so we can see together what the application right is doing
while this 100ms gaps.


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.