cyclist_by_age-mv

Supports queries by age without an index or allow filtering.

Supports queries by age without an index or allow filtering.

SOURCE 'cyclist_base-table.cql';

// START-dropmv
DROP MATERIALIZED VIEW IF EXISTS cycling.cyclist_by_age;
// END-dropmv

// START-age
CREATE MATERIALIZED VIEW cycling.cyclist_by_age 
   AS SELECT age, cid, birthday, country, name FROM cycling.cyclist_base 
WHERE age IS NOT NULL AND cid IS NOT NULL
PRIMARY KEY (age, cid)
WITH CLUSTERING ORDER BY (cid ASC)
     AND caching = { 'keys' : 'ALL', 'rows_per_partition' : '100' }
     AND comment = 'Based on table cyclist';
 // END-age

// add a comment to describe the table
// START-comment
ALTER MATERIALIZED VIEW cycling.cyclist_by_age 
WITH comment = 'A most excellent and useful view'
AND bloom_filter_fp_chance = 0.02;
// END-comment

// alter example
// START-compression
ALTER MATERIALIZED VIEW cycling.cyclist_by_age 
WITH compression = { 
   'sstable_compression' : 'DeflateCompressor', 
   'chunk_length_kb' : 64 }
AND compaction = {
   'class': 'SizeTieredCompactionStrategy', 
   'max_threshold': 64};
// END-compression   

// alter example
// START-cache
ALTER MATERIALIZED VIEW cycling.cyclist_by_age 
WITH caching = { 
   'keys' : 'NONE', 
   'rows_per_partition' : '15' };
// END-cache

// START-test
INSERT INTO cycling.cyclist_base (cid,name,age,birthday,country) 
VALUES ( 
         d1aad83b-be60-47a4-bd6e-069b8da0d97b,
         'Johannes HEIDER', 
         27, 
         '1987-09-04',
         'Germany');
// END-test