You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Philip G <gp...@gpcentre.net> on 2014/03/18 00:27:45 UTC

Cassandra (2.0.4) pagination and total records?

Is there a way to get "total number of records" when working with limit and
internal pagination? Every example I found online was purely about using
LIMIT and sort_col > token(sort_col). Nothing about getting the total
matching records.

(PS: if there's a better group to ask CQL questions, please let me know.
Thanks)

---
Philip
gp@gpcentre.net
http://www.gpcentre.net/

Re: Cassandra (2.0.4) pagination and total records?

Posted by Iain Finlayson <ia...@datastax.com>.
Hi Philip,

Read this blog post

http://www.wentnet.com/blog/?p=24

It talks about COUNT but might give some answers to your first question.

On Monday, March 17, 2014, Philip G <gp...@gpcentre.net> wrote:

> On Mon, Mar 17, 2014 at 4:54 PM, Robert Coli <rcoli@eventbrite.com<javascript:_e(%7B%7D,'cvml','rcoli@eventbrite.com');>
> > wrote:
>
>> The form of your question suggests you are Doing It Wrong, FWIW.
>>
>
>
> Okay, let me ask different question: how do you go about data browsing in
> a CQL3 table? Especially in situations were a single query could return a
> couple thousand records, and we want to limit it by a 100 at a time.
>
> Please, feel free to point me in the right direction, if necessary. I
> admit I'm still figuring out Cassandra/CQL. But my knowledge has been
> exponentially expanding on a daily basis. I want to understand this more,
> and possible solution to problems I'm running into migrating from a RDBMS
> (mssql) to Cassandra. I've figured out a lot of stuff, but have not quite
> resolved this use-case.
>
> Thanks,
>
> ---
> Philip
> gp@gpcentre.net <javascript:_e(%7B%7D,'cvml','gp@gpcentre.net');>
> http://www.gpcentre.net/
>


-- 
Iain Finlayson
Solutions Engineer
718-483-6427
iain@datastax.com



<http://www.datastax.com/what-we-offer/products-services/training/virtual-training>

Re: Cassandra (2.0.4) pagination and total records?

Posted by DuyHai Doan <do...@gmail.com>.
With Cassandra 2.0.x and Java driver 2.0.0 you can set the fetch size on
the query and then use Resulset.iterator(). It will iterate over your data
set by loading batches of size = fetch size
Le 18 mars 2014 01:39, "Philip G" <gp...@gpcentre.net> a écrit :

> Thanks for the links.
>
> As I'm messing around with CQL, I'm realizing Cassandra isn't going to do
> what I need. Quite simply, here's a basic layout of my table:
>
> myTable (
> visit_dt timestamp,
> cid ascii,
> company text,
> // ... other stuff
>        primary key (visit_dt, cid)
> );
> index on (company)
>
> My query starts off with visit_dt IN ('2014-01-17'). In Cassandra, I
> essentially get back just 1 wide row (but shows as many within CQL3). I can
> filter that via AND company='my company' due to the index. However, if I
> LIMIT 10; there isn't a way to get "the next 10" records as token() only
> works on the partition key, and each row has the same partition key.
>
> Or am I missing something? Is there a way I've not discovered to get "the
> next 10" on a single wide row?
>
>
> ---
> Philip
> gp@gpcentre.net
> http://www.gpcentre.net/
>
>
> On Mon, Mar 17, 2014 at 5:12 PM, Tupshin Harper <tu...@tupshin.com>wrote:
>
>> Read the automatic paging portion of this post :
>> http://www.datastax.com/dev/blog/client-side-improvements-in-cassandra-2-0
>> On Mar 17, 2014 8:09 PM, "Philip G" <gp...@gpcentre.net> wrote:
>>
>>> On Mon, Mar 17, 2014 at 4:54 PM, Robert Coli <rc...@eventbrite.com>wrote:
>>>
>>>> The form of your question suggests you are Doing It Wrong, FWIW.
>>>>
>>>
>>>
>>> Okay, let me ask different question: how do you go about data browsing
>>> in a CQL3 table? Especially in situations were a single query could return
>>> a couple thousand records, and we want to limit it by a 100 at a time.
>>>
>>> Please, feel free to point me in the right direction, if necessary. I
>>> admit I'm still figuring out Cassandra/CQL. But my knowledge has been
>>> exponentially expanding on a daily basis. I want to understand this more,
>>> and possible solution to problems I'm running into migrating from a RDBMS
>>> (mssql) to Cassandra. I've figured out a lot of stuff, but have not quite
>>> resolved this use-case.
>>>
>>> Thanks,
>>>
>>> ---
>>> Philip
>>> gp@gpcentre.net
>>> http://www.gpcentre.net/
>>>
>>
>

Re: Cassandra (2.0.4) pagination and total records?

Posted by Philip G <gp...@gpcentre.net>.
Thanks for the links.

As I'm messing around with CQL, I'm realizing Cassandra isn't going to do
what I need. Quite simply, here's a basic layout of my table:

myTable (
visit_dt timestamp,
cid ascii,
company text,
// ... other stuff
       primary key (visit_dt, cid)
);
index on (company)

My query starts off with visit_dt IN ('2014-01-17'). In Cassandra, I
essentially get back just 1 wide row (but shows as many within CQL3). I can
filter that via AND company='my company' due to the index. However, if I
LIMIT 10; there isn't a way to get "the next 10" records as token() only
works on the partition key, and each row has the same partition key.

Or am I missing something? Is there a way I've not discovered to get "the
next 10" on a single wide row?


---
Philip
gp@gpcentre.net
http://www.gpcentre.net/


On Mon, Mar 17, 2014 at 5:12 PM, Tupshin Harper <tu...@tupshin.com> wrote:

> Read the automatic paging portion of this post :
> http://www.datastax.com/dev/blog/client-side-improvements-in-cassandra-2-0
> On Mar 17, 2014 8:09 PM, "Philip G" <gp...@gpcentre.net> wrote:
>
>> On Mon, Mar 17, 2014 at 4:54 PM, Robert Coli <rc...@eventbrite.com>wrote:
>>
>>> The form of your question suggests you are Doing It Wrong, FWIW.
>>>
>>
>>
>> Okay, let me ask different question: how do you go about data browsing in
>> a CQL3 table? Especially in situations were a single query could return a
>> couple thousand records, and we want to limit it by a 100 at a time.
>>
>> Please, feel free to point me in the right direction, if necessary. I
>> admit I'm still figuring out Cassandra/CQL. But my knowledge has been
>> exponentially expanding on a daily basis. I want to understand this more,
>> and possible solution to problems I'm running into migrating from a RDBMS
>> (mssql) to Cassandra. I've figured out a lot of stuff, but have not quite
>> resolved this use-case.
>>
>> Thanks,
>>
>> ---
>> Philip
>> gp@gpcentre.net
>> http://www.gpcentre.net/
>>
>

Re: Cassandra (2.0.4) pagination and total records?

Posted by Tupshin Harper <tu...@tupshin.com>.
Read the automatic paging portion of this post :
http://www.datastax.com/dev/blog/client-side-improvements-in-cassandra-2-0
On Mar 17, 2014 8:09 PM, "Philip G" <gp...@gpcentre.net> wrote:

> On Mon, Mar 17, 2014 at 4:54 PM, Robert Coli <rc...@eventbrite.com> wrote:
>
>> The form of your question suggests you are Doing It Wrong, FWIW.
>>
>
>
> Okay, let me ask different question: how do you go about data browsing in
> a CQL3 table? Especially in situations were a single query could return a
> couple thousand records, and we want to limit it by a 100 at a time.
>
> Please, feel free to point me in the right direction, if necessary. I
> admit I'm still figuring out Cassandra/CQL. But my knowledge has been
> exponentially expanding on a daily basis. I want to understand this more,
> and possible solution to problems I'm running into migrating from a RDBMS
> (mssql) to Cassandra. I've figured out a lot of stuff, but have not quite
> resolved this use-case.
>
> Thanks,
>
> ---
> Philip
> gp@gpcentre.net
> http://www.gpcentre.net/
>

Re: Cassandra (2.0.4) pagination and total records?

Posted by Philip G <gp...@gpcentre.net>.
On Mon, Mar 17, 2014 at 4:54 PM, Robert Coli <rc...@eventbrite.com> wrote:

> The form of your question suggests you are Doing It Wrong, FWIW.
>


Okay, let me ask different question: how do you go about data browsing in a
CQL3 table? Especially in situations were a single query could return a
couple thousand records, and we want to limit it by a 100 at a time.

Please, feel free to point me in the right direction, if necessary. I admit
I'm still figuring out Cassandra/CQL. But my knowledge has been
exponentially expanding on a daily basis. I want to understand this more,
and possible solution to problems I'm running into migrating from a RDBMS
(mssql) to Cassandra. I've figured out a lot of stuff, but have not quite
resolved this use-case.

Thanks,

---
Philip
gp@gpcentre.net
http://www.gpcentre.net/

Re: Cassandra (2.0.4) pagination and total records?

Posted by Robert Coli <rc...@eventbrite.com>.
On Mon, Mar 17, 2014 at 4:27 PM, Philip G <gp...@gpcentre.net> wrote:

> Is there a way to get "total number of records" when working with limit
> and internal pagination? Every example I found online was purely about
> using LIMIT and sort_col > token(sort_col). Nothing about getting the total
> matching records.
>

The form of your question suggests you are Doing It Wrong, FWIW.

=Rob