3
Questions
5
Answers
1
Gold Badges
2
Silver Badges
2
Bronze Badges
I have a query that's taking 30+ seconds on a PostgreSQL database:
SELECT u.name, COUNT(o.id) as order_count, SUM(o.total) as revenue
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE o.created_at > '2024-01-01'
GROUP BY u.id, u.name
ORDER BY revenue DESC;
Tables: 500K users, 8M orders. I've added indexes on user_id and created_at but it's still slow. What am I missing?
Yuki Tanaka
1
Answers23
Upvotes7900
ViewsI have a utility function that returns different types depending on the input parameter:
function transform(input: string | number) {
if (typeof input === 'string') return input.toUpperCase();
return input * 2;
}
TypeScript infers the return type as string | number, but I want it to be narrowed based on the input. Is this possible with overloads or conditional types?
Yuki Tanaka
asked 3 months ago1
Answers59
Upvotes8300
ViewsI'm implementing JWT-based auth in a Next.js app. I've read conflicting advice about where to store the JWT:
What's the recommended approach in 2024 for a production app? Does it change if I'm using NextAuth?
Yuki Tanaka
asked 4 months ago2
Answers69
Upvotes15300
Views1