(improvement)(Headless) Improve model list performance (#880)

Co-authored-by: jolunoluo
This commit is contained in:
LXW
2024-04-03 18:54:48 +08:00
committed by GitHub
parent 6996c4c12e
commit 12c06c8ebe
16 changed files with 83 additions and 53 deletions

View File

@@ -26,6 +26,7 @@ import com.tencent.supersonic.headless.api.pojo.request.DomainReq;
import com.tencent.supersonic.headless.api.pojo.request.ModelReq;
import com.tencent.supersonic.headless.api.pojo.request.DataSetReq;
import com.tencent.supersonic.headless.server.service.DomainService;
import com.tencent.supersonic.headless.server.service.MetricService;
import com.tencent.supersonic.headless.server.service.ModelRelaService;
import com.tencent.supersonic.headless.server.service.ModelService;
import com.tencent.supersonic.headless.server.service.DataSetService;
@@ -50,9 +51,10 @@ public class BenchMarkDemoDataLoader {
private ModelService modelService;
@Autowired
private ModelRelaService modelRelaService;
@Autowired
private DataSetService viewService;
@Autowired
private MetricService metricService;
public void doRun() {
try {
@@ -67,6 +69,7 @@ public class BenchMarkDemoDataLoader {
addModelRela_3();
addModelRela_4();
addModelRela_5();
batchPushlishMetric();
} catch (Exception e) {
log.error("Failed to add bench mark demo data", e);
}
@@ -310,4 +313,10 @@ public class BenchMarkDemoDataLoader {
modelRelaReq.setJoinConditions(joinConditions);
modelRelaService.save(modelRelaReq, user);
}
private void batchPushlishMetric() {
List<Long> ids = Lists.newArrayList(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L);
metricService.batchPublish(ids, User.getFakeUser());
}
}

View File

@@ -121,7 +121,6 @@ public class ModelDemoDataLoader {
addDataSet_2();
addAuthGroup_1();
addAuthGroup_2();
batchPushlishMetric();
} catch (Exception e) {
log.error("Failed to add model demo data", e);
}
@@ -587,11 +586,6 @@ public class ModelDemoDataLoader {
authService.addOrUpdateAuthGroup(authGroupReq);
}
private void batchPushlishMetric() {
List<Long> ids = Lists.newArrayList(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L);
metricService.batchPublish(ids, User.getFakeUser());
}
private RelateDimension getRelateDimension(List<Long> dimensionIds) {
RelateDimension relateDimension = new RelateDimension();
for (Long id : dimensionIds) {

View File

@@ -290,4 +290,7 @@ COMMENT ON TABLE s2_query_rule IS 'tag query rule table';
--20240325
alter table s2_metric change tags classifications varchar(500) null;
alter table s2_metric add column `is_publish` int(10) DEFAULT NULL COMMENT '是否发布';
update s2_metric set is_publish = 1;
update s2_metric set is_publish = 1;
--20240402
alter table s2_dimension add column `ext` varchar(1000) DEFAULT NULL;

View File

@@ -217,6 +217,7 @@ CREATE TABLE IF NOT EXISTS `s2_dimension` (
`default_values` varchar(500) DEFAULT NULL,
`dim_value_maps` varchar(500) DEFAULT NULL,
`is_tag` INT DEFAULT NULL,
`ext` varchar(1000) DEFAULT NULL,
PRIMARY KEY (`id`)
);
COMMENT ON TABLE s2_dimension IS 'dimension information table';

View File

@@ -250,6 +250,7 @@ CREATE TABLE `s2_dimension` (
`default_values` varchar(500) DEFAULT NULL,
`dim_value_maps` varchar(5000) DEFAULT NULL,
`is_tag` int(10) DEFAULT NULL,
`ext` varchar(1000) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='维度表';
@@ -332,7 +333,7 @@ CREATE TABLE `s2_model` (
CREATE TABLE `s2_plugin` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`type` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'DASHBOARD,WIDGET,URL',
`view` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`data_set` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`pattern` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`parse_mode` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`parse_mode_config` text COLLATE utf8mb4_unicode_ci,
@@ -343,7 +344,6 @@ CREATE TABLE `s2_plugin` (
`updated_by` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`config` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
`comment` text COLLATE utf8mb4_unicode_ci,
ADD COLUMN `data_set` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
@@ -351,7 +351,7 @@ CREATE TABLE `s2_query_stat_info` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`trace_id` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '查询标识',
`model_id` bigint(20) DEFAULT NULL,
`view_id` bigint(20) DEFAULT NULL,
`data_set_id` bigint(20) DEFAULT NULL,
`user` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '执行sql的用户',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`query_type` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '查询对应的场景',
@@ -482,7 +482,7 @@ CREATE TABLE `s2_app`
`updated_by` varchar(255) null
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE TABLE s2_view
CREATE TABLE s2_data_set
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
domain_id BIGINT,
@@ -491,7 +491,7 @@ CREATE TABLE s2_view
`description` VARCHAR(255),
`status` INT,
alias VARCHAR(255),
view_detail text,
data_set_detail text,
created_at datetime,
created_by VARCHAR(255),
updated_at datetime,
@@ -548,25 +548,4 @@ CREATE TABLE IF NOT EXISTS `s2_query_rule` (
`updated_by` varchar(100) DEFAULT NULL ,
`ext` text DEFAULT NULL ,
PRIMARY KEY (`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8 COMMENT ='查询规则表';
-- 2024-04-02补充mysql脚本
CREATE TABLE IF NOT EXISTS `s2_data_set` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`domain_id` bigint(20) ,
`name` varchar(255) NOT NULL ,
`biz_name` varchar(255) NOT NULL ,
`description` varchar(255) NOT NULL ,
`status` INT NOT NULL DEFAULT '1' ,
`alias` varchar(255) NOT NULL ,
`data_set_detail` text DEFAULT NULL ,
`created_at` datetime NOT NULL ,
`created_by` varchar(100) NOT NULL ,
`updated_at` datetime DEFAULT NULL ,
`updated_by` varchar(100) DEFAULT NULL ,
`query_config` varchar(3000) DEFAULT NULL ,
`admin` varchar(3000) DEFAULT NULL ,
`admin_org` varchar(3000) DEFAULT NULL ,
`query_type` varchar(100) DEFAULT NULL ,
PRIMARY KEY (`id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8;
) ENGINE = InnoDB DEFAULT CHARSET = utf8 COMMENT ='查询规则表';