forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-24944 Mysql Optimizer bug in forums
This is an issue with the MYSQL Optimizer where a bad plan is cached and performance is greatly affected. It is generally not a good idea to override a DB's optimzer but this issue has created enough problems to warrant its addition.
- Loading branch information
Showing
3 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1496,6 +1496,9 @@ public int getNumModTopicCurrentUserHasModPermForWithPermissionLevel(final List | |
|
||
LOG.debug("getNumModTopicCurrentUserHasModPermForWithPermissionLevel executing with membershipItems: " + membershipList); | ||
|
||
// hibernate will not like an empty list so return 0 | ||
if (membershipList.isEmpty()) return 0; | ||
|
||
HibernateCallback hcb = new HibernateCallback() { | ||
public Object doInHibernate(Session session) throws HibernateException, SQLException { | ||
Query q = session.getNamedQuery(QUERY_GET_NUM_MOD_TOPICS_WITH_MOD_PERM_BY_PERM_LEVEL); | ||
|
@@ -1517,9 +1520,29 @@ public int getNumModTopicCurrentUserHasModPermForWithPermissionLevelName(final L | |
|
||
LOG.debug("getNumModTopicCurrentUserHasModPermForWithPermissionLevelName executing with membershipItems: " + membershipList); | ||
|
||
// hibernate will not like an empty list so return 0 | ||
if (membershipList.isEmpty()) return 0; | ||
|
||
HibernateCallback hcb = new HibernateCallback() { | ||
public Object doInHibernate(Session session) throws HibernateException, SQLException { | ||
Query q = session.getNamedQuery(QUERY_GET_NUM_MOD_TOPICS_WITH_MOD_PERM_BY_PERM_LEVEL_NAME); | ||
Query q = null; | ||
if ("mysql".equals(serverConfigurationService.getString("[email protected]"))) { | ||
q = session.createSQLQuery("select straight_join count(*) as NBR " + | ||
"from MFR_AREA_T area " + | ||
"inner join MFR_OPEN_FORUM_T openforum on openforum.surrogateKey=area.ID inner " + | ||
"join MFR_TOPIC_T topic on topic.of_surrogateKey=openforum.ID " + | ||
"inner join MFR_MEMBERSHIP_ITEM_T membership on topic.ID=membership.t_surrogateKey, " + | ||
"MFR_PERMISSION_LEVEL_T permission " + | ||
"where area.CONTEXT_ID = :contextId " + | ||
"and topic.MODERATED = true " + | ||
"and (membership.NAME in ( :membershipList ) " + | ||
"and permission.MODERATE_POSTINGS = true " + | ||
"and permission.TYPE_UUID <> :customTypeUuid " + | ||
"and permission.NAME=membership.PERMISSION_LEVEL_NAME)") | ||
.addScalar("NBR", Hibernate.INTEGER); | ||
} else { | ||
q = session.getNamedQuery(QUERY_GET_NUM_MOD_TOPICS_WITH_MOD_PERM_BY_PERM_LEVEL_NAME); | ||
} | ||
q.setParameterList("membershipList", membershipList); | ||
q.setParameter("contextId", getContextId(), Hibernate.STRING); | ||
q.setParameter("customTypeUuid", typeManager.getCustomLevelType(), Hibernate.STRING); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters