Reading entity beans from Glassfish too slow [message #527718] |
Fri, 16 April 2010 08:45 |
No real name Messages: 5 Registered: April 2010 |
Junior Member |
|
|
Hi all,
I'm a newbie in Eclipselink and at this time I'm doing some tests. I have created a simple project with 3-layer architecture - swing client, glassfish server and mysql database. The test is simple - in the database I've created a small table (5 columns - id and varchars) with no relations. Using netbeans 6.8 I have created an entitybean like this:
@Entity
@Table(name = "test")
@NamedQueries ...
public class Test implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
...
and a sessionbean with findAll:
public List findAll() {
return em.createNamedQuery("Test.findAll").getResultList();
}
I have inserted 10 000 rows into this table, then I've started a simple swing client on second computer (using JWS). Getting the list of the entites takes about 15 seconds.
Then I've created another method findAllNative:
public List findAllNative() {
return em.createNativeQuery("select * from test").getResultList();
}
and on the client side I have mapped the result list to my own class (is a POJO class with getters and setters). This takes about 2 seconds! (loading and mapping)
So my question is - what I'm doing wrong? I know, that the mapping slows the performance, but so much?
My env: java 1.6.0.18_b07, Netbeans 6.8, Ecplipselink 2.0.0 (v20091127-r5931), Glassfish 2.1.1 ((v2.1 Patch06)(9.1_02 Patch12)) (build b31g-fcs), connection 1Gbps, both computers are dualcores with 4GB RAM, Win XP / Win 7.
Thank you and sorry for my english, I'm not a native speaker
Thomas
[Updated on: Fri, 16 April 2010 10:08] Report message to a moderator
|
|
|
Re: Reading entity beans from Glassfish too slow [message #528148 is a reply to message #527718] |
Mon, 19 April 2010 14:18 |
|
My guess would be you have a EAGER OneToOne or ManyToOne relationship in your Test class. This requires EclipseLink to fetch each of these, one by one.
You can instead mark it LAZY, or use a "join fetch" or "batch read".
Please include the full source to your class.
Also enable logging and see what is occurring, include the SQL trace.
Also measure the server performance with the client performance. Is the server taking longer or just the client? It could be a serialization issue.
James : Wiki : Book : Blog : Twitter
|
|
|
Re: Reading entity beans from Glassfish too slow [message #528602 is a reply to message #528148] |
Wed, 21 April 2010 08:54 |
No real name Messages: 5 Registered: April 2010 |
Junior Member |
|
|
Hi,
thank you for reply!
To the first point - there is no relationship, the whole entityclass:
@Entity
@Table(name = "test")
@NamedQueries(...)
public class Test implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
@Basic(optional = false)
@Column(name = "param1")
private String param1;
@Basic(optional = false)
@Column(name = "param2")
private String param2;
@Basic(optional = false)
@Column(name = "param3")
private String param3;
@Basic(optional = false)
@Column(name = "param4")
private String param4;
@Lob
@Column(name = "param5")
private String param5;
... // getters and setters
}
I have made some measurements and I think the problem is in the deserialization on client side, because:
- it's only 9 MB of data transported through network, which is very fast -> sending data to client takes only 2 seconds
- after the data are received, the client cpu load goes to 50% (it's dualcore, so I think one whole core is used) for the rest of time...
- at this time I don't set the data to the gui, so there is no gui delay (only a "done" message with time is showed)
The call of the session bean on client side:
Context c = new InitialContext();
return (TestSessionRemote) c.lookup("java:comp/env/TestSessionBean");
The client contains the ejb jar, so it has access to ejb classes.
Is there any way for tunning the deserialization of the entity beans? I don't understand, why it takes needs so much performance on client side.
Thomas
|
|
|
|
Powered by
FUDForum. Page generated in 0.02907 seconds