I'd like to run a query on a table that matches any of the following sets of conditions:
SELECT
id,
time
FROM
TABLE
WHERE
<condition1 is True> OR,
<condition2 is True> OR,
<condition3 is True> OR,
...
Each condition might look like:
id = 'id1' AND t > 20 AND t < 40
The values from each WHERE
condition (id
, 20
, 40
above) are rows in a pandas dataframe - that is 20k rows long. I see two options that would technically work:
- make 20k queries to the database, one for each condition, and concat the result
- generate a (very long) query as above and submit
My question: what would be an idiomatic/performant way to accomplish this? I suspect neither of the above are appropriate approaches and this problem is somewhat difficult to google.