cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zachary Marcantel (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-4511) Secondary index support for CQL3 collections
Date Mon, 18 Nov 2013 23:05:21 GMT


Zachary Marcantel commented on CASSANDRA-4511:

I can think of (and need this for) a few use cases. They do revolve around more of a filtering
aspect, however.

It can be said that sometimes models/data/rows belong to a "theoretical list" that contain
infinite possibilities. 

Naturally, you do not want to store all possibilities, but may want to filter on those which
are true while ignoring all other possiblities.

Examples of these lists could be:
- Things of interest to a user
  -- LinkedIn calls these skills, Facebook has 'liked pages', etc
- Movies Watched
  -- Netflix surely doesn't (want to) have a USER x MOVIES sized table
  -- Nor do they want (user x movies) number of columnfamilies
- Places Visited
  -- set yes/no for EVERY location on Earth?

Benchmarks may prove me wrong, but theoretically the performance hit would be minimal if the
data is truly partitioned well, collections are kept small, and secondary indexing used only
as a filter and not data storage.

Dynamic columns may make some of my examples easier, but bring their own headaches (post-filling
dynamically created columns, massively wide tables, largely unused data == disk bloat).

I'll give a couple examples and use [~jbellis] syntax, as well as a potential map-based indexing.

- Users contained in group(s):
-- Note: this could be done with columns, but if we assume groups can contain infinitely many
possibilities (like Facebook groups)
- {code:sql}
SELECT * FROM main.users WHERE 'players' IN groups AND 'admins' NOT IN groups;

- Filter on toggle-based UI elements within user profiles:
SELECT * FROM main.users WHERE notify['email'] = true;

Given a possibly endless list, map rows (or data pieces) onto items within that list:
For instance, user profiles often have 'interests' that could contain one/multiple of thousands
if not millions of possibilities.
Currently, one would have to detail the entirety of the list that has been seen in one of
two ways:
CREATE TABLE main.interests (
    interest_name TEXT PRIMARY KEY,
    users LIST <TEXT>


CREATE TABLE main.users (
    ... other user fields ...
    interests LIST <TEXT>

Both of which would require post-result processing (map-reduce or similar) to find just the
users containing a certain key/value.

Rather, with indexing:
CREATE TABLE main.users (
    name TEXT,
    age INT,
    interests LIST <TEXT>

where 'interests' is a relatively small (~10-25 elements) list that can be filtered by:

SELECT * FROM main.users WHERE 'baseball' IN interests AND 'soccer' IN interests;

> Secondary index support for CQL3 collections 
> ---------------------------------------------
>                 Key: CASSANDRA-4511
>                 URL:
>             Project: Cassandra
>          Issue Type: Improvement
>    Affects Versions: 1.2.0 beta 1
>            Reporter: Sylvain Lebresne
>            Assignee: Sylvain Lebresne
>             Fix For: 2.1
>         Attachments: 4511.txt
> We should allow to 2ndary index on collections. A typical use case would be to add a
'tag set<String>' to say a user profile and to query users based on what tag they have.

This message was sent by Atlassian JIRA

View raw message