title: Cassandra performance on clustered column sorting vs secondary index
body: <p>my schema is : <br/><br/><strong>A)</strong></p>
  
  <pre><code>CREATE TABLE friend_list (
      userId uuid,
      friendId uuid,
      accepted boolean, 
      ts_accepted timestamp,
      PRIMARY KEY ((userId) ,accepted, ts_accepted)
     ) with clustering order by (accepted desc, ts_accepted desc);
  </code></pre>
  
  <p><strong>B)</strong><br/></p>
  
  <pre><code>CREATE TABLE friend_list (
          userId uuid,
          friendId uuid,
          accepted boolean, 
          ts_accepted timestamp,
          PRIMARY KEY (userId , ts_accepted)
         ) with clustering order by (ts_accepted desc);
  CREATE INDEX ON friend_list (accepted);
  </code></pre>
  
  <p>Which will give the best performance for the query :</p>
  
  <pre><code>SELECT * FROM friend_list WHERE userId="---" AND accepted=true;
  </code></pre>
  
  <p>With my understanding, Cassandra automatically sorts the clustered columns in ASC order and we specify DESC if we need to change the default sorting order for efficient queries.</p>
  
  <p>With my schema A, I am making 'accepted' as a clustered key, but I need to sort it unnecessarily as I definitely have to sort 'ts_accepted' to DESC. 
  Will this unwanted sorting of 'accepted' affects performance ?</p>
  
  <p>If so, say I am making 'accepted' as secondary index in schema B. I know secondary index are not bad for low cardinal values(boolean). But still the query might have some performance issue.</p>
  
  <p>Please let me know the efficient way on achieving this query.  </p>