Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-14808

Support ORDER BY with 2ndary Indexes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Normal
    • Resolution: Unresolved
    • None
    • Legacy/CQL
    • None
    • Apache Cassandra 3.11.3

    • Normal

    Description

       Suppose we have a generic table:

      CREATE TABLE base_table(
          partition1 uuid,
          ...
          partitionN uuid,
          static_column text static,
          clustering1 uuid,
          ...
          clusteringM uuid,
          regular text,
          list_text list,
          set_text set,
          map_int_text map<int, text>,
          PRIMARY KEY((partition1, ..., partitionN), clustering1, ... , clusteringN)
      );
      

       

      And create an index on regular text column, the schema of the index table will be:

      CREATE TABLE regular_idx(
          regular text,
          partitionColumns blob,
          clustering1 uuid,
          ...
          clusteringM uuid,
          PRIMARY KEY((regular), partitionColumns, clustering1, ..., clusteringM)
      );
      

       

      Then it's possible to execute queries like:

      SELECT * FROM base_table WHERE regular = <some_value_0> AND partition1 = <some_value_1> AND ... AND partitionN = <some_value_N> ORDER BY clustering1;

       

      However, CQL3 would check if the secondary index is used WITH order by during prepare a select statement, and throw an exception at once for queries like above. 

      Could we support ORDER BY with 2ndary Indexes at least for above query pattern?   

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            Double Infinity Yan Yao
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated: