I remembered why we have the additional index (and...
# general
j
I remembered why we have the additional index (and the documentation is not correct here)
Copy code
sql
    -------------------- TimescaleDB table for process values -------------------- 
     CREATE TABLE IF NOT EXISTS processValueTable 
     ( 
         timestamp               TIMESTAMPTZ                         NOT NULL, 
         asset_id                SERIAL                              REFERENCES assetTable (id), 
         valueName               TEXT                                NOT NULL, 
         value                   DOUBLE PRECISION                    NULL, 
         UNIQUE(timestamp, asset_id, valueName) 
     ); 
     -- creating hypertable 
     SELECT create_hypertable('processValueTable', 'timestamp'); 
  
     -- creating an index to increase performance 
     CREATE INDEX ON processValueTable (asset_id, timestamp DESC); 
  
     -- creating an index to increase performance 
     CREATE INDEX ON processValueTable (valuename); 
  
     -- create an index to increase performance 
     CREATE INDEX ON processvaluetable(valuename, asset_id) WITH (timescaledb.transaction_per_chunk);
We added the one on value name so that we could speed up the distinct(valuename) query for each asset_id. So we could show the users which value names he can choose. Probably not relevant for the datamodel of you @Richard Shaw