SQL query to convert date ranges to per day records

前端 未结 2 962
执念已碎
执念已碎 2020-12-11 11:52

Requirements

  1. I have data table that saves data in date ranges.
  2. Each record is allowed to overlap previous record(s) (record has a CreatedOn da
2条回答
  •  生来不讨喜
    2020-12-11 12:25

    Why do it all in DB when you can do it better in memory

    This is the solution (I eventually used) that seemed most reasonable in terms of data transferred, speed and resources.

    1. get actual range definitions from DB to mid tier (smaller amount of data)
    2. generate in memory calendar of a certain date range (faster than in DB)
    3. put those DB definitions in (much easier and faster than DB)

    And that's it. I realised that complicating certain things in DB is not not worth it when you have executable in memory code that can do the same manipulation faster and more efficient.

提交回复
热议问题