Hello,
we have a question again regarding query performance.
The query:
SELECT v FROM Values v WHERE v.step.stepNumber = ?
is very slow in comparing to the query:
SELECT v FROM Values v WHERE v.stepNumber = ?
Can you explain why the first query needs so much time or do you have a hint for optimization of the query or entities?
For the first query I attached the profiling images with the bottlenecks of the query execution.
Why the compareTo() calls need so much time?
@Entity @Access (AccessType.FIELD) public class TCStep extends Identifiable { @Index private long stepNumber; @Basic private String comment; @Basic private boolean isVisible; @Basic private int numberOfDefinedValues = 0; @Basic private int lastIdentifierIndex = -1; @Deprecated @Removed (version = EPVersion.EP2_5_0) @ElementCollection private Map<Integer, String> values = new HashMap<>(); @OneToOne (fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) private Values valuesRef; }
@Index (members = {"step.stepNumber"}) @Entity @Access (AccessType.FIELD) public class Values extends Identifiable { @Index private long stepNumber; @OneToOne (fetch = FetchType.EAGER) private TCStep step; //For performance reasons, we use a list instead of a map as put operations are more expensive as the add operations //per index in the list @ElementCollection (fetch = FetchType.EAGER) private Map<Integer, String> values = new HashMap<>(); }