Can I merge updated rows in a SQL table with historical data?
I have a SQL table in an event system. Data of interest are 10 years back in time. To decrease the load of the SQL DB, I would like to only read the modified data each day, and merge that data with a query that is update less frequently (e.g once per year). My data might look like below for some years ago:
id open last_mod custom
== ========== ========== ======
1 2010-01-01 2010-01-01 a
2 2010-01-02 2010-01-02 a
3 2010-01-03 2010-01-03 a
The next day, the data might look like below:
id open last_mod custom == ========== ========== ====== 1 2010-01-01 2010-01-01 a 2 2010-01-02 2017-04-04 b 3 2010-01-03 2010-01-03 a 4 2017-04-04 2017-04-04 a
I.E. now row-id 4 has been added and row-id 2 has changed from "a" to "b" in the custom column. This is detectable in the last_mod column as well
Is it possible to combine two queries where Q1 reads all the data, and Q2 reads the updated data?