Project

General

Profile

Actions

Patch #36503

closed

Reduce extra queries in IssueQuery.default

Added by Go MAEDA almost 3 years ago. Updated over 2 years ago.

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

0%

Estimated time:

Description

The attached patch reduces the total number of SQL queries during the execution of IssueQuery.default.

No default queries in any levels:

before:

  UserPreference Load (0.2ms)  SELECT "user_preferences".* FROM "user_preferences" WHERE "user_preferences"."user_id" = ? LIMIT ?  [["user_id", 1], ["LIMIT", 1]]
  ↳ app/models/user.rb:394:in `pref'
  IssueQuery Load (0.1ms)  SELECT "queries".* FROM "queries" WHERE "queries"."type" = ? AND "queries"."id" IS NULL LIMIT ?  [["type", "IssueQuery"], ["LIMIT", 1]]
  ↳ app/models/issue_query.rb:83:in `default'
  Setting Load (0.1ms)  SELECT "settings".* FROM "settings" WHERE "settings"."name" = ? ORDER BY "settings"."id" DESC LIMIT ?  [["name", "default_issue_query"], ["LIMIT", 1]]
  ↳ app/models/setting.rb:360:in `find_or_default'
  IssueQuery Load (0.1ms)  SELECT "queries".* FROM "queries" WHERE "queries"."type" = ? AND "queries"."id" = ? LIMIT ?  [["type", "IssueQuery"], ["id", nil], ["LIMIT", 1]]
  ↳ app/models/issue_query.rb:86:in `default'

after:

  UserPreference Load (0.1ms)  SELECT "user_preferences".* FROM "user_preferences" WHERE "user_preferences"."user_id" = ? LIMIT ?  [["user_id", 1], ["LIMIT", 1]]
  ↳ app/models/user.rb:394:in `pref'
  Setting Load (0.1ms)  SELECT "settings".* FROM "settings" WHERE "settings"."name" = ? ORDER BY "settings"."id" DESC LIMIT ?  [["name", "default_issue_query"], ["LIMIT", 1]]
  ↳ app/models/setting.rb:360:in `find_or_default'

A project-level default query defined:

before:

  UserPreference Load (0.2ms)  SELECT "user_preferences".* FROM "user_preferences" WHERE "user_preferences"."user_id" = ? LIMIT ?  [["user_id", 1], ["LIMIT", 1]]
  ↳ app/models/user.rb:394:in `pref'
  IssueQuery Load (0.2ms)  SELECT "queries".* FROM "queries" WHERE "queries"."type" = ? AND "queries"."id" IS NULL LIMIT ?  [["type", "IssueQuery"], ["LIMIT", 1]]
  ↳ app/models/issue_query.rb:83:in `default'
  IssueQuery Load (0.2ms)  SELECT "queries".* FROM "queries" WHERE "queries"."type" = ? AND "queries"."id" = ? LIMIT ?  [["type", "IssueQuery"], ["id", 4], ["LIMIT", 1]]
  ↳ app/models/issue_query.rb:85:in `default'

after:

  UserPreference Load (0.2ms)  SELECT "user_preferences".* FROM "user_preferences" WHERE "user_preferences"."user_id" = ? LIMIT ?  [["user_id", 1], ["LIMIT", 1]]
  ↳ app/models/user.rb:394:in `pref'
  IssueQuery Load (0.2ms)  SELECT "queries".* FROM "queries" WHERE "queries"."type" = ? AND "queries"."id" = ? LIMIT ?  [["type", "IssueQuery"], ["id", 4], ["LIMIT", 1]]
  ↳ app/models/issue_query.rb:87:in `default'


Files


Related issues

Related to Redmine - Feature #7360: Issue custom query: default query per instance, project and userClosedGo MAEDA2011-01-18

Actions
Copied to Redmine - Patch #37135: Reduce extra queries in ProjectQuery.defaultClosedMarius BĂLTEANU

Actions
Actions

Also available in: Atom PDF