I would like to store time series in a MySQL database. I would like to do it linearly, i.e. Each line represents a unique observation (1 measure, 1 site, 1 timestamp). Currently, this will require a line of 84 096 000 , and it will grow approximately 2 102 400 lines per year.
What precautions should be taken to correctly develop a table of time series, indexes, and related queries (essentially, the choice of data that defines the measure, site, and time range).
Edit:
Adding a table design suggestion:
CREATE TABLE TimeSeries( Id INT NOT NULL AUTO_INCREMENT, MeasureTimeStamp DATETIME NOT NULL, MeasureId INT NOT NULL, SiteId INT NOT NULL, Measure FLOAT NOT NULL, Quality INT NOT NULL, PRIMARY KEY (Id), CONSTRAINT UNIQUE (MeasureTimeStamp,MeasureId,SiteId), FOREIGN KEY (MeasureId) REFERENCES Measure(Id), FOREIGN KEY (SiteId) REFERENCES Site(Id) ); CREATE INDEX ChannelIndex ON TimeSeries(MeasureId,SiteId);
Provided that there is a table called Measure and Site, which should be improved for this structure if my basic queries are:
SELECT * FROM TimeSeries WHERE (MeasureId IN (?,?,?)) AND (SiteId IN (?,?,?)) AND (MeasureTimeStamp BETWEEN ? AND ?) ORDER BY MeasureId ASC, SiteId ASC, MeasureTimeStamp ASC;
Edit 2:
Sites are about 20, and measures are about 50. This leads to a maximum of 1000 channels (a couple of sites and a measurement). It may increase slightly over several decades, but will not reach more than 10,000 channels. Most of the data has a temporary granularity of about 30 minutes. In any case, the granulation of time is not constant and will not be less than a minute (some data daily or weekly).