Select rows which are not present in another table

The issue with your implementation is that it will execute the subquery for every question. This quickly gets very slow when you start scaling.

Currently on mobile so its hard to write code, but your best bet is probably to do an outer join from question to test_question based on question_id. After that outer join you can use a WHERE to check which rows have tq.id IS NULL.

Hopefully thats clear :slight_smile:

Edit: Sfusato’s version is definitely the way to go