Let's say we need to store reading of temperature sensors and keep a history, for every day. Each measure is a tuple day: number, value: string
(some days could be missed that's why we need to store the day explicitly). There are hundreds of thousands of sensors.
Adding new measurement should not require re-reading and re-write the whole object, it should be small incremental addition.
And, there could be multiple reading for the same day. In such case, if day is the same only the latest measurement for that day should be kept.
What data structure should be used? I can see the following ways:
CREATE TABLE sensor_history (
sensor_id integer,
time integer[],
value text[]
);
or
CREATE TABLE sensor_history (
sensor_id integer,
history json/jsonb/hstore
);