Kukuh Indrayana
Kukuh Indrayana

Reputation: 204

vaadin jpa container connection and performance

I want to ask another question about vaadin jpacontainer.

  1. If I had a "person" jpacontainer, bind it to a table, and then I do something like this :

    person.getItem(1).getItemProperty("name").getValue();
    person.getItem(2).getItemProperty("name").getValue();
    

    Is that mean that I open the database connection, then do query "select name from person where id = 1" then close the connection, then do the same for the next id? or the connection is always opened? or what?

  2. the person table has +- 500.000 records. If I want to update a single record like this :

    person.getItem(1).getItemProperty("name").setValue("John");
    

    It takes about 3 seconds to do that. Are there any way to do this faster?

Upvotes: 0

Views: 556

Answers (1)

Erich
Erich

Reputation: 2773

I think your question has more to do with optimizing your database and less to do with Vaadin specifically.

Is that mean that I open the database connection, then do query "select name from person where id = 1" then close the connection, then do the same for the next id? or the connection is always opened? or what?

When you initialize your JPA EntityManagerFactory you'll pass in a datasource. Your datasource is the thing that will handle connection pooling.

the person table has +- 500.000 records ... It takes about 3 seconds to do that. Are there any way to do this faster?

You should look into database ways of optimizing your performance here. Set your JPA logging to FINE and take a look at the output JPQL. You'll be able to use that as hints to what you can do to improve the performance. Maybe adding an index or examining other bottlenecks will help

Upvotes: 1

Related Questions