0

I have table

Column A Column B Column C
1 a d
2 b e
3 c f

and very large .csv file (about 1M rows). It contains Columns A, B and C.

Column A Column B Column C
4 a d
5 b w
6 c f

I need to extract rows from table where (B = 'a' and C = 'd') or (B = 'b' and C = 'w') or (B = 'c' and C = 'f')

Result will be:

Column A Column B Column C
1 a d
3 c f

I've tried query like in description, but it's too large for request (1M rows)

1 Answer 1

2

You are basically trying to join on the columns (b, c) manually. However, SQL knows how to do a join more efficiently.

Import the CSV file as a temporary table, analyze it, create a multi-column index on its (b, c), then do a join like this:

SELECT R.*
FROM realTable R
JOIN csvTable C
  ON R.b = C.b AND R.c = C.c;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.