Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Denormalize! You must model your schema in a manner that will enable the types of queries you wish to perform. We create a reverse (aka inverted, inverse) index for such scenarios.</p> <pre><code>CREATE TABLE report( KEY uuid PRIMARY KEY, svc1 bigint, svc2 bigint, svc3 bigint ); CREATE TABLE ReportsByTime( KEY ascii PRIMARY KEY ) with default_validation=uuid AND comparator=uuid; CREATE TABLE ReportsByUser( KEY bigint PRIMARY KEY )with default_validation=uuid AND comparator=uuid; </code></pre> <p>See <a href="http://www.royans.net/arch/cassandra-inverted-index/" rel="nofollow">here</a> for a nice explanation. What you are doing now is generating your own <code>ascii</code> key in the <code>times</code> table, to enable yourself to perform the range slice query you want - it doesn't have to be <code>ascii</code> though just something you can use to programmatically generate your own slice keys with.</p> <p>You can use this approach to facilitate all of your queries, this likely isn't going to suit your application directly but the idea is the same. You can squeeze more out of this by adding meaningful values to the column keys of each table above.</p> <pre><code>cqlsh:tester&gt; select * from report; KEY | svc1 | svc2 | svc3 --------------------------------------+------+------+------ 1381b530-1dd2-11b2-0000-242d50cf1fb5 | 332 | 333 | 334 13818e20-1dd2-11b2-0000-242d50cf1fb5 | 222 | 223 | 224 13816710-1dd2-11b2-0000-242d50cf1fb5 | 112 | 113 | 114 cqlsh:tester&gt; select * from times; KEY,1212051037 | 13818e20-1dd2-11b2-0000-242d50cf1fb5,13818e20-1dd2-11b2-0000-242d50cf1fb5 | 1381b530-1dd2-11b2-0000-242d50cf1fb5,1381b530-1dd2-11b2-0000-242d50cf1fb5 KEY,1212051035 | 13816710-1dd2-11b2-0000-242d50cf1fb5,13816710-1dd2-11b2-0000-242d50cf1fb5 | 13818e20-1dd2-11b2-0000-242d50cf1fb5,13818e20-1dd2-11b2-0000-242d50cf1fb5 KEY,1212051036 | 13818e20-1dd2-11b2-0000-242d50cf1fb5,13818e20-1dd2-11b2-0000-242d50cf1fb5 cqlsh:tester&gt; select * from users; KEY | 13816710-1dd2-11b2-0000-242d50cf1fb5 | 13818e20-1dd2-11b2-0000-242d50cf1fb5 -------------+--------------------------------------+-------------------------------------- 23123123231 | 13816710-1dd2-11b2-0000-242d50cf1fb5 | 13818e20-1dd2-11b2-0000-242d50cf1fb5 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload