HCL GUVI
26.7K subscribers
915 photos
145 videos
1 file
904 links
GUVI (Grab Your Vernacular Imprint) | An HCL Group Company | Learn AI, Data Science, Full Stack, AI/ML & UI/UX in 19+ Languages | 3M+ Learners | 1000+ Hiring Companies | Daily Job Updates & Free Tips!!

Career Consultation: https://bit.ly/4j2Lt21
Download Telegram
Batching DB Requests with Promise.all


OPTIMIZATION TIP: Run Queries in Parallel

Sequential — each waits for the previous to finish

const user = await getUser(id); // 100ms
const courses = await getCourses(id); // 100ms
const badges = await getBadges(id); // 100ms
// Total: ~300ms

Parallel — all run at the same time

const [user, courses, badges] = await Promise.all([
getUser(id),
getCourses(id),
getBadges(id)
]);
// Total: ~100ms (3x faster!)

Note: Use this when queries are independent of each other.
Perfect for dashboard data loading!

#JavaScript #AsyncAwait #NodeJS