Skip to content

Instantly share code, notes, and snippets.

@ketanbhatt
Last active October 18, 2019 09:37
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Avoid Joins: Evaluate and Select Query
WITH user_ids AS
(SELECT id
FROM user
WHERE account_id IN
(SELECT generate_series(1,1000)))
SELECT purchase.id
FROM purchase
WHERE user_id IN
(SELECT id
FROM user_ids);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment