Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[common] auto generate index when jpa auto-ddl #756

Merged
merged 1 commit into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
* @date 2021/12/8 20:41
*/
@Entity
@Table(name = "hzb_alert_define_monitor_bind")
@Table(name = "hzb_alert_define_monitor_bind", indexes = {
@Index(name = "index_alert_define_monitor", columnList = "alertDefineId"),
@Index(name = "index_alert_define_monitor", columnList = "monitor_id")
})
@Data
@Builder
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
* @date 2021/11/14 9:53
*/
@Entity
@Table(name = "hzb_monitor")
@Table(name = "hzb_monitor", indexes = {
@Index(name = "monitor_query_index", columnList = "app"),
@Index(name = "monitor_query_index", columnList = "host"),
@Index(name = "monitor_query_index", columnList = "name")
})
@Data
@Builder
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
* @date 2021/11/13 22:19
*/
@Entity
@Table(name = "hzb_param")
@Table(name = "hzb_param", indexes = { @Index(columnList = "monitorId") },
uniqueConstraints = @UniqueConstraint(columnNames = {"monitorId", "field"}))
@Data
@Builder
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
* @date 2021/11/13 22:19
*/
@Entity
@Table(name = "hzb_tag_monitor_bind")
@Table(name = "hzb_tag_monitor_bind", indexes = {
@Index(name = "index_tag_monitor", columnList = "tag_id"),
@Index(name = "index_tag_monitor", columnList = "monitor_id")
})
@Data
@Builder
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
* @date 2023/2/3 14:13
*/
@Entity
@Table(name = "hzb_history")
@Table(name = "hzb_history", indexes = {
@Index(name = "history_query_index", columnList = "monitorId"),
@Index(name = "history_query_index", columnList = "app"),
@Index(name = "history_query_index", columnList = "metrics"),
@Index(name = "history_query_index", columnList = "metric")
})
@Data
@Builder
@AllArgsConstructor
Expand Down
9 changes: 9 additions & 0 deletions manager/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,13 @@
</root>
</springProfile>

<!-- 开发环境配置 -->
<springProfile name="mysql">
<root level="INFO">
<appender-ref ref="ConsoleAppender"/>
<appender-ref ref="SystemOutFileAppender"/>
<appender-ref ref="ErrOutFileAppender"/>
</root>
</springProfile>

</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public interface HistoryDao extends JpaRepository<History, Long>, JpaSpecificati
*/
@Modifying
@Transactional(rollbackFor = Exception.class)
@Query(value = "delete from hzb_history limit 5000", nativeQuery = true)
@Query(value = "delete from hzb_history limit 20000", nativeQuery = true)
int deleteOlderHistoriesRecord();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class HistoryJpaDatabaseDataStorage extends AbstractHistoryDataStorage {
private WarehouseProperties.StoreProperties.JpaProperties jpaProperties;

private static final int STRING_MAX_LENGTH = 1024;
private static final int MAX_HISTORY_TABLE_RECORD = 200_000;
private static final int MAX_HISTORY_TABLE_RECORD = 60_000;

public HistoryJpaDatabaseDataStorage(WarehouseProperties properties,
HistoryDao historyDao) {
Expand Down