Skip to content

Commit

Permalink
Cassandra performance: Replace sequence ids with time-based UUIDs
Browse files Browse the repository at this point in the history
ref:
 - #99
 - #94
  • Loading branch information
michaelsembwever authored and adejanovski committed May 29, 2017
1 parent 1e37a09 commit f4792a1
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 69 deletions.
70 changes: 42 additions & 28 deletions src/main/resources/db/cassandra/001_Initialize_db.cql
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,27 @@ CREATE TABLE IF NOT EXISTS cluster (
name text PRIMARY KEY,
partitioner text,
seed_hosts set<text>
);
)
WITH compaction = {'class': 'LeveledCompactionStrategy'}
AND caching = {'rows_per_partition': 'ALL'};

-- Repair unit is basically a keyspace with a set of column families.
-- Cassandra supports repairing multiple column families in one go.

CREATE TABLE IF NOT EXISTS repair_unit (
id bigint PRIMARY KEY,
id timeuuid PRIMARY KEY,
cluster_name text,
keyspace_name text,
column_families set<text>,
incremental_repair boolean
);
)
WITH compaction = {'class': 'LeveledCompactionStrategy'}
AND caching = {'rows_per_partition': 10};

CREATE TABLE IF NOT EXISTS repair_run (
id bigint PRIMARY KEY,
id timeuuid PRIMARY KEY,
cluster_name text,
repair_unit_id bigint,
repair_unit_id timeuuid,
cause text,
owner text,
state text,
Expand All @@ -37,64 +41,74 @@ CREATE TABLE IF NOT EXISTS repair_run (
last_event text ,
segment_count int ,
repair_parallelism text
);
)
WITH compaction = {'class': 'LeveledCompactionStrategy'}
AND caching = {'rows_per_partition': 10};

CREATE TABLE IF NOT EXISTS repair_run_by_cluster(
cluster_name text,
id bigint,
id timeuuid,
PRIMARY KEY(cluster_name, id)
);
)
WITH compaction = {'class': 'LeveledCompactionStrategy'}
AND caching = {'rows_per_partition': 10};

CREATE TABLE IF NOT EXISTS repair_run_by_unit(
repair_unit_id bigint,
id bigint,
repair_unit_id timeuuid,
id timeuuid,
PRIMARY KEY(repair_unit_id, id)
);
)
WITH compaction = {'class': 'LeveledCompactionStrategy'}
AND caching = {'rows_per_partition': 10};

CREATE TABLE IF NOT EXISTS repair_segment (
id bigint PRIMARY KEY,
repair_unit_id bigint,
run_id bigint,
id timeuuid PRIMARY KEY,
repair_unit_id timeuuid,
run_id timeuuid,
start_token varint,
end_token varint,
state int ,
coordinator_host text,
start_time timestamp,
end_time timestamp,
fail_count INT
);
)
WITH compaction = {'class': 'LeveledCompactionStrategy'}
AND caching = {'rows_per_partition': 10};

CREATE TABLE IF NOT EXISTS repair_segment_by_run_id (
run_id bigint,
segment_id bigint,
run_id timeuuid,
segment_id timeuuid,
PRIMARY KEY(run_id, segment_id)
);
)
WITH compaction = {'class': 'LeveledCompactionStrategy'}
AND caching = {'rows_per_partition': 10};


CREATE TABLE IF NOT EXISTS repair_schedule (
id bigint PRIMARY KEY,
repair_unit_id bigint,
id timeuuid PRIMARY KEY,
repair_unit_id timeuuid,
state text ,
days_between int ,
next_activation timestamp,
run_history set<bigint>,
run_history set<timeuuid>,
segment_count int ,
repair_parallelism text ,
intensity double ,
creation_time timestamp,
owner text ,
pause_time timestamp
);
)
WITH compaction = {'class': 'LeveledCompactionStrategy'}
AND caching = {'rows_per_partition': 10};


CREATE TABLE IF NOT EXISTS repair_schedule_by_cluster_and_keyspace(
cluster_name text,
keyspace_name text,
repair_schedule_id bigint,
repair_schedule_id timeuuid,
PRIMARY KEY((cluster_name, keyspace_name), repair_schedule_id)
);
)
WITH compaction = {'class': 'LeveledCompactionStrategy'}
AND caching = {'rows_per_partition': 10};

CREATE TABLE IF NOT EXISTS repair_id(
id_type text PRIMARY KEY,
id bigint
);
41 changes: 0 additions & 41 deletions src/main/resources/db/cassandra/002_table_properties.cql

This file was deleted.

0 comments on commit f4792a1

Please sign in to comment.