The analysts I work with have created multiple tables where they structure them so there is data in majority of the table but then they tack on these date fields at the end which are designed to show a varying time period. For example, there might be columns to show current month, prior month, current quarter, prior quarter, current year, prior year, prior 90 days, etc… which are then given the value 1 or 0 based on a date provided. The problem comes with how the updates are handled to these columns. Currently they either perform a massive update to these columns for all records (tables can be as large as 17 million rows) after the data portion is inserted or they truncate the table and insert the data back into it using case statements to handle updating the date flags accordingly. Essentially the “data” portion of these tables will not change once it is inserted. The only thing that changes are the date flags at the tail end. Is there an efficient way to update all of these date flags without having to update the dates that might not have changed from the prior day, month, year, etc...?
↧