SQL Subquery is faster than joins

November 24th, 2023

This dude’s benchmark shows that it’s in average around twice as fast compared to joins. I’ll be using subquery then idc.

SELECT * FROM users WHERE id IN (
    SELECT user_id FROM posts WHERE views > 90000
);

SELECT * FROM users WHERE EXISTS (
    SELECT user_id FROM posts WHERE views > 90000 and users.id = user_id
)