プロジェクト

全般

プロフィール

Vote #80542

未完了

Distinct can be removed due to unique constraint in database

Admin Redmine さんが約2年前に追加.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
-
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
0
version_id:
0
issue_org_id:
32612
author_id:
306584
assigned_to_id:
0
comments:
0
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

Hi, we are a research team that aims to detect and fix performance and data constraints problems in application built upon ORM framework, such as Rails. Redmine provides us with a good platform.

There are two queries can be improved by removing the distinct keyword based on the unique constraint created in database.

@principals ||= Principal.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).distinct

 @users ||= User.active.joins(:members).where("#{Member.table_name}.project_id = ?", 

constraint is redmine/db/migrate/20101104182107_add_unique_index_on_members.rb
add_index :members, [:user_id, :project_id], :unique => true

which means (user_id, project_id) will be unique. so this will make above two queries return distinct results without the distinct call.

表示するデータがありません

他の形式にエクスポート: Atom PDF

いいね!0