I'm considering whether to store sessions in a separate Redis store instead of just keeping everything in Postgres. If I go with Redis, I would need to look up the session cookie there to get the user ID, and then run a separate query in Postgres to retrieve the user data. Doesn't this approach seem less efficient than running a single query with a join?
2 Answers
Using Redis can really help with scaling your sessions across multiple nodes, especially when traffic picks up. It's like having a turbo boost for session lookups, which makes it super fast when you're dealing with high requests per second (RPS). If you preload some common user data when they log in, it can save time in the long run.
You're right that if you're already making calls to Postgres for user data, adding Redis might feel like an extra step. However, splitting sessions into Redis is mostly about speed and handling larger scales. Redis shines when there are many concurrent users or when sessions are short-lived. For smaller apps or less traffic, sticking with Postgres for sessions can be simpler and just as effective.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically