Re: 答复: 答复: A difficult data model with C*

2016-11-10 Thread Benjamin Roth
This is the reason why One would like to use an mv for it. An mv Handels this. It adds a clustering Key while preserving uniqueness of the original pk. Am 11.11.2016 02:33 schrieb "Gang Liu" : > I guess orignal design is keep one record for one video per user. maybe > their app will report many p

Re: 答复: 答复: A difficult data model with C*

2016-11-10 Thread Gang Liu
I guess orignal design is keep one record for one video per user. maybe their app will report many play records when user watching one video. So there will be many records when change primary key to (user_name, last_time). Also SELECT * FROM user_views WHERE user_name = ? LIMIT 10 without group by

Re: 答复: 答复: A difficult data model with C*

2016-11-10 Thread Benjamin Roth
Yes sorry. Was irritated by the fact that Video id wasn't. Anyway probably an mv could be a way to go. Am 10.11.2016 13:38 schrieb "Carlos Alonso" : Hi Ben, you're right, but in my example the last_time timestamp field is actually part of the primary key. Regards Carlos Alonso | Software Engine

Re: 答复: 答复: A difficult data model with C*

2016-11-10 Thread Carlos Alonso
Hi Ben, you're right, but in my example the last_time timestamp field is actually part of the primary key. Regards Carlos Alonso | Software Engineer | @calonso On 10 November 2016 at 11:50, Benjamin Roth wrote: > I pretty much guess the CQL you posted is invalid.

Re: 答复: 答复: A difficult data model with C*

2016-11-10 Thread Benjamin Roth
I pretty much guess the CQL you posted is invalid. You cannot set a clustering column that is not part of the primary key. But you can use a materialized view to append the last_time to the primary key and still preserver uniqueness of username + vedio_id (guess it is a typo in vedio). 2016-11-10

Re: 答复: 答复: A difficult data model with C*

2016-11-10 Thread Carlos Alonso
What about having something like CREATE TABLE user_views ( user_name text, video_id text, position int, last_time timestamp, PRIMARY KEY(user_name, last_time) ) WITH CLUSTERING ORDER BY (last_time DESC); Where you insert a record everytime a user watches a video and then having a batch

Re: 答复: 答复: A difficult data model with C*

2016-11-10 Thread Vladimir Yudovin
>Do you mean the oldest one should be removed when a new play is added? Sure. As you described the issue "the last ten items may be adequate for the business" Best regards, Vladimir Yudovin, Winguzone - Hosted Cloud Cassandra Launch your cluster in minutes. On Wed, 09 Nov 2016 20:4

答复: 答复: A difficult data model with C*

2016-11-09 Thread Diamond ben
The solution maybe work. However, the play list will grow over time and somebody maybe has ten thousands that will slow down the query and sort . Do you mean the oldest one should be removed when a new play is added? BTW, the version is 2.1.16 in our live system. BRs, BEN ___