You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Benjamin Lerer (JIRA)" <ji...@apache.org> on 2015/09/22 18:57:06 UTC

[jira] [Comment Edited] (CASSANDRA-10380) SELECT count within a partition does not respect LIMIT

    [ https://issues.apache.org/jira/browse/CASSANDRA-10380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14902969#comment-14902969 ] 

Benjamin Lerer edited comment on CASSANDRA-10380 at 9/22/15 4:56 PM:
---------------------------------------------------------------------

I add a look at the code. My understanding is that [~slebresne] changed this behaviour in CASSANDRA-8099 and put some comment about it in the code.
{quote}
If we aggregate, the limit really apply to the number of rows returned to the user, not to what is queried, and
since in practice we currently only aggregate at top level (we have no GROUP BY support yet), we'll only ever
return 1 result and can therefore basically ignore the user LIMIT in this case.
{quote} 

Database like MySQL do it the same way.

This means that the behaviour is good in 3.0 but not in 2.2.


was (Author: blerer):
I add a look at the code. My understanding is that @Sylvain changed this behaviour in CASSANDRA-8099 and put some comment about it in the code.
{quote}
If we aggregate, the limit really apply to the number of rows returned to the user, not to what is queried, and
since in practice we currently only aggregate at top level (we have no GROUP BY support yet), we'll only ever
return 1 result and can therefore basically ignore the user LIMIT in this case.
{quote} 

Database like MySQL do it the same way.

This means that the behaviour is good in 3.0 but not in 2.2.

> SELECT count within a partition does not respect LIMIT
> ------------------------------------------------------
>
>                 Key: CASSANDRA-10380
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10380
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Core
>            Reporter: Adam Holmberg
>            Assignee: Benjamin Lerer
>            Priority: Minor
>
> {code}
> cassandra@cqlsh> create KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};
> cassandra@cqlsh> use test;
> cassandra@cqlsh:test> create table t (k int, c int, v int, primary key (k, c));
> cassandra@cqlsh:test> INSERT INTO t (k, c, v) VALUES (0, 0, 0);
> cassandra@cqlsh:test> INSERT INTO t (k, c, v) VALUES (0, 1, 0);
> cassandra@cqlsh:test> INSERT INTO t (k, c, v) VALUES (0, 2, 0);
> cassandra@cqlsh:test> select * from t where k = 0;
>  k | c | v
> ---+---+---
>  0 | 0 | 0
>  0 | 1 | 0
>  0 | 2 | 0
> (3 rows)
> cassandra@cqlsh:test> select count(*) from t where k = 0 limit 2;
>  count
> -------
>      3
> (1 rows)
> {code}
> Expected: count should return 2, according to limit.
> Actual: count of all rows in partition
> This manifests in 3.0, does not appear in 2.2



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)