title: partial constraint EXCLUDE USING gist
body: <p>I have the following constraint:</p>
  
  <pre><code>ALTER TABLE my_table
    ADD CONSTRAINT no_overlap EXCLUDE USING gist (
      product_id WITH =,
      applicable_period WITH &amp;&amp;
    )
  </code></pre>
  
  <p>Now I realized, that this should only be checked conditionally, e.g.</p>
  
  <pre><code>ALTER TABLE my_table
    ADD CONSTRAINT no_overlap EXCLUDE USING gist (
      product_id WITH =,
      applicable_period WITH &amp;&amp;
    )
    WHERE my_table.user_id IS NULL
  </code></pre>
  
  <p>Is this possible and otherwise how can I achieve this in an efficient/advised way? (I could add a trigger, but I hope there is more elegant/efficient approaches).</p>
  
  <p>Should I resort to table partition?
  Thank you</p>