title: Best option for indexing 3 columns where only 2 columns are queried at a time in Postgresql
body: <p>For the following scenario, what is the most efficient indexing? 3 columns: </p>
  
  <p><code>user_id, created_at, and name.</code></p>
  
  <p>((<code>user_id</code> and <code>created_at</code>) are queried together and (<code>user_id</code> and <code>name</code>) are queried together. </p>
  
  <p>The <code>created_at</code> and <code>name</code> are exclusively used to sort. As an example: </p>
  
  <p><code>SELECT  "items".* FROM "items"  WHERE "items"."user_id" = $1  ORDER BY created_at [["user_id", 1]]</code></p>
  
  <p>or </p>
  
  <p><code>SELECT  "items".* FROM "items"  WHERE "items"."user_id" = $1  ORDER BY name [["user_id", 1]]</code></p>
  
  <p>I know that indexing is left to right so would two multi-column indexes on <code>"user_id, created_at"</code> and <code>"user_id, name"</code> be best or is there a way to "share" the user_id index (with something like 3 indexes on user_id, created_at, and name individually)?</p>