Cassandra CQL3 select row keys from table with compound primary key

edofic

I'm using Cassandra 1.2.7 with the official Java driver that uses CQL3.

Suppose a table created by

CREATE TABLE foo ( 
    row int, 
    column int, 
    txt text, 
    PRIMARY KEY (row, column)
);

Then I'd like to preform the equivalent of SELECT DISTINCT row FROM foo

As for my understanding it should be possible to execute this query efficiently inside Cassandra's data model(given the way compound primary keys are implemented) as it would just query the 'raw' table.

I searched the CQL documentation but I didn't find any options to do that.

My backup plan is to create a separate table - something like

CREATE TABLE foo_rows (
    row int,
    PRIMARY KEY (row)
);

But this requires the hassle of keeping the two in sync - writing to foo_rows for any write in foo(also a performance penalty).

So is there any way to query for distinct row(partition) keys?

daniel.bavrin

according to the documentation, from CQL version 3.11, cassandra understands DISTINCT modifier. So you can now write

SELECT DISTINCT row FROM foo

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Delete operation on a CQL3 table in Cassandra

From Dev

Is primary index created on clustering column of a compound primary key in cassandra?

From Dev

Cassandra CQL SELECT/DELETE issue due to primary key constraints

From Dev

Cassandra CQL3 Select statement without LIMIT

From Dev

Cassandra CQL3 Select statement without LIMIT

From Dev

Insertion and retrieval of timestamp into Cassandra CQL3 based table in Python

From Dev

Mapping a table with a compound primary key to a python dictionary

From Dev

How to select from table ordering by primary key

From Dev

Paging Resultsets in Cassandra with compound primary keys - Missing out on rows

From Dev

Select data by Spark from Cassandra using primary key

From Dev

Inserting to cassandra table with a composite primary key from hadoop reduce

From Dev

alter composite primary key in cassandra CQL 3.0

From Dev

Get a random row from a MySQL table with no primary key - optimized

From Dev

Get a random row from a MySQL table with no primary key - optimized

From Dev

Cassandra: SELECT ROW by composite key

From Dev

Cassandra: SELECT ROW by composite key

From Dev

cassandra, select via a non primary key

From Dev

Cassandra table based query and primary key uniqueness

From Dev

Primary Key related CQL3 Queries cases & errors when sorting

From Dev

Select filtered records from a table with composite primary key

From Dev

Cassandra+Solr: table with compact storage and compound key

From Dev

How can a CSV file with counter columns be loaded to a Cassandra CQL3 table

From Dev

How can a CSV file with counter columns be loaded to a Cassandra CQL3 table

From Dev

Cassandra cql: how to select the LAST n rows from a table

From Dev

what's the difference among row key, primary key and index in cassandra?

From Dev

what's the difference among row key, primary key and index in cassandra?

From Dev

SQL Select from a single compound table

From Dev

Increase SELECT performance for table with only primary keys

From Dev

SQL Server : multiple foreign keys from first table linking to the primary key of second table

Related Related

  1. 1

    Delete operation on a CQL3 table in Cassandra

  2. 2

    Is primary index created on clustering column of a compound primary key in cassandra?

  3. 3

    Cassandra CQL SELECT/DELETE issue due to primary key constraints

  4. 4

    Cassandra CQL3 Select statement without LIMIT

  5. 5

    Cassandra CQL3 Select statement without LIMIT

  6. 6

    Insertion and retrieval of timestamp into Cassandra CQL3 based table in Python

  7. 7

    Mapping a table with a compound primary key to a python dictionary

  8. 8

    How to select from table ordering by primary key

  9. 9

    Paging Resultsets in Cassandra with compound primary keys - Missing out on rows

  10. 10

    Select data by Spark from Cassandra using primary key

  11. 11

    Inserting to cassandra table with a composite primary key from hadoop reduce

  12. 12

    alter composite primary key in cassandra CQL 3.0

  13. 13

    Get a random row from a MySQL table with no primary key - optimized

  14. 14

    Get a random row from a MySQL table with no primary key - optimized

  15. 15

    Cassandra: SELECT ROW by composite key

  16. 16

    Cassandra: SELECT ROW by composite key

  17. 17

    cassandra, select via a non primary key

  18. 18

    Cassandra table based query and primary key uniqueness

  19. 19

    Primary Key related CQL3 Queries cases & errors when sorting

  20. 20

    Select filtered records from a table with composite primary key

  21. 21

    Cassandra+Solr: table with compact storage and compound key

  22. 22

    How can a CSV file with counter columns be loaded to a Cassandra CQL3 table

  23. 23

    How can a CSV file with counter columns be loaded to a Cassandra CQL3 table

  24. 24

    Cassandra cql: how to select the LAST n rows from a table

  25. 25

    what's the difference among row key, primary key and index in cassandra?

  26. 26

    what's the difference among row key, primary key and index in cassandra?

  27. 27

    SQL Select from a single compound table

  28. 28

    Increase SELECT performance for table with only primary keys

  29. 29

    SQL Server : multiple foreign keys from first table linking to the primary key of second table

HotTag

Archive