これがメールボックスのgemに関係しているのか、それともレールの深いところにあるのかはわかりません。リンクをクリックするたびに、メッセージ テーブル、会話テーブル、領収書テーブルのすべてのレコードが読み込まれます。これは、ページがメールボックスと関係がない場合でも発生します。これがなぜなのか、どうすれば修正できるのか誰か知っていますか?
たとえば、どのページに移動しても、サーバー ログには常に次のように表示されます。
Receipt Load (0.3ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 80]]
Receipt Load (0.3ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 80]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 78]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 78]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 75]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 75]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 69]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 69]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 67]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 67]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 66]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 66]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 65]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 65]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 63]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 63]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 60]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 60]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 55]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 55]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 51]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 51]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 46]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 46]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 45]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 45]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 44]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 44]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 42]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 42]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 41]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 41]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 39]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 39]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 38]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 38]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 37]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 37]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 43]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 43]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 32]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 32]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 31]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 31]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 29]]
Receipt Load (0.2ms) SELECT "receipts".* FROM "receipts" WHERE "receipts"."notification_id" = $1 AND (receiver_id = 32) ORDER BY "receipts"."id" ASC LIMIT 1 [["notification_id", 29]]
Active Record、Postgres、Rails 4 を使用しています。