EXPLAIN QUERY PLAN tells you this before you run it, and it is the single highest-value habit for anyone writing SQL against a metered platform.
A correlated subquery shows up as a scan nested inside the outer loop. You do not need to understand the whole plan output. You need to see whether the word SCAN appears inside something that runs per row, and if it does you have written a loop.
Thirty seconds, and it would have caught this before the CPU limit did.