title: How to create TimescaleDB Hypertable with time partitioning on non unique timestamp?
body: <p>I have just started to use TimescaleDB and want to create a hypertable on a table with events.
  Originally I thought of following the conventional pattern of:</p>
  <pre><code>CREATE TABLE event (
    id serial PRIMARY KEY,
    ts timestamp with time zone NOT NULL,
    details varchar(255) NOT NULL
  );
  
  CREATE INDEX event_ts_idx on event(ts);
  </code></pre>
  <p>However, when I tried to create the hypertable with the following query:</p>
  <pre><code>SELECT create_hypertable('event', 'ts');
  </code></pre>
  <p>I got: <code>ERROR:  cannot create a unique index without the column &quot;ts&quot; (used in partitioning)</code></p>
  <p>After doing some research, it seems that the timestamp itself needs to be the (or part of the) primary key.</p>
  <p>However, I do not want the timestamp <code>ts</code> to be unique. It is very likely that these high frequency events will coincide in the same microsecond (the maximum resolution of the <code>timestamp</code> type). It is the whole reason why I am looking into TimescaleDB in the first place.</p>
  <p>What is the best practice in this case?</p>
  <p>I was thinking of maybe keeping the <code>serial id</code> as part of the primary key, and making it composite like this:</p>
  <pre><code>CREATE TABLE event_hyper (
    id serial,
    ts timestamp with time zone NOT NULL,
    details varchar(255) NOT NULL,
    PRIMARY KEY (id, ts)
  );
  
  SELECT create_hypertable('event_hyper', 'ts');
  </code></pre>
  <p>This sort of works, but I am unsure if it is the right approach, or if I am creating a complicated primary key which will slow down inserts or create other problems.</p>
  <p>What is the right approach when you have possible collision in timestamps when using TimescaleDB hypertables?</p>