Commit 3602bb57 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

split search for data overlay entries into two separate queries (performance issue)

parent 5156610b
Pipeline #51132 passed with stage
in 13 minutes and 48 seconds
......@@ -101,7 +101,7 @@ public class DataOverlayDao extends BaseDao<DataOverlay> {
+ " entry left join entry.compartments compartment left join entry.miriamData entry_miriam, "
+ Element.class.getSimpleName() + " element left join element.miriamData element_miriam"
+ " where element.model in :maps and entry.dataOverlay.id = :overlayId "
+ " and (lower(element.name) = lower(entry.name) or entry.name ='') "
+ " and (%ELEMENT_NAME_PART%) "
+ " and (lower(element.model.name) = lower(entry.modelName) or entry.modelName='' or entry.modelName is null) "
+ " and (entry_miriam is null or (entry_miriam.dataType = element_miriam.dataType and lower(entry_miriam.resource) = lower(element_miriam.resource)) ) "
+ " and (compartment is null or"
......@@ -113,15 +113,24 @@ public class DataOverlayDao extends BaseDao<DataOverlay> {
}
queryString += " group by entry, element";
org.hibernate.query.Query<?> query = getSession()
.createQuery(queryString)
org.hibernate.query.Query<?> query1 = getSession()
.createQuery(queryString.replace("%ELEMENT_NAME_PART%", "lower(element.name) = lower(entry.name) and entry.name <>''"))
.setParameter("maps", maps)
.setParameter("overlayId", overlayId);
if (elementIdentifiers.size() > 0) {
query.setParameter("elementId", elementIdentifiers);
query1.setParameter("elementId", elementIdentifiers);
}
List<?> list = query.list();
org.hibernate.query.Query<?> query2 = getSession()
.createQuery(queryString.replace("%ELEMENT_NAME_PART%", "entry.name =''"))
.setParameter("maps", maps)
.setParameter("overlayId", overlayId);
if (elementIdentifiers.size() > 0) {
query2.setParameter("elementId", elementIdentifiers);
}
List<Object> list = new ArrayList<>(query1.list());
list.addAll(query2.list());
return list;
}
......@@ -161,7 +170,7 @@ public class DataOverlayDao extends BaseDao<DataOverlay> {
+ " entry left join entry.compartments compartment left join entry.miriamData entry_miriam, "
+ Reaction.class.getSimpleName() + " reaction left join reaction.miriamData reaction_miriam"
+ " where reaction.model in :maps and entry.dataOverlay.id = :overlayId "
+ " and (lower(reaction.name) = lower(entry.name) or entry.name ='') "
+ " and (%REACTION_NAME_PART%) "
+ " and (lower(reaction.model.name) = lower(entry.modelName) or entry.modelName='' or entry.modelName is null) "
+ " and (entry_miriam is null or (entry_miriam.dataType = reaction_miriam.dataType and lower(entry_miriam.resource) = lower(reaction_miriam.resource)) ) "
+ " and (lower(reaction.idReaction) = lower(entry.elementId) or entry.elementId='' or entry.elementId is null) ";
......@@ -171,16 +180,26 @@ public class DataOverlayDao extends BaseDao<DataOverlay> {
queryString += " group by entry, reaction";
org.hibernate.query.Query<?> query = getSession()
.createQuery(queryString)
org.hibernate.query.Query<?> query1 = getSession()
.createQuery(queryString.replace("%REACTION_NAME_PART%", "lower(reaction.name) = lower(entry.name) and entry.name <>''"))
.setParameter("maps", maps)
.setParameter("overlayId", overlayId);
if (reactionIdentifiers.size() > 0) {
query1.setParameter("reactionId", reactionIdentifiers);
}
org.hibernate.query.Query<?> query2 = getSession()
.createQuery(queryString.replace("%REACTION_NAME_PART%", "entry.name =''"))
.setParameter("maps", maps)
.setParameter("overlayId", overlayId);
if (reactionIdentifiers.size() > 0) {
query.setParameter("reactionId", reactionIdentifiers);
query2.setParameter("reactionId", reactionIdentifiers);
}
List<?> list = query.list();
List<Object> list = new ArrayList<>(query1.list());
list.addAll(query2.list());
return list;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment