Actions
Patch #37687
closedRetrieve attachments with a single query when rendering a journal
Description
The attached patch fixes N+1 queries in Journal#attachments.
Before:
D, [2022-09-19T17:11:55.977897 #39418] DEBUG -- : Attachment Load (0.4ms) SELECT "attachments".* FROM "attachments" WHERE "attachments"."id" = ? LIMIT ? [["id", 24], ["LIMIT", 1]] D, [2022-09-19T17:11:55.978340 #39418] DEBUG -- : ↳ app/models/journal.rb:145:in `block in attachments' D, [2022-09-19T17:11:55.978659 #39418] DEBUG -- : Attachment Load (0.1ms) SELECT "attachments".* FROM "attachments" WHERE "attachments"."id" = ? LIMIT ? [["id", 25], ["LIMIT", 1]] D, [2022-09-19T17:11:55.979025 #39418] DEBUG -- : ↳ app/models/journal.rb:145:in `block in attachments' D, [2022-09-19T17:11:55.979276 #39418] DEBUG -- : Attachment Load (0.1ms) SELECT "attachments".* FROM "attachments" WHERE "attachments"."id" = ? LIMIT ? [["id", 26], ["LIMIT", 1]] D, [2022-09-19T17:11:55.979616 #39418] DEBUG -- : ↳ app/models/journal.rb:145:in `block in attachments'
After:
D, [2022-09-19T17:35:55.808467 #41181] DEBUG -- : Attachment Load (0.2ms) SELECT "attachments".* FROM "attachments" WHERE "attachments"."id" IN (?, ?, ?) [["id", 24], ["id", 25], ["id", 26]] D, [2022-09-19T17:35:55.809074 #41181] DEBUG -- : ↳ app/models/journal.rb:146:in `attachments'
Files
Updated by Go MAEDA about 2 years ago
- File 0001-Get-attachments-with-single-query-when-rendering-a-j.patch 0001-Get-attachments-with-single-query-when-rendering-a-j.patch added
- File 0002-Unify-duplicate-codes.patch 0002-Unify-duplicate-codes.patch added
Updated the patch.
Updated by Go MAEDA about 2 years ago
- Target version set to 5.1.0
Setting the target version to 5.1.0.
Updated by Go MAEDA about 2 years ago
- Subject changed from Get attachments with single query when rendering a journal to Retrieve attachments with single query when rendering a journal
- Status changed from New to Closed
- Assignee set to Go MAEDA
Committed the patch.
Updated by Go MAEDA about 2 years ago
- Subject changed from Retrieve attachments with single query when rendering a journal to Retrieve attachments with a single query when rendering a journal
Actions