使用大IN优化Postgres查询
该查询获取您关注的人创建的帖子列表。您可以追踪的人数不受限制,但是大多数人追踪的人数<1000。 使用这种查询方式,明显的优化将是缓存"Post"id,但是不幸的是我现在没有时间。 EXPLAIN ANALYZE SELECT "Post"."id", "Post"."actionId", "Post"."commentCount", ... FROM "Posts" AS "Post" INNER JOIN "Users" AS "user" ON "Post"."userId" = "user"."id" LEFT OUTER JOIN "ActivityLogs" AS "activityLog" ON "Post"."activityLogId" = "activityLog"."id" LEFT OUTER JOIN "WeightLogs" AS "weightLog" ON "Post"."weightLogId" = "weightLog"."id" LEFT OUTER JOIN "Workouts" AS "workout" ON "Post"."workoutId" …