title: When comparing insert performance between postgres and timescaledb, timescaledb didn't perform that well?
body: <p>I tried an insert query performance test. Here are the numbers :-</p>
  <p><strong>Postgres</strong></p>
  <p>Insert : Avg Execution Time For 10 inserts of 1 million rows :  6260 ms</p>
  <p><strong>Timescale</strong></p>
  <p>Insert : Avg Execution Time For 10 inserts of 1 million rows :  10778 ms</p>
  <p>Insert Queries:</p>
  <pre class="lang-sql prettyprint-override"><code>-- Testing SQL Queries
  
  --Join table
  
  CREATE TABLE public.sensors(
    id SERIAL PRIMARY KEY,
    type VARCHAR(50),
    location VARCHAR(50)
  );
  
  
  -- Postgres table
  CREATE TABLE sensor_data (
    time TIMESTAMPTZ NOT NULL,
    sensor_id INTEGER,
    temperature DOUBLE PRECISION,
    cpu DOUBLE PRECISION,
    FOREIGN KEY (sensor_id) REFERENCES sensors (id)
  );
  
  CREATE INDEX idx_sensor_id
  ON sensor_data(sensor_id);
  
  -- TimescaleDB table
  CREATE TABLE sensor_data_ts (
    time TIMESTAMPTZ NOT NULL,
        sensor_id INTEGER,
    temperature DOUBLE PRECISION,
    cpu DOUBLE PRECISION,
    FOREIGN KEY (sensor_id) REFERENCES sensors (id)
  );
  SELECT create_hypertable('sensor_data_ts', 'time');
  
      
  -- Insert Data
  
  INSERT INTO sensors (type, location) VALUES
  ('a','floor'),
  ('a', 'ceiling'),
  ('b','floor'),
  ('b', 'ceiling');
  
  
  -- Postgres 
  EXPLAIN ANALYSE
  INSERT INTO sensor_data (time, sensor_id, cpu, temperature)
  SELECT
    time,
    sensor_id,
    random() AS cpu,
    random()*100 AS temperature
  FROM generate_series(now() - interval '125 week', now(), interval '5 minute') AS g1(time), generate_series(1,4,1) AS g2(sensor_id); 
  
  
  -- TimescaleDB
  EXPLAIN ANALYSE
  INSERT INTO sensor_data_ts (time, sensor_id, cpu, temperature)
  SELECT
    time,
    sensor_id,
    random() AS cpu,
    random()*100 AS temperature
  FROM generate_series(now() - interval '125 week', now(), interval '5 minute') AS g1(time), generate_series(1,4,1) AS g2(sensor_id);
  </code></pre>
  <p>Am I overlooking any optimizations ?</p>