I have a large historical transaction table (15-20 million rows MANY columns) and a table with one row one column. The table with one row contains a date (last processing date) which will be used to pull the data in the trasaction table ('process_date').
Question: Should I inner join the 'process_date' table to the transaction table or the transaction table to the 'process_date' table?
This is how I would do it
SELECT <<list only columns you need>>
FROM large_historical_transaction_table t
WHERE EXISTS (SELECT 1 FROM OneRowTable o
WHERE o.last_processing_date = t.process_date)
An Inner join is a symmetrical, bi-directional relationship, in general it doesn't matter, but in this case I would suggest not joining at all, read the threshold date into a variable and pass it to the other select query as a parameter...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With