Home » Support » Forum » Performance in SELECT statement

Performance in SELECT statement

#1

Hello,

I have the following 2 entities :

@Entity
public class TestEntity implements LocalEntity
{
    @Id
    @GeneratedValue
    private Long key;
    private Long clientKey;
    private String text1;
    private String text2;
    private String text3;
    private String text4;
    private String text5;
    private Object value; // for now just Double values

    @Index
    private long timestamp;

    @Embedded
    private State state;

    ... getter/setters ...
}

@Embeddable
public class State
{
    private Long lastProcessingDate;
    private int processingCount;

    @Enumerated(EnumType.ORDINAL)
    @Index
    private EntityState entityState;

    ... getters / setters ...
}

when I query by the "state" field in TestEntity it tooks several seconds to retrieve the objects (around 5s) and I
think I do something wrong because it's so slow. (DB has around 30.000 rows)

Example query looks like :

String strSelect = "SELECT e FROM TestEntity WHERE e.state.entityState IN :state";

TypedQuery<TestEntity> query = em.createQuery(strSelect, TestEntity.class);   
query.setParameter("state", EnumSet.of(State.NEW, State.ACKNOWLEDGED));

List<TestEntity> results = query.getResultList();

I would be very happy if someone could give me a hint why this query tooks so long.

edit: I just tried to remove the second entity completely and integrate its 3 variables directly in the TestEntity...
but it makes no difference.

edit2: persisting values is also very slow (5-6s for 30.000 inserts). Environment is JBoss Wildfly 9.0.2. Classes are enhanced...

regards,

paddy

#2

The index definition is invalid. You cannot define an index directly on a field of embeddable class. Define a path index on TestEntity instead:

@Entity
@Index(members={"state.entityState"})
public class TestEntity implements LocalEntity

Please create a separate thread regarding the persisting performance and provide more details and sample code.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3

The index thing did the trick! Thank you... I will post another thread for the performance issue

regards!


Post Reply

To post a reply and/or subscribe to update notifications - please login