Project

General

Profile

Actions

Patch #26711

closed

Use pluck instead of collect/map

Added by jwjw yy over 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

In app/helpers/my_helpers,
68: where(:project_id => User.current.projects.map(&:id)).
Use pluck to get the id is much more efficient, since the query will only access the id field, instead of select * from projects:
Before:
SELECT `projects`.* FROM `projects` INNER JOIN `members` ON `projects`.`id` = `members`.`project_id` WHERE `members`.`user_id` = ? AND (projects.status<>9) "user_id", 5341

After:
SELECT `projects`.`id` FROM `projects` INNER JOIN `members` ON `projects`.`id` = `members`.`project_id` WHERE `members`.`user_id` = ? AND (projects.status<>9) "user_id", 5341


Related issues

Related to Redmine - Patch #26726: Use pluck(:id) instead of collect(&:id) Closed

Actions
Actions

Also available in: Atom PDF