<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I have been using Hibernate since January 2011, but more recently I
am integrating things into some UI. For some context I have an
application that deals with libraries of colors.<br>
<br>
Our current application stores the libraries in XML files under
Castor on the local file system. A given library has 2,000 colors in
it and takes maybe 200 ms to load.<br>
<br>
My JPA framework looks something like<br>
<br>
@Entity Library - m2m - @Entity Color - m2m - @Entity Representation
(i.e. L*a*b*)<br>
<br>
In my application, loading from a PostgreSQL database via Hibernate
the same data takes<br>
<ol>
<li>20 seconds to load with full logging enabled</li>
<li>16 seconds to load with logging disabled</li>
<li>4 seconds to reload a second time (probably due the default
caching behavior)</li>
<li>0.2 seconds from via SQL from PostgreSQL<br>
</li>
<li>0.2 seconds to load from Castor<br>
</li>
<li>0 seconds (usually) if I use SoftReferences to cache the data
in memory</li>
</ol>
Some of my questions are:<br>
<ol>
<li>Is the performance I am seeing typical? Is it what most people
would agree to expect from using Hibernate with a DBMS like
PostgreSQL?</li>
<li>When logging is turned on, I see what looks like an obscene
amount of SQL produced for only 2,000 colors. When logging is
turned off, 16 seconds still seems like an awfully long time to
load 2,000 color representations, where running an SQL query to
extract the same data takes 203 ms.</li>
<li>What exactly is taking so long? Using Hibernate I basically
load the library object, then iterate over all the colors it
has, then for each color object I get the representation object
and load the L*a*b* data into the UI.</li>
<li>Am I making some lame newbie mistake somewhere, and what would
that mistake be?</li>
<li>Should I be formulating an appropriate HQL statement, similar
to my SQL statement, and loading things that way?</li>
<li>Is there some documentation on using Hibernate with Graphical
User Interfaces, or some best practices documentation somewhere?<br>
</li>
</ol>
Cheers, Eric<br>
</body>
</html>