Scylla: cqlsh: Can only select at most 100 rows when filtering by clustering key

Created on 21 Sep 2016  Â·  9Comments  Â·  Source: scylladb/scylla

_Installation details_
Scylla version (or git commit hash): 906250dcbdbbee26c5892381ace90ec4d5e6223a

Reproducer:

$ echo "create keyspace ks with replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };" | bin/cqlsh
$ echo "create table ks.cf(p text, c1 text, c2 text, v int, primary key (p, c1, c2));" |  bin/cqlsh
$ for i in `seq 1 1000`; do echo  "insert into ks.cf (p, c1, c2, v) values ('key1', 'a', '$i', 0);" ; done | bin/cqlsh
$ echo "select count(*) from ks.cf;" |  bin/cqlsh

 count
-------
  1000

(1 rows)
$ echo "select count(*) from ks.cf where c1 = 'a' allow filtering;" |  bin/cqlsh

 count
-------
   100

(1 rows)

Cassandra returns the correct count.

bug

Most helpful comment

100 is the default page_size when using cqlsh, and paging is on by default.

echo "paging off; select count(*) from ks.cf where p = 'key1' and c1 = 'a';" |  bin/cqlsh
Disabled Query paging.

 count
-------
  1000

(1 rows)

This returns the correct value. So it seems our paging support is buggy?

All 9 comments

Is this related to another issue ?

To verify that I understand the issue we do not enforce the "100 row limit rule" when allow filtering is added

It's unrelated to other issues.

I'm querying a table with allow filtering and I'm only getting back 100 rows. Is this expected behavior? Cassandra returns everything.

Its a bug - yet I expect cassandra would also limit the amount of rows it
allows under allow filtering

On Sun, Sep 25, 2016 at 3:05 PM, Duarte Nunes [email protected]
wrote:

It's unrelated to other issues.

I'm querying a table with allow filtering and I'm only getting back 100
rows. Is this expected behavior? Cassandra returns everything.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/scylladb/scylla/issues/1684#issuecomment-249417972,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADThCNCfLKLERqqIYwDxdfOXAe3x_hXUks5qtmOggaJpZM4KDQcA
.

It seems this happens whenever we filter a clustering key, regardless of allow filtering. The following doesn't return the correct result either:

$ echo "select count(*) from ks.cf where p = 'key1' and c1 = 'a';" |  bin/cqlsh

 count
-------
   100

(1 rows)

100 is the default page_size when using cqlsh, and paging is on by default.

echo "paging off; select count(*) from ks.cf where p = 'key1' and c1 = 'a';" |  bin/cqlsh
Disabled Query paging.

 count
-------
  1000

(1 rows)

This returns the correct value. So it seems our paging support is buggy?

That changes the priority ....

Surprise, surprise, incorrect handling of clustering row ranges in paging code. The code assumes that ck range [a, a] is singular and contains only one row.

Yikes :/ I see fetch_page() is using clustering_key_prefix::less_compare.

Yes, the proper solution requires #1446 fixed. Looks like a workaround would have to do for now.

Was this page helpful?
0 / 5 - 0 ratings