how to reduce db queries
GET /organization-os 200 in 2450ms
Query: select "id", "expires_at", "token", "created_at", "updated_at", "ip_address", "user_agent", "user_id", "active_organization_id" from "session" where "session"."token" = $1 -- params: ["vVruXo2YbncR1OAb7vQE5UeyHlisPWHG"]
Query: select "id", "name", "email", "email_verified", "image", "onboarded", "created_at", "updated_at" from "user" where "user"."id" = $1 -- params: ["lu2xgWwEaxetZPv-Rx0gC"]
Query: select "id", "expires_at", "token", "created_at", "updated_at", "ip_address", "user_agent", "user_id", "active_organization_id" from "session" where "session"."token" = $1 -- params: ["vVruXo2YbncR1OAb7vQE5UeyHlisPWHG"]
Query: select "id", "name", "email", "email_verified", "image", "onboarded", "created_at", "updated_at" from "user" where "user"."id" = $1 -- params: ["lu2xgWwEaxetZPv-Rx0gC"]
Query: select "id", "organization_id", "user_id", "role", "created_at" from "member" where "member"."user_id" = $1 limit $2 -- params: ["lu2xgWwEaxetZPv-Rx0gC", 100]
Query: select "id", "name", "slug", "logo", "created_at", "metadata" from "organization" where "organization"."id" in ($1, $2) limit $3 -- params: ["9VBA7Lr5HcerASzEw-rtG", "ht0hWzfF_NoLQ6q7VHgXj", 100]
Query: select "id", "expires_at", "token", "created_at", "updated_at", "ip_address", "user_agent", "user_id", "active_organization_id" from "session" where "session"."token" = $1 -- params: ["vVruXo2YbncR1OAb7vQE5UeyHlisPWHG"]
Query: select "id", "name", "email", "email_verified", "image", "onboarded", "created_at", "updated_at" from "user" where "user"."id" = $1 -- params: ["lu2xgWwEaxetZPv-Rx0gC"]
GET /organization-os 200 in 3796ms
GET /organization-os 200 in 2450ms
Query: select "id", "expires_at", "token", "created_at", "updated_at", "ip_address", "user_agent", "user_id", "active_organization_id" from "session" where "session"."token" = $1 -- params: ["vVruXo2YbncR1OAb7vQE5UeyHlisPWHG"]
Query: select "id", "name", "email", "email_verified", "image", "onboarded", "created_at", "updated_at" from "user" where "user"."id" = $1 -- params: ["lu2xgWwEaxetZPv-Rx0gC"]
Query: select "id", "expires_at", "token", "created_at", "updated_at", "ip_address", "user_agent", "user_id", "active_organization_id" from "session" where "session"."token" = $1 -- params: ["vVruXo2YbncR1OAb7vQE5UeyHlisPWHG"]
Query: select "id", "name", "email", "email_verified", "image", "onboarded", "created_at", "updated_at" from "user" where "user"."id" = $1 -- params: ["lu2xgWwEaxetZPv-Rx0gC"]
Query: select "id", "organization_id", "user_id", "role", "created_at" from "member" where "member"."user_id" = $1 limit $2 -- params: ["lu2xgWwEaxetZPv-Rx0gC", 100]
Query: select "id", "name", "slug", "logo", "created_at", "metadata" from "organization" where "organization"."id" in ($1, $2) limit $3 -- params: ["9VBA7Lr5HcerASzEw-rtG", "ht0hWzfF_NoLQ6q7VHgXj", 100]
Query: select "id", "expires_at", "token", "created_at", "updated_at", "ip_address", "user_agent", "user_id", "active_organization_id" from "session" where "session"."token" = $1 -- params: ["vVruXo2YbncR1OAb7vQE5UeyHlisPWHG"]
Query: select "id", "name", "email", "email_verified", "image", "onboarded", "created_at", "updated_at" from "user" where "user"."id" = $1 -- params: ["lu2xgWwEaxetZPv-Rx0gC"]
GET /organization-os 200 in 3796ms
1 Reply
Don't auth in middleware I've been told, instead do it per page/route
Most check you can do is a presence check of the session cookie