can not count distinct in scyllaDB?

559 views
Skip to first unread message

max19950618@gmail.com

<max19950618@gmail.com>
unread,
Jun 17, 2019, 12:37:10 AM6/17/19
to ScyllaDB users
hello everyone

I met a question about scylladb.
today I want to count distinct multiple partition key , but it seems not work for me.

For example.

 app_id | env_id | uid
--------+--------+-------------
      1 |      2 | 987g6h89183
      1 |      4 | 987g6h89183

I want to count distinct uid in scylla. 
By rights, it will return value equals to '1'. but it can not work.

thus , I want to check if can count distinct in scyllaDB.

Thank you.

Max

Tzach Livyatan

<tzach@scylladb.com>
unread,
Jun 17, 2019, 3:24:09 AM6/17/19
to ScyllaDB users
Hi Max
The SELECT command does include DISTINCT[1], but I'm not sure it fits your needs.
Can you please share the full example, including the schema (CREATE TABLE) and CQL query?

THanks
Tzach

[1] https://docs.scylladb.com/getting-started/dml/#select-statement

--
You received this message because you are subscribed to the Google Groups "ScyllaDB users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scylladb-user...@googlegroups.com.
To post to this group, send email to scyllad...@googlegroups.com.
Visit this group at https://groups.google.com/group/scylladb-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/scylladb-users/24f8cb51-e88b-4d6f-83c3-c2f8c06fa476%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

max19950618@gmail.com

<max19950618@gmail.com>
unread,
Jun 17, 2019, 3:30:46 AM6/17/19
to ScyllaDB users

hi Tzach

For example:
(table schema)
```
app_id int,
env_id int,
uid text,
ts int,
PRIMARY KEY ((app_id,env_id,uid),ts)
```

following CQL command is my need ideally:
```
SELECT COUNT(DISTINCT app_id,env_id,uid) FROM table WHERE app_id=1 AND env_id=2 ALLOW FILTERING;
```

By rights, it will return '1'. But it can not work.


Tzach Livyatan於 2019年6月17日星期一 UTC+8下午3時24分09秒寫道:
Hi Max
The SELECT command does include DISTINCT[1], but I'm not sure it fits your needs.
Can you please share the full example, including the schema (CREATE TABLE) and CQL query?

THanks
Tzach

[1] https://docs.scylladb.com/getting-started/dml/#select-statement

On Mon, Jun 17, 2019 at 7:37 AM <max19...@gmail.com> wrote:
hello everyone

I met a question about scylladb.
today I want to count distinct multiple partition key , but it seems not work for me.

For example.

 app_id | env_id | uid
--------+--------+-------------
      1 |      2 | 987g6h89183
      1 |      4 | 987g6h89183

I want to count distinct uid in scylla. 
By rights, it will return value equals to '1'. but it can not work.

thus , I want to check if can count distinct in scyllaDB.

Thank you.

Max

--
You received this message because you are subscribed to the Google Groups "ScyllaDB users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scyllad...@googlegroups.com.

Tzach Livyatan

<tzach@scylladb.com>
unread,
Jun 17, 2019, 8:56:27 AM6/17/19
to ScyllaDB users
Thanks
This syntax is indeed not supported with CQL Select

On Mon, Jun 17, 2019 at 10:30 AM <max19...@gmail.com> wrote:

hi Tzach

For example:
(table schema)
```
app_id int,
env_id int,
uid text,
ts int,
PRIMARY KEY ((app_id,env_id,uid),ts)
```

 
following CQL command is my need ideally:
```
SELECT COUNT(DISTINCT app_id,env_id,uid) FROM table WHERE app_id=1 AND env_id=2 ALLOW FILTERING;
```


If I understand correctly you try to count all the clustering key values in one partition
If this is the case, reading all of them and do it in the App side should be pretty efficient

 
To unsubscribe from this group and stop receiving emails from it, send an email to scylladb-user...@googlegroups.com.

To post to this group, send email to scyllad...@googlegroups.com.
Visit this group at https://groups.google.com/group/scylladb-users.

max19950618@gmail.com

<max19950618@gmail.com>
unread,
Jun 17, 2019, 9:47:23 PM6/17/19
to ScyllaDB users
OK, I got it .
Thank you. :)

Tzach Livyatan於 2019年6月17日星期一 UTC+8下午8時56分27秒寫道:
Reply all
Reply to author
Forward
0 new messages