thingsboard-aplcache
Changes
dao/src/main/resources/cassandra/schema.cql 31(+19 -12)
Details
diff --git a/application/src/main/data/upgrade/2.1.1/schema_update.cql b/application/src/main/data/upgrade/2.1.1/schema_update.cql
index e0cff41..c5d919b 100644
--- a/application/src/main/data/upgrade/2.1.1/schema_update.cql
+++ b/application/src/main/data/upgrade/2.1.1/schema_update.cql
@@ -22,72 +22,51 @@ DROP MATERIALIZED VIEW IF EXISTS thingsboard.entity_views_by_tenant_and_customer
DROP TABLE IF EXISTS thingsboard.entity_views;
CREATE TABLE IF NOT EXISTS thingsboard.entity_views (
- id timeuuid,
- entity_id timeuuid,
- entity_type text,
- tenant_id timeuuid,
- customer_id timeuuid,
- name text,
- keys text,
- start_ts bigint,
- end_ts bigint,
- search_text text,
- additional_info text,
- PRIMARY KEY (id, entity_id, tenant_id, customer_id)
+id timeuuid,
+entity_id timeuuid,
+entity_type text,
+tenant_id timeuuid,
+customer_id timeuuid,
+name text,
+keys text,
+start_ts bigint,
+end_ts bigint,
+search_text text,
+additional_info text,
+PRIMARY KEY (id, tenant_id, customer_id)
);
CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_name AS
- SELECT *
- from thingsboard.entity_views
- WHERE entity_id IS NOT NULL
- AND tenant_id IS NOT NULL
- AND customer_id IS NOT NULL
- AND keys IS NOT NULL
- AND start_ts IS NOT NULL
- AND end_ts IS NOT NULL
- AND name IS NOT NULL
- AND id IS NOT NULL
- PRIMARY KEY (tenant_id, name, id, entity_id, customer_id)
- WITH CLUSTERING ORDER BY (name ASC, id DESC, entity_id DESC, customer_id DESC);
+SELECT *
+from thingsboard.entity_views
+WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
+PRIMARY KEY (tenant_id, name, id, entity_id, customer_id)
+WITH CLUSTERING ORDER BY (name ASC, id DESC, entity_id DESC, customer_id DESC);
-CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_entity AS
- SELECT *
- from thingsboard.entity_views
- WHERE entity_id IS NOT NULL
- AND tenant_id IS NOT NULL
- AND customer_id IS NOT NULL
- AND keys IS NOT NULL
- AND start_ts IS NOT NULL
- AND end_ts IS NOT NULL
- AND name IS NOT NULL
- AND id IS NOT NULL
- PRIMARY KEY (tenant_id, entity_id, id, customer_id, name)
- WITH CLUSTERING ORDER BY (entity_id ASC, customer_id ASC, id DESC, name DESC);
+CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_search_text AS
+SELECT *
+from thingsboard.entity_views
+WHERE entity_id IS NOT NULL AND search_text IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
+PRIMARY KEY (tenant_id, search_text, id, customer_id, name)
+WITH CLUSTERING ORDER BY (search_text ASC, customer_id ASC, id DESC, name DESC);
-CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer AS
- SELECT *
- from thingsboard.entity_views
- WHERE entity_id IS NOT NULL
- AND tenant_id IS NOT NULL
- AND customer_id IS NOT NULL
- AND keys IS NOT NULL
- AND start_ts IS NOT NULL
- AND end_ts IS NOT NULL
- AND name IS NOT NULL
- AND id IS NOT NULL
- PRIMARY KEY (tenant_id, customer_id, id, entity_id, name)
- WITH CLUSTERING ORDER BY (customer_id ASC, id DESC, entity_id DESC, name DESC);
+CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_entity_and_search_text AS
+SELECT *
+from thingsboard.entity_views
+WHERE entity_id IS NOT NULL AND search_text IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
+PRIMARY KEY (tenant_id, entity_id, search_text, id, customer_id, name)
+WITH CLUSTERING ORDER BY (entity_id ASC, search_text ASC, id DESC, name DESC);
-CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer_and_entity AS
- SELECT *
- from thingsboard.entity_views
- WHERE entity_id IS NOT NULL
- AND tenant_id IS NOT NULL
- AND customer_id IS NOT NULL
- AND keys IS NOT NULL
- AND start_ts IS NOT NULL
- AND end_ts IS NOT NULL
- AND name IS NOT NULL
- AND id IS NOT NULL
- PRIMARY KEY (tenant_id, customer_id, entity_id, id, name)
- WITH CLUSTERING ORDER BY (customer_id ASC, entity_id DESC, id DESC, name DESC);
+CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer_and_search_text AS
+SELECT *
+from thingsboard.entity_views
+WHERE entity_id IS NOT NULL AND search_text IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
+PRIMARY KEY (tenant_id, customer_id, search_text, id, entity_id)
+WITH CLUSTERING ORDER BY (customer_id ASC, search_text ASC, id DESC, entity_id DESC);
+
+CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer_and_entity_and_search_text AS
+SELECT *
+from thingsboard.entity_views
+WHERE entity_id IS NOT NULL AND search_text IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
+PRIMARY KEY (tenant_id, customer_id, search_text,entity_id, id)
+WITH CLUSTERING ORDER BY (customer_id ASC, search_text ASC, entity_id DESC, id DESC);
dao/src/main/resources/cassandra/schema.cql 31(+19 -12)
diff --git a/dao/src/main/resources/cassandra/schema.cql b/dao/src/main/resources/cassandra/schema.cql
index 3cefacb..674d30e 100644
--- a/dao/src/main/resources/cassandra/schema.cql
+++ b/dao/src/main/resources/cassandra/schema.cql
@@ -661,23 +661,30 @@ CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_na
PRIMARY KEY (tenant_id, name, id, entity_id, customer_id)
WITH CLUSTERING ORDER BY (name ASC, id DESC, entity_id DESC, customer_id DESC);
-CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_entity AS
+CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_search_text AS
SELECT *
from thingsboard.entity_views
- WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
- PRIMARY KEY (tenant_id, entity_id, id, customer_id, name)
- WITH CLUSTERING ORDER BY (entity_id ASC, customer_id ASC, id DESC, name DESC);
+ WHERE entity_id IS NOT NULL AND search_text IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
+ PRIMARY KEY (tenant_id, search_text, id, customer_id, name)
+ WITH CLUSTERING ORDER BY (search_text ASC, customer_id ASC, id DESC, name DESC);
-CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer AS
+CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_view_by_tenant_and_entity_and_search_text AS
SELECT *
from thingsboard.entity_views
- WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
- PRIMARY KEY (tenant_id, customer_id, id, entity_id, name)
- WITH CLUSTERING ORDER BY (customer_id ASC, id DESC, entity_id DESC, name DESC);
+ WHERE entity_id IS NOT NULL AND search_text IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
+ PRIMARY KEY (tenant_id, entity_id, search_text, id, customer_id, name)
+ WITH CLUSTERING ORDER BY (entity_id ASC, search_text ASC, id DESC, name DESC);
-CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer_and_entity AS
+CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer_and_search_text AS
SELECT *
from thingsboard.entity_views
- WHERE entity_id IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
- PRIMARY KEY (tenant_id, customer_id, entity_id, id, name)
- WITH CLUSTERING ORDER BY (customer_id ASC, entity_id DESC, id DESC, name DESC);
+ WHERE entity_id IS NOT NULL AND search_text IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
+ PRIMARY KEY (tenant_id, customer_id, search_text, id, entity_id)
+ WITH CLUSTERING ORDER BY (customer_id ASC, search_text ASC, id DESC, entity_id DESC);
+
+CREATE MATERIALIZED VIEW IF NOT EXISTS thingsboard.entity_views_by_tenant_and_customer_and_entity_and_search_text AS
+ SELECT *
+ from thingsboard.entity_views
+ WHERE entity_id IS NOT NULL AND search_text IS NOT NULL AND tenant_id IS NOT NULL AND customer_id IS NOT NULL AND keys IS NOT NULL AND start_ts IS NOT NULL AND end_ts IS NOT NULL AND name IS NOT NULL AND id IS NOT NULL
+ PRIMARY KEY (tenant_id, customer_id, search_text,entity_id, id)
+ WITH CLUSTERING ORDER BY (customer_id ASC, search_text ASC, entity_id DESC, id DESC);