The execution plan now (when the query is not failing) is the following:
Eval[var_id, var_name, var_description, isnumeric, code, code, gateway_config, unit, var_type]
└ NestedLoopJoin[LEFT | (var_filter_id = filter_id)]
├ NestedLoopJoin[LEFT | (category_id = cat_id)]
│ ├ Rename[var_id, var_name, var_description, isnumeric, gateway_config, unit, var_type, category_id, var_filter_id] AS vn
│ │ └ Get[bemp_demo.var_names | var_id, var_name, var_description, isnumeric, gateway_config, unit, var_type, category_id, var_filter_id | DocKeys{73::bigint} | (var_id = 73::bigint)]
│ └ Rename[code, cat_id] AS c
│ └ Collect[bemp.categories | [code, cat_id] | true]
└ Rename[code, filter_id] AS f
└ Collect[bemp.var_filters | [code, filter_id] | true]
And here I paste the SHOW CREATE TABLE results:
CREATE TABLE IF NOT EXISTS "bemp_demo"."var_names" (
"alarms" ARRAY(BIGINT),
"var_id" BIGINT,
"var_name" VARCHAR(255) NOT NULL,
"var_description" TEXT,
"var_creation_date" TIMESTAMP WITHOUT TIME ZONE,
"isnumeric" BOOLEAN DEFAULT true,
"var_filter_id" BIGINT,
"category_id" BIGINT,
"unit" TEXT,
"var_type" TEXT,
"device_id" BIGINT,
"alarm_id" ARRAY(BIGINT),
"filter_execution_time" TIMESTAMP WITHOUT TIME ZONE,
"categories" ARRAY(TEXT),
"var_unit" TEXT,
"var_order" INTEGER,
"alarm_execution_time" TIMESTAMP WITHOUT TIME ZONE,
"gateway_config" OBJECT(DYNAMIC),
PRIMARY KEY ("var_id")
)
CLUSTERED BY ("var_id") INTO 2 SHARDS
WITH (
"allocation.max_retries" = 5,
"blocks.metadata" = false,
"blocks.read" = false,
"blocks.read_only" = false,
"blocks.read_only_allow_delete" = false,
"blocks.write" = false,
codec = 'default',
column_policy = 'dynamic',
"mapping.total_fields.limit" = 1000,
max_ngram_diff = 1,
max_shingle_diff = 3,
number_of_replicas = '0-1',
"routing.allocation.enable" = 'all',
"routing.allocation.total_shards_per_node" = -1,
"store.type" = 'fs',
"translog.durability" = 'REQUEST',
"translog.flush_threshold_size" = 536870912,
"translog.sync_interval" = 5000,
"unassigned.node_left.delayed_timeout" = 60000,
"write.wait_for_active_shards" = '1'
)
CREATE TABLE IF NOT EXISTS "bemp"."categories" (
"cat_id" BIGINT,
"name" TEXT NOT NULL,
"description" TEXT,
"parent_cat" BIGINT,
"client_id" BIGINT,
"cat_order" INTEGER,
"code" TEXT,
"modification_date" TIMESTAMP WITHOUT TIME ZONE GENERATED ALWAYS AS _cast(current_timestamp, 'timestamp without time zone'),
"creation_date" TIMESTAMP WITHOUT TIME ZONE DEFAULT _cast(current_timestamp, 'timestamp without time zone') NOT NULL,
PRIMARY KEY ("cat_id")
)
CLUSTERED BY ("cat_id") INTO 4 SHARDS
WITH (
"allocation.max_retries" = 5,
"blocks.metadata" = false,
"blocks.read" = false,
"blocks.read_only" = false,
"blocks.read_only_allow_delete" = false,
"blocks.write" = false,
codec = 'default',
column_policy = 'dynamic',
"mapping.total_fields.limit" = 1000,
max_ngram_diff = 1,
max_shingle_diff = 3,
number_of_replicas = '0-1',
"routing.allocation.enable" = 'all',
"routing.allocation.total_shards_per_node" = -1,
"store.type" = 'fs',
"translog.durability" = 'REQUEST',
"translog.flush_threshold_size" = 536870912,
"translog.sync_interval" = 5000,
"unassigned.node_left.delayed_timeout" = 60000,
"write.wait_for_active_shards" = '1'
)
CREATE TABLE IF NOT EXISTS "bemp"."var_filters" (
"filter_id" BIGINT,
"client_id" BIGINT NOT NULL,
"name" VARCHAR(255),
"description" TEXT,
"content" TEXT,
"code" TEXT,
"modification_date" TIMESTAMP WITHOUT TIME ZONE GENERATED ALWAYS AS _cast(current_timestamp, 'timestamp without time zone'),
"creation_date" TIMESTAMP WITHOUT TIME ZONE DEFAULT _cast(current_timestamp, 'timestamp without time zone') NOT NULL,
PRIMARY KEY ("filter_id")
)
CLUSTERED BY ("filter_id") INTO 4 SHARDS
WITH (
"allocation.max_retries" = 5,
"blocks.metadata" = false,
"blocks.read" = false,
"blocks.read_only" = false,
"blocks.read_only_allow_delete" = false,
"blocks.write" = false,
codec = 'default',
column_policy = 'dynamic',
"mapping.total_fields.limit" = 1000,
max_ngram_diff = 1,
max_shingle_diff = 3,
number_of_replicas = '0-1',
"routing.allocation.enable" = 'all',
"routing.allocation.total_shards_per_node" = -1,
"store.type" = 'fs',
"translog.durability" = 'REQUEST',
"translog.flush_threshold_size" = 536870912,
"translog.sync_interval" = 5000,
"unassigned.node_left.delayed_timeout" = 60000,
"write.wait_for_active_shards" = '1'
)
Currently the data in those table is not too much:
- “bemp_demo”.“var_names” = 149 records
- “bemp”.“categories” = 79
- “bemp”.“var_filters” = 51
As said the query is not failing now, I can send the same information when it starts failing again.