Project

General

Profile

Actions

Feature #44407

open

Preload the attachment authors when rendering a single issue in the REST API

Added by Go MAEDA 1 day ago. Updated about 12 hours ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Performance
Target version:
Resolution:

Description

show.api.rsb renders the author of every attachment of the issue, causing an author lookup for each attachment.

  Attachment Load (0.1ms)  SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC  [["container_id", 3], ["container_type", "Issue"]]
  ↳ app/views/issues/show.api.rsb:37
  CACHE User Load (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN (?, ?) AND "users"."id" = ? LIMIT ?  [["type", "User"], ["type", "AnonymousUser"], ["id", 2], ["LIMIT", 1]]
  ↳ app/helpers/attachments_helper.rb:85:in 'AttachmentsHelper#render_api_attachment_attributes'
  CACHE User Load (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN (?, ?) AND "users"."id" = ? LIMIT ?  [["type", "User"], ["type", "AnonymousUser"], ["id", 2], ["LIMIT", 1]]
  ↳ app/helpers/attachments_helper.rb:85:in 'AttachmentsHelper#render_api_attachment_attributes'
  CACHE User Load (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN (?, ?) AND "users"."id" = ? LIMIT ?  [["type", "User"], ["type", "AnonymousUser"], ["id", 2], ["LIMIT", 1]]
  ↳ app/helpers/attachments_helper.rb:85:in 'AttachmentsHelper#render_api_attachment_attributes'
  CACHE User Load (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN (?, ?) AND "users"."id" = ? LIMIT ?  [["type", "User"], ["type", "AnonymousUser"], ["id", 2], ["LIMIT", 1]]
  ↳ app/helpers/attachments_helper.rb:85:in 'AttachmentsHelper#render_api_attachment_attributes'

The patch loads all attachment authors with a single query. Requests without include=attachments are not affected.

  Attachment Load (0.1ms)  SELECT "attachments".* FROM "attachments" WHERE "attachments"."container_id" = ? AND "attachments"."container_type" = ? ORDER BY attachments.created_on ASC, attachments.id ASC  [["container_id", 3], ["container_type", "Issue"]]
  ↳ app/views/issues/show.api.rsb:37
  User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN (?, ?) AND "users"."id" = ?  [["type", "User"], ["type", "AnonymousUser"], ["id", 2]]
  ↳ app/views/issues/show.api.rsb:37

Files

Actions #1

Updated by Go MAEDA 1 day ago

  • Description updated (diff)
Actions #2

Updated by Go MAEDA about 12 hours ago

  • Target version set to 7.1.0

Setting the target version to 7.1.0.

Actions

Also available in: Atom PDF