Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved performance of notification preloading #15640

Merged
merged 3 commits into from
Jan 31, 2021

Conversation

abcang
Copy link
Contributor

@abcang abcang commented Jan 29, 2021

I optimized queries because many useless queries are being executed when loading notifications (for example, unnecessary associations and N + 1 queries).
Also, I improved to stop the notification cache and use the status cache. Since notifications are used only by the logged-in user, the cache effect is low. We hope that using the status cache will increase the effectiveness of the cache.

I have confirmed the change in the development environment with the following notification. (cache is off)

  • favorite: 3
  • reblog: 2
  • follow: 1
  • mention: 1

before

query count: 67

Started GET "/api/v1/notifications?exclude_types[]=follow_request" for 127.0.0.1 at 2021-01-29 00:54:34 +0900
Processing by Api::V1::NotificationsController#index as HTML
  Parameters: {"exclude_types"=>["follow_request"]}
  Doorkeeper::AccessToken Load (1.7ms)  SELECT  "oauth_access_tokens".* FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."token" = $1 LIMIT $2  [["token", "rS5uip_bRAIyzLyifWxsh-Q-v0Wegr7sqNzxqNazCww"], ["LIMIT", 1]]
  User Load (1.7ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
  SessionActivation Load (2.5ms)  SELECT  "session_activations".* FROM "session_activations" WHERE "session_activations"."session_id" = $1 LIMIT $2  [["session_id", "378e5b94629516862b0b93d6ab8f900f"], ["LIMIT", 1]]
  Account Load (2.3ms)  SELECT  "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
  Notification Load (2.0ms)  SELECT  "notifications"."id", "notifications"."updated_at", "notifications"."activity_type", "notifications"."activity_id" FROM "notifications" INNER JOIN "accounts" ON "accounts"."id" = "notifications"."from_account_id" WHERE "notifications"."account_id" = $1 AND "accounts"."suspended_at" IS NULL AND "notifications"."type" IN ($2, $3, $4, $5, $6, $7) ORDER BY "notifications"."id" DESC LIMIT $8  [["account_id", 1], ["type", "mention"], ["type", "status"], ["type", "reblog"], ["type", "follow"], ["type", "favourite"], ["type", "poll"], ["LIMIT", 15]]
  Notification Load (2.0ms)  SELECT "notifications".* FROM "notifications" WHERE "notifications"."id" IN ($1, $2, $3, $4, $5, $6, $7)  [["id", 7], ["id", 6], ["id", 5], ["id", 4], ["id", 3], ["id", 2], ["id", 1]]
  Account Load (2.2ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1  [["id", 3]]
  Status Load (2.3ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL AND "statuses"."id" IN ($1, $2, $3, $4, $5) ORDER BY "statuses"."id" DESC  [["id", 1], ["id", 105633831934347478], ["id", 2], ["id", 105633832073943742], ["id", 3]]
  CACHE Account Load (0.0ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1  [["id", 3]]
  MediaAttachment Load (2.0ms)  SELECT "media_attachments".* FROM "media_attachments" WHERE "media_attachments"."status_id" IN ($1, $2) ORDER BY "media_attachments"."id" ASC  [["status_id", 105633832073943742], ["status_id", 105633831934347478]]
  HABTM_Tags Load (1.6ms)  SELECT "statuses_tags".* FROM "statuses_tags" WHERE "statuses_tags"."status_id" IN ($1, $2)  [["status_id", 105633832073943742], ["status_id", 105633831934347478]]
  Mention Load (1.6ms)  SELECT "mentions".* FROM "mentions" WHERE "mentions"."silent" = $1 AND "mentions"."status_id" IN ($2, $3)  [["silent", false], ["status_id", 105633832073943742], ["status_id", 105633831934347478]]
  Status Load (1.8ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL AND "statuses"."id" IN ($1, $2) ORDER BY "statuses"."id" DESC  [["id", 105508139787263284], ["id", 105605752787288430]]
  Account Load (1.6ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1  [["id", 1]]
  Doorkeeper::Application Load (1.8ms)  SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."id" = $1  [["id", 1]]
  MediaAttachment Load (1.6ms)  SELECT "media_attachments".* FROM "media_attachments" WHERE "media_attachments"."status_id" IN ($1, $2) ORDER BY "media_attachments"."id" ASC  [["status_id", 105605752787288430], ["status_id", 105508139787263284]]
  HABTM_Tags Load (1.9ms)  SELECT "statuses_tags".* FROM "statuses_tags" WHERE "statuses_tags"."status_id" IN ($1, $2)  [["status_id", 105605752787288430], ["status_id", 105508139787263284]]
  Tag Load (1.8ms)  SELECT "tags".* FROM "tags" WHERE "tags"."id" = $1  [["id", 1]]
  Mention Load (1.8ms)  SELECT "mentions".* FROM "mentions" WHERE "mentions"."silent" = $1 AND "mentions"."status_id" IN ($2, $3)  [["silent", false], ["status_id", 105605752787288430], ["status_id", 105508139787263284]]
  Mention Load (2.4ms)  SELECT "mentions".* FROM "mentions" WHERE "mentions"."id" IN ($1, $2, $3, $4, $5)  [["id", 1], ["id", 105633831934347478], ["id", 2], ["id", 105633832073943742], ["id", 3]]
  Status Load (2.5ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL AND "statuses"."id" = $1 ORDER BY "statuses"."id" DESC  [["id", 105633832456495666]]
  CACHE Account Load (0.0ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1  [["id", 3]]
  CACHE Doorkeeper::Application Load (0.0ms)  SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."id" = $1  [["id", 1]]
  MediaAttachment Load (1.8ms)  SELECT "media_attachments".* FROM "media_attachments" WHERE "media_attachments"."status_id" = $1 ORDER BY "media_attachments"."id" ASC  [["status_id", 105633832456495666]]
  HABTM_Tags Load (1.9ms)  SELECT "statuses_tags".* FROM "statuses_tags" WHERE "statuses_tags"."status_id" = $1  [["status_id", 105633832456495666]]
  Mention Load (1.8ms)  SELECT "mentions".* FROM "mentions" WHERE "mentions"."silent" = $1 AND "mentions"."status_id" = $2  [["silent", false], ["status_id", 105633832456495666]]
  CACHE Account Load (0.0ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1  [["id", 1]]
  Favourite Load (1.8ms)  SELECT "favourites".* FROM "favourites" WHERE "favourites"."id" IN ($1, $2, $3, $4, $5)  [["id", 1], ["id", 105633831934347478], ["id", 2], ["id", 105633832073943742], ["id", 3]]
  CACHE Account Load (0.0ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1  [["id", 3]]
  Status Load (1.7ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL AND "statuses"."id" IN ($1, $2, $3) ORDER BY "statuses"."id" DESC  [["id", 105605752787288430], ["id", 105605750742241758], ["id", 105508138911264929]]
  CACHE Account Load (0.0ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1  [["id", 1]]
  CACHE Doorkeeper::Application Load (0.0ms)  SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."id" = $1  [["id", 1]]
  MediaAttachment Load (1.8ms)  SELECT "media_attachments".* FROM "media_attachments" WHERE "media_attachments"."status_id" IN ($1, $2, $3) ORDER BY "media_attachments"."id" ASC  [["status_id", 105605752787288430], ["status_id", 105605750742241758], ["status_id", 105508138911264929]]
  HABTM_Tags Load (1.7ms)  SELECT "statuses_tags".* FROM "statuses_tags" WHERE "statuses_tags"."status_id" IN ($1, $2, $3)  [["status_id", 105605752787288430], ["status_id", 105605750742241758], ["status_id", 105508138911264929]]
  Mention Load (2.5ms)  SELECT "mentions".* FROM "mentions" WHERE "mentions"."silent" = $1 AND "mentions"."status_id" IN ($2, $3, $4)  [["silent", false], ["status_id", 105605752787288430], ["status_id", 105605750742241758], ["status_id", 105508138911264929]]
  Follow Load (2.2ms)  SELECT "follows".* FROM "follows" WHERE "follows"."id" IN ($1, $2, $3, $4, $5)  [["id", 1], ["id", 105633831934347478], ["id", 2], ["id", 105633832073943742], ["id", 3]]
  CACHE Account Load (0.0ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1  [["id", 3]]
  FollowRequest Load (1.7ms)  SELECT "follow_requests".* FROM "follow_requests" WHERE "follow_requests"."id" IN ($1, $2, $3, $4, $5)  [["id", 1], ["id", 105633831934347478], ["id", 2], ["id", 105633832073943742], ["id", 3]]
  Poll Load (1.6ms)  SELECT "polls".* FROM "polls" WHERE "polls"."id" IN ($1, $2, $3, $4, $5)  [["id", 1], ["id", 105633831934347478], ["id", 2], ["id", 105633832073943742], ["id", 3]]
  Status Load (1.7ms)  SELECT "statuses"."reblog_of_id" FROM "statuses" WHERE "statuses"."reblog_of_id" IN ($1, $2, $3, $4, $5) AND "statuses"."account_id" = $6  [["reblog_of_id", 105633832456495666], ["reblog_of_id", 105508138911264929], ["reblog_of_id", 105508139787263284], ["reblog_of_id", 105605750742241758], ["reblog_of_id", 105605752787288430], ["account_id", 1]]
  Favourite Load (1.8ms)  SELECT "favourites"."status_id" FROM "favourites" WHERE "favourites"."status_id" IN ($1, $2, $3, $4, $5) AND "favourites"."account_id" = $6  [["status_id", 105633832456495666], ["status_id", 105508138911264929], ["status_id", 105508139787263284], ["status_id", 105605750742241758], ["status_id", 105605752787288430], ["account_id", 1]]
  Bookmark Load (1.7ms)  SELECT "bookmarks"."status_id" FROM "bookmarks" WHERE "bookmarks"."status_id" IN ($1, $2, $3, $4, $5) AND "bookmarks"."account_id" = $6  [["status_id", 105633832456495666], ["status_id", 105508138911264929], ["status_id", 105508139787263284], ["status_id", 105605750742241758], ["status_id", 105605752787288430], ["account_id", 1]]
  ConversationMute Load (1.4ms)  SELECT "conversation_mutes"."conversation_id" FROM "conversation_mutes" WHERE "conversation_mutes"."conversation_id" IN ($1, $2, $3, $4) AND "conversation_mutes"."account_id" = $5  [["conversation_id", 1], ["conversation_id", 2], ["conversation_id", 3], ["conversation_id", 4], ["account_id", 1]]
  StatusPin Load (1.8ms)  SELECT "status_pins"."status_id" FROM "status_pins" WHERE "status_pins"."status_id" IN ($1, $2, $3, $4, $5) AND "status_pins"."account_id" = $6  [["status_id", 105508138911264929], ["status_id", 105508139787263284], ["status_id", 105605750742241758], ["status_id", 105605752787288430], ["status_id", 105605752787288430], ["account_id", 1]]
[active_model_serializers]   AccountStat Load (1.8ms)  SELECT  "account_stats".* FROM "account_stats" WHERE "account_stats"."account_id" = $1 LIMIT $2  [["account_id", 3], ["LIMIT", 1]]
[active_model_serializers]   StatusStat Load (1.7ms)  SELECT  "status_stats".* FROM "status_stats" WHERE "status_stats"."status_id" = $1 LIMIT $2  [["status_id", 105633832456495666], ["LIMIT", 1]]
[active_model_serializers]   User Load (1.9ms)  SELECT  "users".* FROM "users" WHERE "users"."account_id" = $1 LIMIT $2  [["account_id", 3], ["LIMIT", 1]]
[active_model_serializers]   Setting Load (1.5ms)  SELECT  "settings".* FROM "settings" WHERE "settings"."thing_type" = $1 AND "settings"."thing_id" = $2 AND "settings"."var" = $3 LIMIT $4  [["thing_type", "User"], ["thing_id", 3], ["var", "show_application"], ["LIMIT", 1]]
[active_model_serializers]   Setting Load (1.9ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = $1 ORDER BY "settings"."id" ASC LIMIT $2  [["var", "theme"], ["LIMIT", 1]]
[active_model_serializers]   Setting Load (1.5ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = $1 ORDER BY "settings"."id" ASC LIMIT $2  [["var", "noindex"], ["LIMIT", 1]]
[active_model_serializers]   CACHE AccountStat Load (0.0ms)  SELECT  "account_stats".* FROM "account_stats" WHERE "account_stats"."account_id" = $1 LIMIT $2  [["account_id", 3], ["LIMIT", 1]]
[active_model_serializers]   PreviewCard Load (2.1ms)  SELECT  "preview_cards".* FROM "preview_cards" INNER JOIN "preview_cards_statuses" ON "preview_cards"."id" = "preview_cards_statuses"."preview_card_id" WHERE "preview_cards_statuses"."status_id" = $1 ORDER BY "preview_cards"."id" ASC LIMIT $2  [["status_id", 105633832456495666], ["LIMIT", 1]]
[active_model_serializers]   StatusStat Load (2.2ms)  SELECT  "status_stats".* FROM "status_stats" WHERE "status_stats"."status_id" = $1 LIMIT $2  [["status_id", 105508138911264929], ["LIMIT", 1]]
[active_model_serializers]   User Load (2.6ms)  SELECT  "users".* FROM "users" WHERE "users"."account_id" = $1 LIMIT $2  [["account_id", 1], ["LIMIT", 1]]
[active_model_serializers]   Setting Load (1.6ms)  SELECT  "settings".* FROM "settings" WHERE "settings"."thing_type" = $1 AND "settings"."thing_id" = $2 AND "settings"."var" = $3 LIMIT $4  [["thing_type", "User"], ["thing_id", 1], ["var", "show_application"], ["LIMIT", 1]]
[active_model_serializers]   AccountStat Load (1.7ms)  SELECT  "account_stats".* FROM "account_stats" WHERE "account_stats"."account_id" = $1 LIMIT $2  [["account_id", 1], ["LIMIT", 1]]
[active_model_serializers]   PreviewCard Load (1.7ms)  SELECT  "preview_cards".* FROM "preview_cards" INNER JOIN "preview_cards_statuses" ON "preview_cards"."id" = "preview_cards_statuses"."preview_card_id" WHERE "preview_cards_statuses"."status_id" = $1 ORDER BY "preview_cards"."id" ASC LIMIT $2  [["status_id", 105508138911264929], ["LIMIT", 1]]
[active_model_serializers]   StatusStat Load (1.7ms)  SELECT  "status_stats".* FROM "status_stats" WHERE "status_stats"."status_id" = $1 LIMIT $2  [["status_id", 105508139787263284], ["LIMIT", 1]]
[active_model_serializers]   CACHE User Load (0.0ms)  SELECT  "users".* FROM "users" WHERE "users"."account_id" = $1 LIMIT $2  [["account_id", 1], ["LIMIT", 1]]
[active_model_serializers]   CACHE AccountStat Load (0.0ms)  SELECT  "account_stats".* FROM "account_stats" WHERE "account_stats"."account_id" = $1 LIMIT $2  [["account_id", 1], ["LIMIT", 1]]
[active_model_serializers]   PreviewCard Load (2.4ms)  SELECT  "preview_cards".* FROM "preview_cards" INNER JOIN "preview_cards_statuses" ON "preview_cards"."id" = "preview_cards_statuses"."preview_card_id" WHERE "preview_cards_statuses"."status_id" = $1 ORDER BY "preview_cards"."id" ASC LIMIT $2  [["status_id", 105508139787263284], ["LIMIT", 1]]
[active_model_serializers]   StatusStat Load (2.0ms)  SELECT  "status_stats".* FROM "status_stats" WHERE "status_stats"."status_id" = $1 LIMIT $2  [["status_id", 105605750742241758], ["LIMIT", 1]]
[active_model_serializers]   PreviewCard Load (1.7ms)  SELECT  "preview_cards".* FROM "preview_cards" INNER JOIN "preview_cards_statuses" ON "preview_cards"."id" = "preview_cards_statuses"."preview_card_id" WHERE "preview_cards_statuses"."status_id" = $1 ORDER BY "preview_cards"."id" ASC LIMIT $2  [["status_id", 105605750742241758], ["LIMIT", 1]]
[active_model_serializers]   StatusStat Load (1.9ms)  SELECT  "status_stats".* FROM "status_stats" WHERE "status_stats"."status_id" = $1 LIMIT $2  [["status_id", 105605752787288430], ["LIMIT", 1]]
[active_model_serializers]   PreviewCard Load (1.5ms)  SELECT  "preview_cards".* FROM "preview_cards" INNER JOIN "preview_cards_statuses" ON "preview_cards"."id" = "preview_cards_statuses"."preview_card_id" WHERE "preview_cards_statuses"."status_id" = $1 ORDER BY "preview_cards"."id" ASC LIMIT $2  [["status_id", 105605752787288430], ["LIMIT", 1]]
[active_model_serializers]   CACHE StatusStat Load (0.0ms)  SELECT  "status_stats".* FROM "status_stats" WHERE "status_stats"."status_id" = $1 LIMIT $2  [["status_id", 105605752787288430], ["LIMIT", 1]]
[active_model_serializers]   CACHE PreviewCard Load (0.0ms)  SELECT  "preview_cards".* FROM "preview_cards" INNER JOIN "preview_cards_statuses" ON "preview_cards"."id" = "preview_cards_statuses"."preview_card_id" WHERE "preview_cards_statuses"."status_id" = $1 ORDER BY "preview_cards"."id" ASC LIMIT $2  [["status_id", 105605752787288430], ["LIMIT", 1]]
Completed 200 OK in 256ms (Views: 98.1ms | ActiveRecord: 101.3ms)

after

query count: 40

Started GET "/api/v1/notifications?exclude_types[]=follow_request" for 127.0.0.1 at 2021-01-30 00:41:30 +0900
Processing by Api::V1::NotificationsController#index as HTML
  Parameters: {"exclude_types"=>["follow_request"]}
  Doorkeeper::AccessToken Load (2.6ms)  SELECT  "oauth_access_tokens".* FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."token" = $1 LIMIT $2  [["token", "rS5uip_bRAIyzLyifWxsh-Q-v0Wegr7sqNzxqNazCww"], ["LIMIT", 1]]
  User Load (1.6ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
  SessionActivation Load (1.3ms)  SELECT  "session_activations".* FROM "session_activations" WHERE "session_activations"."session_id" = $1 LIMIT $2  [["session_id", "378e5b94629516862b0b93d6ab8f900f"], ["LIMIT", 1]]
  Account Load (1.8ms)  SELECT  "accounts".* FROM "accounts" WHERE "accounts"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
  Notification Load (3.0ms)  SELECT  "notifications".* FROM "notifications" INNER JOIN "accounts" ON "accounts"."id" = "notifications"."from_account_id" WHERE "notifications"."account_id" = $1 AND "accounts"."suspended_at" IS NULL AND "notifications"."type" IN ($2, $3, $4, $5, $6, $7) ORDER BY "notifications"."id" DESC LIMIT $8  [["account_id", 1], ["type", "mention"], ["type", "status"], ["type", "reblog"], ["type", "follow"], ["type", "favourite"], ["type", "poll"], ["LIMIT", 15]]
  Account Load (1.2ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1  [["id", 3]]
  AccountStat Load (1.2ms)  SELECT "account_stats".* FROM "account_stats" WHERE "account_stats"."account_id" = $1  [["account_id", 3]]
  Mention Load (1.3ms)  SELECT "mentions".* FROM "mentions" WHERE "mentions"."id" = $1  [["id", 1]]
  Status Load (1.2ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL AND "statuses"."id" = $1 ORDER BY "statuses"."id" DESC  [["id", 105633832456495666]]
  Favourite Load (1.4ms)  SELECT "favourites".* FROM "favourites" WHERE "favourites"."id" IN ($1, $2, $3)  [["id", 3], ["id", 2], ["id", 1]]
  Status Load (1.9ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL AND "statuses"."id" IN ($1, $2, $3) ORDER BY "statuses"."id" DESC  [["id", 105605752787288430], ["id", 105605750742241758], ["id", 105508138911264929]]
  Status Load (1.5ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL AND "statuses"."id" IN ($1, $2) ORDER BY "statuses"."id" DESC  [["id", 105633832073943742], ["id", 105633831934347478]]
  Status Load (1.4ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL AND "statuses"."id" IN ($1, $2) ORDER BY "statuses"."id" DESC  [["id", 105508139787263284], ["id", 105605752787288430]]
  Status Load (1.5ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL AND "statuses"."id" IN ($1, $2, $3, $4, $5) ORDER BY "statuses"."id" DESC  [["id", 105633832456495666], ["id", 105508138911264929], ["id", 105508139787263284], ["id", 105605750742241758], ["id", 105605752787288430]]
  Doorkeeper::Application Load (1.3ms)  SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."id" = $1  [["id", 1]]
  MediaAttachment Load (1.5ms)  SELECT "media_attachments".* FROM "media_attachments" WHERE "media_attachments"."status_id" IN ($1, $2, $3, $4, $5) ORDER BY "media_attachments"."id" ASC  [["status_id", 105633832456495666], ["status_id", 105605752787288430], ["status_id", 105605750742241758], ["status_id", 105508139787263284], ["status_id", 105508138911264929]]
  Conversation Load (1.5ms)  SELECT "conversations".* FROM "conversations" WHERE "conversations"."id" IN ($1, $2, $3, $4)  [["id", 1], ["id", 4], ["id", 3], ["id", 2]]
  StatusStat Load (2.1ms)  SELECT "status_stats".* FROM "status_stats" WHERE "status_stats"."status_id" IN ($1, $2, $3, $4, $5)  [["status_id", 105633832456495666], ["status_id", 105605752787288430], ["status_id", 105605750742241758], ["status_id", 105508139787263284], ["status_id", 105508138911264929]]
  HABTM_Tags Load (1.8ms)  SELECT "statuses_tags".* FROM "statuses_tags" WHERE "statuses_tags"."status_id" IN ($1, $2, $3, $4, $5)  [["status_id", 105633832456495666], ["status_id", 105605752787288430], ["status_id", 105605750742241758], ["status_id", 105508139787263284], ["status_id", 105508138911264929]]
  Tag Load (3.3ms)  SELECT "tags".* FROM "tags" WHERE "tags"."id" = $1  [["id", 1]]
  HABTM_PreviewCards Load (2.1ms)  SELECT "preview_cards_statuses".* FROM "preview_cards_statuses" WHERE "preview_cards_statuses"."status_id" IN ($1, $2, $3, $4, $5)  [["status_id", 105633832456495666], ["status_id", 105605752787288430], ["status_id", 105605750742241758], ["status_id", 105508139787263284], ["status_id", 105508138911264929]]
  Account Load (1.8ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" IN ($1, $2)  [["id", 3], ["id", 1]]
  AccountStat Load (1.4ms)  SELECT "account_stats".* FROM "account_stats" WHERE "account_stats"."account_id" IN ($1, $2)  [["account_id", 1], ["account_id", 3]]
  Mention Load (1.4ms)  SELECT "mentions".* FROM "mentions" WHERE "mentions"."silent" = $1 AND "mentions"."status_id" IN ($2, $3, $4, $5, $6)  [["silent", false], ["status_id", 105633832456495666], ["status_id", 105605752787288430], ["status_id", 105605750742241758], ["status_id", 105508139787263284], ["status_id", 105508138911264929]]
  Account Load (1.2ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1  [["id", 1]]
  AccountStat Load (1.1ms)  SELECT "account_stats".* FROM "account_stats" WHERE "account_stats"."account_id" = $1  [["account_id", 1]]
  Status Load (1.3ms)  SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL AND "statuses"."id" = $1 ORDER BY "statuses"."id" DESC  [["id", 105508138911264929]]
  CACHE Account Load (0.0ms)  SELECT "accounts".* FROM "accounts" WHERE "accounts"."id" = $1  [["id", 1]]
  CACHE AccountStat Load (0.0ms)  SELECT "account_stats".* FROM "account_stats" WHERE "account_stats"."account_id" = $1  [["account_id", 1]]
  Status Load (1.9ms)  SELECT "statuses"."reblog_of_id" FROM "statuses" WHERE "statuses"."reblog_of_id" IN ($1, $2, $3, $4, $5) AND "statuses"."account_id" = $6  [["reblog_of_id", 105633832456495666], ["reblog_of_id", 105508138911264929], ["reblog_of_id", 105508139787263284], ["reblog_of_id", 105605750742241758], ["reblog_of_id", 105605752787288430], ["account_id", 1]]
  Favourite Load (1.6ms)  SELECT "favourites"."status_id" FROM "favourites" WHERE "favourites"."status_id" IN ($1, $2, $3, $4, $5) AND "favourites"."account_id" = $6  [["status_id", 105633832456495666], ["status_id", 105508138911264929], ["status_id", 105508139787263284], ["status_id", 105605750742241758], ["status_id", 105605752787288430], ["account_id", 1]]
  Bookmark Load (1.7ms)  SELECT "bookmarks"."status_id" FROM "bookmarks" WHERE "bookmarks"."status_id" IN ($1, $2, $3, $4, $5) AND "bookmarks"."account_id" = $6  [["status_id", 105633832456495666], ["status_id", 105508138911264929], ["status_id", 105508139787263284], ["status_id", 105605750742241758], ["status_id", 105605752787288430], ["account_id", 1]]
  ConversationMute Load (2.6ms)  SELECT "conversation_mutes"."conversation_id" FROM "conversation_mutes" WHERE "conversation_mutes"."conversation_id" IN ($1, $2, $3, $4) AND "conversation_mutes"."account_id" = $5  [["conversation_id", 1], ["conversation_id", 2], ["conversation_id", 3], ["conversation_id", 4], ["account_id", 1]]
  StatusPin Load (1.6ms)  SELECT "status_pins"."status_id" FROM "status_pins" WHERE "status_pins"."status_id" IN ($1, $2, $3, $4, $5) AND "status_pins"."account_id" = $6  [["status_id", 105508138911264929], ["status_id", 105508139787263284], ["status_id", 105605750742241758], ["status_id", 105605752787288430], ["status_id", 105605752787288430], ["account_id", 1]]
[active_model_serializers]   User Load (2.4ms)  SELECT  "users".* FROM "users" WHERE "users"."account_id" = $1 LIMIT $2  [["account_id", 3], ["LIMIT", 1]]
[active_model_serializers]   Setting Load (2.2ms)  SELECT  "settings".* FROM "settings" WHERE "settings"."thing_type" = $1 AND "settings"."thing_id" = $2 AND "settings"."var" = $3 LIMIT $4  [["thing_type", "User"], ["thing_id", 3], ["var", "show_application"], ["LIMIT", 1]]
[active_model_serializers]   Setting Load (1.6ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = $1 ORDER BY "settings"."id" ASC LIMIT $2  [["var", "theme"], ["LIMIT", 1]]
[active_model_serializers]   Setting Load (1.5ms)  SELECT  "settings".* FROM "settings" WHERE (thing_type is NULL and thing_id is NULL) AND "settings"."var" = $1 ORDER BY "settings"."id" ASC LIMIT $2  [["var", "noindex"], ["LIMIT", 1]]
[active_model_serializers]   User Load (3.0ms)  SELECT  "users".* FROM "users" WHERE "users"."account_id" = $1 LIMIT $2  [["account_id", 1], ["LIMIT", 1]]
[active_model_serializers]   Setting Load (1.5ms)  SELECT  "settings".* FROM "settings" WHERE "settings"."thing_type" = $1 AND "settings"."thing_id" = $2 AND "settings"."var" = $3 LIMIT $4  [["thing_type", "User"], ["thing_id", 1], ["var", "show_application"], ["LIMIT", 1]]
Completed 200 OK in 183ms (Views: 67.5ms | ActiveRecord: 66.2ms)

@Gargron Gargron merged commit 7ab53f2 into mastodon:main Jan 31, 2021
@abcang abcang deleted the improve_notification_includes_query branch February 1, 2021 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants