title: Clustered index in PostgreSQL?
body: <p>I have a table :</p>
  
  <pre><code>CREATE TABLE users (
          id BIGSERIAL PRIMARY KEY,
          first_name varchar(255) NOT NULL,
          last_name varchar(255) NOT NULL,
          cell_id   BIGINT                  
          ...
  )
  </code></pre>
  
  <p>cell_id is an uint64 from s2 and can represent any position on the planet.</p>
  
  <p>-> <a href="http://blog.christianperone.com/2015/08/googles-s2-geometry-on-the-sphere-cells-and-hilbert-curve/" rel="nofollow noreferrer">click here for good description of s2</a></p>
  
  <p>Now I'd like to have an index on cell_id mostly to use an equality operator.</p>
  
  <pre><code>CREATE INDEX user_position ON users (cell_id);
  </code></pre>
  
  <p>But now I'm afraid that this index is going to be overly updated and queried and in the end lead up to deadlocks.</p>
  
  <p>So I've had the idea of doing something like this</p>
  
  <pre><code>CREATE INDEX user_position_even ON users (cell_id) WHERE user id % 2 = 0
  CREATE INDEX user_position_odd ON users (cell_id) WHERE user id % 2 = 1
  </code></pre>
  
  <p>and even may be add more indexes/scarcity.</p>
  
  <p>Now I have some questions: </p>
  
  <ol>
  <li>Will Postgres use both indexes when I do a query? </li>
  <li>Would this help to keep performances up?</li>
  <li>Was my first concern wrong?</li>
  <li>Should I just have different tables instead of indexes?</li>
  <li>Would there be another way of doing this better?</li>
  </ol>