nosql - Cassandra time series modeling -
nosql - Cassandra time series modeling -
i have table this.
> create table docyard.documents ( > document_id text, > namespace text, > version_id text, > created_at timestamp, > path text, > attributes map<text, text> > primary key (document_id, namespace, version_id, created_at) ) clustering order (namespace asc, version_id asc, created_at > asc) > , bloom_filter_fp_chance = 0.01 > , caching = '{"keys":"all", "rows_per_partition":"none"}' > , comment = '' > , compaction = {'min_threshold': '4', 'class': 'org.apache.cassandra.db.compaction.sizetieredcompactionstrategy', > 'max_threshold': '32'} > , compression = {'sstable_compression': 'org.apache.cassandra.io.compress.lz4compressor'} > , dclocal_read_repair_chance = 0.1 > , default_time_to_live = 0 > , gc_grace_seconds = 864000 > , max_index_interval = 2048 > , memtable_flush_period_in_ms = 0 > , min_index_interval = 128 > , read_repair_chance = 0.0 > , speculative_retry = '99.0percentile'; i want able range queries on next conditions-
select * documents namespace = 'something' , created_at> 'some-value' order created_at allow filtering; select documents namespace = 'something' , path = 'something' , created_at> 'some-value' order created_at allow filtering; i not able create these queries work in manner. tried secondary indexes well. can please help?
i maintain getting or other when trying create work.
first of all, don't utilize secondary indexes or allow filtering. timeseries info perform terribly on time.
to satisfy first query, want restructure primary key , clustering order this:
primary key (namespace, created_at, document_id) ) clustering order (created_at desc, document_id asc); this allow following:
partitioningnamespace. sorting created_at in descending order (most-recent rows read first). uniqueness document_id you not need allow filtering or order by in query, necessary keys provided, , results sorted clustering order. for sec query, create additional query table. because in cassandra, need model tables suit queries. may end-up having several query tables same data, , that's ok.
create table docyardbypath.documents ( document_id text, namespace text, version_id text, created_at timestamp, path text, attributes map<text, text> primary key ((namespace, path), created_at, document_id) ) clustering order (created_at desc, document_id asc); this will:
partition bothnamespace , path. allow rows within unique combinations of namespace , path sorted according clustering order. again, should not need allow filtering or order by in query. cassandra nosql cql3
Comments
Post a Comment