You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Katsutoshi <na...@gmail.com> on 2013/09/20 08:07:37 UTC

select count query not working at cassandra 2.0.0

I would like to use select count query.
Although it was work at Cassandra 1.2.9, but there is a situation which
does not work at Cassandra 2.0.0.
so, If some row is deleted, 'select count query' seems to return the wrong
value.
Did anything change by Cassandra 2.0.0 ? or Have I made a mistake ?

My test procedure is as follows:

### At Cassandra 1.2.9

1) create table, and insert two rows

```
cqlsh:test> CREATE TABLE count_hash_test (key text, value text, PRIMARY KEY
(key));
cqlsh:test> INSERT INTO count_hash_test (key, value) VALUES ('key1',
'value');
cqlsh:test> INSERT INTO count_hash_test (key, value) VALUES ('key2',
'value');
```

2) do a select count query, it returns 2 which is expected

```
cqlsh:test> SELECT * FROM count_hash_test;

 key  | value
------+-------
 key1 | value
 key2 | value

cqlsh:test> SELECT COUNT(*) FROM count_hash_test;

 count
-------
     2
```

3) delete one row

```
cqlsh:test> DELETE FROM count_hash_test WHERE key='key1';
```

4) do a select count query, it returns 1 which is expected

```
cqlsh:test> SELECT * FROM count_hash_test;

 key  | value
------+-------
 key2 | value

cqlsh:test> SELECT COUNT(*) FROM count_hash_test;

 count
-------
     1
```

### At Cassandra 2.0.0

1) create table, and insert two rows

```
cqlsh:test> CREATE TABLE count_hash_test (key text, value text, PRIMARY KEY
(key));
cqlsh:test> INSERT INTO count_hash_test (key, value) VALUES ('key1',
'value');
cqlsh:test> INSERT INTO count_hash_test (key, value) VALUES ('key2',
'value');
```

2) do a select count query, it returns 2  which is expected

```
cqlsh:test> SELECT * FROM count_hash_test;

 key  | value
------+-------
 key1 | value
 key2 | value

cqlsh:test> SELECT COUNT(*) FROM count_hash_test;

 count
-------
     2
```

3) delete one row

```
cqlsh:test> DELETE FROM count_hash_test WHERE key='key1';
```

4) do a select count query, but it returns 0 which is NOT expected

```
cqlsh:test> SELECT * FROM count_hash_test;

 key  | value
------+-------
 key2 | value

cqlsh:test> SELECT COUNT(*) FROM count_hash_test;

 count
-------
     0
```

Could anyone help me for this? thanks.

Katsutoshi