View Issue Details

IDProjectCategoryView StatusLast Update
0023904mantisbtperformancepublic2019-01-07 17:16
ReporterbcuestaAssigned Tocproensa 
PrioritynormalSeveritymajorReproducibilityalways
Status assignedResolutionopen 
Product Version2.2.0 
Target VersionFixed in Version 
Summary0023904: Massive queries to user table in edit project
Description

Entering edit project page (manage_proj_edit_page.php) launch a sql for each user assigned to the project for getting email. In private projects with many users assigned, this cause performance problems.
The solution is simple. Get email for all users in "project_get_all_user_rows()" and use it.

TagsNo tags attached.

Activities

bcuesta

bcuesta

2018-01-28 15:33

reporter   ~0058644

I suggest apply the attachment patch. I revolved the problem with it.



fix_projedit_massivequeries_1.0.0.diff (1,748 bytes)
diff --git a/mantisbt/2.2.0/core/project_api.php b/mantisbt/2.2.0/core/project_api.php
index bf42e9a..4a97e91 100644
--- a/mantisbt/2.2.0/core/project_api.php
+++ b/mantisbt/2.2.0/core/project_api.php
@@ -703,7 +703,7 @@ function project_get_all_user_rows( $p_project_id = ALL_PROJECTS, $p_access_leve
 
 	if( $p_include_global_users ) {
 		db_param_push();
-		$t_query = 'SELECT id, username, realname, access_level
+		$t_query = 'SELECT id, username, realname, access_level, email
 				FROM {user}
 				WHERE enabled = ' . db_param() . '
 					AND access_level ' . $t_global_access_clause;
@@ -717,7 +717,7 @@ function project_get_all_user_rows( $p_project_id = ALL_PROJECTS, $p_access_leve
 	if( $c_project_id != ALL_PROJECTS ) {
 		# Get the project overrides
 		db_param_push();
-		$t_query = 'SELECT u.id, u.username, u.realname, l.access_level
+		$t_query = 'SELECT u.id, u.username, u.realname, l.access_level, u.email
 				FROM {project_user_list} l, {user} u
 				WHERE l.user_id = u.id
 				AND u.enabled = ' . db_param() . '
diff --git a/mantisbt/2.2.0/manage_proj_edit_page.php b/mantisbt/2.2.0/manage_proj_edit_page.php
index 309b41c..1928f41 100644
--- a/mantisbt/2.2.0/manage_proj_edit_page.php
+++ b/mantisbt/2.2.0/manage_proj_edit_page.php
@@ -768,8 +768,9 @@ event_signal( 'EVENT_MANAGE_PROJECT_PAGE', array( $f_project_id ) );
 				</td>
 				<td>
 				<?php
-					$t_email = user_get_email( $t_user['id'] );
-					print_email_link( $t_email, $t_email );
+					// FIXED: Evitar consulta masiva innecesaria
+					// $t_email = user_get_email( $t_user['id'] );
+					print_email_link( $t_user['email'], $t_user['email'] );
 				?>
 				</td>
 				<td><?php echo get_enum_element( 'access_levels', $t_user['access_level'] ) ?></td>
cproensa

cproensa

2019-01-07 17:16

developer   ~0061161

PR https://github.com/mantisbt/mantisbt/pull/1436

Issue History

Date Modified Username Field Change
2018-01-28 12:18 bcuesta New Issue
2018-01-28 15:33 bcuesta File Added: fix_projedit_massivequeries_1.0.0.diff
2018-01-28 15:33 bcuesta Note Added: 0058644
2019-01-07 17:16 cproensa Assigned To => cproensa
2019-01-07 17:16 cproensa Status new => assigned
2019-01-07 17:16 cproensa Note Added: 0061161