I receive data (Timestamp and Value) from external service (let’s assume that Timestamp is Datetime and Value is string). I want to store it in database. So for example following data sequence can be received:
Value1 2024-07-07 12:05:50
Value1 2024-07-07 12:05:51
Value1 2024-07-07 12:05:52
Value1 2024-07-07 12:05:53
Value2 2024-07-07 12:05:55
Value2 2024-07-07 12:05:56
Value3 2024-07-07 12:05:57
Value2 2024-07-07 12:05:58
Currently I create new row entry each time data is received (so 8 rows will be created for above data sequence).
However I thought that maybe it’s better to store only data changes. So for example if Value is not changed, then new Datetime is concatenated. Otherwise new row entry is created:
Value1 "2024-07-07 12:05:50, 2024-07-07 12:05:51, 2024-07-07 12:05:52, 2024-07-07 12:05:53"
Value2 "2024-07-07 12:05:55, 2024-07-07 12:05:56"
Value3 "2024-07-07 12:05:57"
Value2 "2024-07-07 12:05:58"
What do you think about such solution? Do you know better solution to optimize it?
Please note that I use EF Core 8 and Postgres