less than a minute
This table contains all reported counts of the assets.
key | data type | description | example |
---|---|---|---|
timestamp | timestamptz | Entry timestamp | 0 |
asset_id | serial | Asset id (see assetTable) | 1 |
count | integer | A count greater 0 | 1 |
CREATE TABLE IF NOT EXISTS countTable
(
timestamp TIMESTAMPTZ NOT NULL,
asset_id SERIAL REFERENCES assetTable (id),
count INTEGER CHECK (count > 0),
UNIQUE(timestamp, asset_id)
);
-- creating hypertable
SELECT create_hypertable('countTable', 'timestamp');
-- creating an index to increase performance
CREATE INDEX ON countTable (asset_id, timestamp DESC);