Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: remove slow query in frontend (#15461)
boojackb4d839a8d93b
diff --git a/frontend/src/components/Database/DatabaseSlowQueryPanel.vue b/frontend/src/components/Database/DatabaseSlowQueryPanel.vuedeleted file mode 100644index 8bf4c57ab0..0000000000--- a/frontend/src/components/Database/DatabaseSlowQueryPanel.vue+++ /dev/null@@ -1,47 +0,0 @@-<template>- <SlowQueryPanel- v-if="database"- :key="`slow-query.${database.name}`"- :show-project-column="false"- :show-environment-column="false"- :show-instance-column="false"- :show-database-column="false"- :support-option-id-list="[]"- :readonly-search-scopes="readonlyScopes"- v-bind="$attrs"- />-</template>--<script lang="ts" setup>-import { computed } from "vue";-import { SlowQueryPanel } from "@/components/SlowQuery";-import type { ComposedDatabase } from "@/types";-import type { SearchScope } from "@/utils";-import {- extractEnvironmentResourceName,- extractProjectResourceName,-} from "@/utils";--const props = defineProps<{- database: ComposedDatabase;-}>();--const readonlyScopes = computed((): SearchScope[] => {- return [- {- id: "project",- value: extractProjectResourceName(props.database.project),- },- {- id: "environment",- value: extractEnvironmentResourceName(- props.database.effectiveEnvironment- ),- },- {- id: "database",- value: props.database.name,- },- ];-});-</script>diff --git a/frontend/src/components/Database/context.ts b/frontend/src/components/Database/context.tsindex 5b8ae2c482..3f727cc1eb 100644--- a/frontend/src/components/Database/context.ts+++ b/frontend/src/components/Database/context.ts@@ -10,7 +10,6 @@ import { DEFAULT_PROJECT_NAME } from "@/types";import {hasProjectPermissionV2,instanceV1HasAlterSchema,- instanceV1SupportSlowQuery,isArchivedDatabaseV1,hasPermissionToCreateChangeDatabaseIssue,} from "@/utils";@@ -29,7 +28,6 @@ export type DatabaseDetailContext = {allowUpdateSecrets: Ref<boolean>;allowDeleteSecrets: Ref<boolean>;allowListChangelogs: Ref<boolean>;- allowListSlowQueries: Ref<boolean>;};export const KEY = Symbol(@@ -115,11 +113,6 @@ export const provideDatabaseDetailContext = (const allowListChangelogs = computed(() =>checkPermission("bb.changelogs.list"));- const allowListSlowQueries = computed(- () =>- checkPermission("bb.slowQueries.list") &&- instanceV1SupportSlowQuery(database.value.instanceResource)- );const context: DatabaseDetailContext = {database,@@ -135,7 +128,6 @@ export const provideDatabaseDetailContext = (allowUpdateSecrets,allowDeleteSecrets,allowListChangelogs,- allowListSlowQueries,};provide(KEY, context);diff --git a/frontend/src/components/Project/useProjectSidebar.ts b/frontend/src/components/Project/useProjectSidebar.tsindex 5fe99190c5..b20bdb5d2a 100644--- a/frontend/src/components/Project/useProjectSidebar.ts+++ b/frontend/src/components/Project/useProjectSidebar.ts@@ -20,7 +20,6 @@ import projectV1Routes, {PROJECT_V1_ROUTE_DATABASES,PROJECT_V1_ROUTE_ISSUES,PROJECT_V1_ROUTE_SYNC_SCHEMA,- PROJECT_V1_ROUTE_SLOW_QUERIES,PROJECT_V1_ROUTE_ANOMALIES,PROJECT_V1_ROUTE_MEMBERS,PROJECT_V1_ROUTE_SETTINGS,@@ -145,7 +144,6 @@ export const useProjectSidebar = (},{title: startCase(t("slow-query.slow-queries")),- path: PROJECT_V1_ROUTE_SLOW_QUERIES,type: "div",},{diff --git a/frontend/src/components/ProjectSlowQueryPanel.vue b/frontend/src/components/ProjectSlowQueryPanel.vuedeleted file mode 100644index 0458ce0dbf..0000000000--- a/frontend/src/components/ProjectSlowQueryPanel.vue+++ /dev/null@@ -1,29 +0,0 @@-<template>- <SlowQueryPanel- :key="`slow-query.${project.name}`"- :readonly-search-scopes="readonlyScopes"- :support-option-id-list="['environment', 'database']"- :show-project-column="false"- />-</template>--<script lang="ts" setup>-import { computed } from "vue";-import { SlowQueryPanel } from "@/components/SlowQuery";-import type { Project } from "@/types/proto/v1/project_service";-import type { SearchScope } from "@/utils";-import { extractProjectResourceName } from "@/utils";--const props = defineProps<{- project: Project;-}>();--const readonlyScopes = computed((): SearchScope[] => {- return [- {- id: "project",- value: extractProjectResourceName(props.project.name),- },- ];-});-</script>diff --git a/frontend/src/components/SlowQuery/Panel/DetailPanel.vue b/frontend/src/components/SlowQuery/Panel/DetailPanel.vuedeleted file mode 100644index 69243defcd..0000000000--- a/frontend/src/components/SlowQuery/Panel/DetailPanel.vue+++ /dev/null@@ -1,225 +0,0 @@-<template>- <Drawer- :show="slowQueryLog !== undefined"- width="auto"- @update:show="(show: boolean) => !show && $emit('close')"- >- <DrawerContent- :title="$t('slow-query.detail')"- :closable="true"- class="w-[calc(100vw-2rem)] lg:max-w-[64rem] xl:max-w-[72rem]"- >- <div v-if="slowQueryLog" class="max-h-full flex flex-col gap-y-4 text-sm">- <div- class="grid grid-cols-[auto_1fr] md:grid-cols-[minmax(auto,7rem)_1fr_minmax(auto,7rem)_1fr] gap-x-2 gap-y-4"- >- <div class="contents">- <label class="font-medium capitalize">- {{ $t("common.project") }}- </label>-- <ProjectV1Name :project="database.projectEntity" />- </div>-- <div class="contents">- <label class="font-medium capitalize">- {{ $t("common.environment") }}- </label>-- <EnvironmentV1Name- :environment="database.effectiveEnvironmentEntity"- />- </div>-- <div class="contents">- <label class="font-medium capitalize">- {{ $t("common.instance") }}- </label>-- <InstanceV1Name :instance="database.instanceResource" />- </div>-- <div class="contents">- <label class="font-medium capitalize">- {{ $t("common.database") }}- </label>-- <DatabaseV1Name :database="database" />- </div>-- <div class="contents">- <label class="font-medium capitalize whitespace-nowrap">- {{ $t("common.sql-statement") }}- </label>-- <div- class="col-start-2 md:col-span-3 max-h-[8rem] overflow-auto py-0.5 text-xs"- >- <HighlightCodeBlock- :code="log.statistics?.sqlFingerprint ?? ''"- class="whitespace-pre-wrap"- />- </div>- </div>- </div>- <IndexAdvisor- v-if="slowQueryLog && hasIndexAdvisorPermission"- :slow-query-log="slowQueryLog"- />- <div- v-if="instanceV1HasSlowQueryDetail(database.instanceResource)"- class="flex-1 overflow-auto border"- >- <BBGrid- :column-list="columns"- :data-source="log.statistics?.samples"- :row-clickable="false"- :is-row-expanded="isSelectedRow"- class="compact"- header-class="capitalize"- >- <template #item="{ item: detail }: SlowQueryDetailsRow">- <div class="bb-grid-cell whitespace-nowrap !pl-1 !pr-1">- <NButton quaternary size="tiny" @click="selectRow(detail)">- <heroicons:chevron-right- class="w-4 h-4 transition-transform duration-150 cursor-pointer"- :class="[isSelectedRow(detail) && 'rotate-90']"- />- </NButton>- </div>- <div class="bb-grid-cell whitespace-nowrap !pr-4">- {{- dayjs(getDateForPbTimestamp(detail.startTime)).format(- "YYYY-MM-DD HH:mm:ss"- )- }}- </div>- <div class="bb-grid-cell text-xs font-mono">- <div class="truncate">- {{ detail.sqlText }}- </div>- </div>- <div class="bb-grid-cell">- {{ detail.queryTime?.seconds?.toNumber()?.toFixed(2) }}s- </div>- <div class="bb-grid-cell">- {{ detail.lockTime?.seconds?.toNumber()?.toFixed(2) }}s- </div>- <div class="bb-grid-cell">- {{ detail.rowsExamined }}- </div>- <div class="bb-grid-cell">- {{ detail.rowsSent }}- </div>- </template>-- <template #expanded-item="{ item: detail }: SlowQueryDetailsRow">- <div class="w-full max-h-[20rem] overflow-auto text-xs pl-2">- <HighlightCodeBlock- :code="detail.sqlText"- class="whitespace-pre-wrap"- />- </div>- </template>- </BBGrid>- </div>- </div>- </DrawerContent>- </Drawer>-</template>--<script lang="ts" setup>-import { NButton } from "naive-ui";-import { computed, shallowRef, watch } from "vue";-import { useI18n } from "vue-i18n";-import { type BBGridColumn, type BBGridRow, BBGrid } from "@/bbkit";-import HighlightCodeBlock from "@/components/HighlightCodeBlock";-import {- DatabaseV1Name,- InstanceV1Name,- EnvironmentV1Name,- ProjectV1Name,- Drawer,- DrawerContent,-} from "@/components/v2";-import { getDateForPbTimestamp, type ComposedSlowQueryLog } from "@/types";-import type { SlowQueryDetails } from "@/types/proto/v1/database_service";-import { instanceV1HasSlowQueryDetail } from "@/utils";-import { hasProjectPermissionV2 } from "@/utils";-import IndexAdvisor from "./IndexAdvisor.vue";--export type SlowQueryDetailsRow = BBGridRow<SlowQueryDetails>;--const props = defineProps<{- slowQueryLog: ComposedSlowQueryLog | undefined;-}>();--defineEmits<{- (event: "close"): void;-}>();--const { t } = useI18n();--const columns = computed(() => {- const columns: BBGridColumn[] = [- {- width: "auto",- },- {- title: t("slow-query.query-start-time"),- width: "auto",- },- {- title: t("common.sql-statement"),- width: "minmax(6rem, 3fr)",- },- {- title: t("slow-query.query-time"),- width: "minmax(auto, 1fr)",- },- {- title: t("slow-query.lock-time"),- width: "minmax(auto, 1fr)",- },- {- title: t("slow-query.rows-examined"),- width: "minmax(auto, 1fr)",- },- {- title: t("slow-query.rows-sent"),- width: "minmax(auto, 1fr)",- },- ];- return columns;-});--const log = computed(() => props.slowQueryLog!.log);-const database = computed(() => props.slowQueryLog!.database);-const selectedDetail = shallowRef<SlowQueryDetails>();-const hasIndexAdvisorPermission = computed(() =>- hasProjectPermissionV2(- database.value.projectEntity,- "bb.databases.adviseIndex"- )-);--const isSelectedRow = (item: SlowQueryDetails) => {- return selectedDetail.value === item;-};--const selectRow = (item: SlowQueryDetails) => {- if (selectedDetail.value === item) {- selectedDetail.value = undefined;- } else {- selectedDetail.value = item;- }-};--watch(- () => props.slowQueryLog,- () => {- selectedDetail.value = undefined;- },- { immediate: true }-);-</script>diff --git a/frontend/src/components/SlowQuery/Panel/IndexAdvisor.vue b/frontend/src/components/SlowQuery/Panel/IndexAdvisor.vuedeleted file mode 100644index 144bac4ad6..0000000000--- a/frontend/src/components/SlowQuery/Panel/IndexAdvisor.vue+++ /dev/null@@ -1,172 +0,0 @@-<template>- <div- v-if="showIndexAdvisor"- class="w-full min-w-[128px] flex flex-row justify-start items-start gap-4"- >- <div class="w-1/4 flex flex-col justify-start items-start gap-2">- <span class="font-medium capitalize whitespace-nowrap">{{- $t("slow-query.advise-index.current-index")- }}</span>- <span class="font-mono">{{ state.currentIndex }}</span>- </div>- <div class="w-3/4 flex flex-col justify-start items-start gap-2">- <div class="flex flex-row justify-start items-center">- <span class="font-medium capitalize whitespace-nowrap">{{- $t("slow-query.advise-index.suggestion")- }}</span>- <BBSpin v-if="state.isLoading" class="ml-2" />- <button- v-else- class="ml-2 normal-link underline"- @click="handleCreateIndex"- >- {{ $t("slow-query.advise-index.create-index") }}- </button>- </div>- <span class="w-full font-mono">{{ state.suggestion }}</span>- </div>- </div>- <div v-else-if="!hasIndexAdvisorFeature">- <NButton type="primary" @click="state.showFeatureModal = true">- {{ $t("dynamic.subscription.features.bb-feature-index-advisor.title") }}- <FeatureBadge- custom-class="ml-1 text-white"- feature="bb.feature.index-advisor"- :instance="slowQueryLog.database.instanceResource"- />- </NButton>- </div>- <div v-else-if="!hasOpenAIKeySetup">- <router-link- class="normal-link"- :to="{ name: SETTING_ROUTE_WORKSPACE_GENERAL }"- >- {{ $t("slow-query.advise-index.setup-openai-key-to-enable") }}- </router-link>- </div>-- <FeatureModal- feature="bb.feature.index-advisor"- :open="state.showFeatureModal"- :instance="slowQueryLog.database.instanceResource"- @cancel="state.showFeatureModal = false"- />-</template>--<script lang="ts" setup>-import { NButton } from "naive-ui";-import { Status } from "nice-grpc-common";-import { v4 as uuidv4 } from "uuid";-import { computed, reactive, watch } from "vue";-import { useRouter } from "vue-router";-import { BBSpin } from "@/bbkit";-import { FeatureBadge, FeatureModal } from "@/components/FeatureGuard";-import { databaseServiceClient } from "@/grpcweb";-import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";-import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/router/dashboard/workspaceSetting";-import { featureToRef, hasFeature, useStorageStore } from "@/store";-import { useSettingV1Store } from "@/store/modules/v1/setting";-import type { ComposedSlowQueryLog } from "@/types";-import { extractProjectResourceName, generateIssueTitle } from "@/utils";-import { getErrorCode } from "@/utils/grpcweb";--const props = defineProps<{- slowQueryLog: ComposedSlowQueryLog;-}>();--interface LocalState {- isLoading: boolean;- currentIndex: string;- suggestion: string;- createIndexStatement: string;- showFeatureModal: boolean;-}--const router = useRouter();-const state = reactive<LocalState>({- isLoading: false,- currentIndex: "",- suggestion: "",- createIndexStatement: "",- showFeatureModal: false,-});-const settingV1Store = useSettingV1Store();-const hasIndexAdvisorFeature = featureToRef(- "bb.feature.index-advisor",- props.slowQueryLog.database.instanceResource-);-const hasOpenAIKeySetup = computed(() => {- const openAIKeySetting = settingV1Store.getSettingByName(- "bb.plugin.openai.key"- );- if (openAIKeySetting) {- return openAIKeySetting.value?.stringValue !== "";- }- return false;-});-const log = computed(() => props.slowQueryLog.log);-const database = computed(() => props.slowQueryLog.database);-const sqlFingerprint = computed(- () => log.value.statistics?.sqlFingerprint || ""-);-const showIndexAdvisor = computed(() => {- return hasIndexAdvisorFeature.value && hasOpenAIKeySetup.value;-});--const handleCreateIndex = () => {- const sqlStorageKey = `bb.issues.sql.${uuidv4()}`;- useStorageStore().put(sqlStorageKey, state.createIndexStatement);- const query: Record<string, any> = {- template: "bb.issue.database.schema.update",- name: generateIssueTitle("bb.issue.database.schema.update", [- database.value.databaseName,- ]),- databaseList: database.value.name,- mode: "normal",- description: `Create index for database ${database.value.databaseName}`,- sqlStorageKey,- };-- const routeInfo = {- name: PROJECT_V1_ROUTE_ISSUE_DETAIL,- params: {- projectId: extractProjectResourceName(database.value.project),- issueSlug: "create",- },- query,- };- router.push(routeInfo);-};--watch(- () => props.slowQueryLog,- async () => {- if (hasFeature("bb.feature.ai-assistant") && hasOpenAIKeySetup.value) {- state.isLoading = true;- try {- const response = await databaseServiceClient.adviseIndex({- parent: log.value.resource,- statement: sqlFingerprint.value,- });-- state.currentIndex = response.currentIndex;- state.suggestion = response.suggestion;- state.createIndexStatement = response.createIndexStatement;- } catch (error) {- if (getErrorCode(error) !== Status.NOT_FOUND) {- state.isLoading = false;- throw error;- }- }- state.isLoading = false;- } else {- state.currentIndex = "";- state.suggestion = "";- state.createIndexStatement = "";- }- },- {- immediate: true,- }-);-</script>diff --git a/frontend/src/components/SlowQuery/Panel/LogFilter.vue b/frontend/src/components/SlowQuery/Panel/LogFilter.vuedeleted file mode 100644index a924c1c050..0000000000--- a/frontend/src/components/SlowQuery/Panel/LogFilter.vue+++ /dev/null@@ -1,55 +0,0 @@-<template>- <div v-if="ready" class="mb-2 space-y-2">- <div- class="flex flex-col md:flex-row items-end md:items-center gap-y-2 gap-x-2"- >- <AdvancedSearch- v-if="supportOptionIdList.length > 0"- class="flex-1 hidden md:block"- :params="params"- :placeholder="''"- :scope-options="scopeOptions"- :readonly-scopes="readonlyScopes"- @update:params="$emit('update:params', $event)"- />- <TimeRange- :params="params"- @update:params="$emit('update:params', $event)"- />- <div class="flex items-center justify-end space-x-2">- <slot name="suffix" />- </div>- </div>- </div>-</template>-<script lang="ts" setup>-import { computed } from "vue";-import AdvancedSearch, { TimeRange } from "@/components/AdvancedSearch";-import { useCommonSearchScopeOptions } from "@/components/AdvancedSearch/useCommonSearchScopeOptions";-import { useSlowQueryPolicyList } from "@/store";-import type { SearchParams, SearchScopeId, SearchScope } from "@/utils";--const props = withDefaults(- defineProps<{- params: SearchParams;- readonlyScopes?: SearchScope[];- supportOptionIdList: SearchScopeId[];- loading?: boolean;- }>(),- {- readonlyScopes: () => [],- loading: false,- }-);--defineEmits<{- (event: "update:params", params: SearchParams): void;-}>();--const { ready } = useSlowQueryPolicyList();--const scopeOptions = useCommonSearchScopeOptions(- computed(() => props.params),- computed(() => props.supportOptionIdList)-);-</script>diff --git a/frontend/src/components/SlowQuery/Panel/LogTable.vue b/frontend/src/components/SlowQuery/Panel/LogTable.vuedeleted file mode 100644index 684f25d786..0000000000--- a/frontend/src/components/SlowQuery/Panel/LogTable.vue+++ /dev/null@@ -1,260 +0,0 @@-<template>- <NDataTable- key="slow-query-table"- v-model:expanded-row-keys="expandedRowKeys"- class="min-w-[120rem]"- :columns="dataTableColumns"- :data="slowQueryLogList"- :max-height="'100%'"- :row-key="rowKey"- :row-props="rowProps"- :virtual-scroll="true"- :striped="true"- :bordered="true"- :bottom-bordered="true"- >- <template #empty>- <div class="py-8 px-8 text-center">- <p v-if="allowAdmin">- {{ $t("slow-query.no-log-placeholder.admin") }}- </p>- <p v-else>- {{ $t("slow-query.no-log-placeholder.developer") }}- </p>- </div>- </template>- </NDataTable>-</template>--<script lang="ts" setup>-import dayjs from "dayjs";-import type { DataTableColumn } from "naive-ui";-import { NDataTable } from "naive-ui";-import { computed, h, ref } from "vue";-import { useI18n } from "vue-i18n";-import HighlightCodeBlock from "@/components/HighlightCodeBlock";-import {- ProjectV1Name,- DatabaseV1Name,- InstanceV1Name,- EnvironmentV1Name,-} from "@/components/v2";-import {- getDateForPbTimestamp,- getTimeForPbTimestamp,- type ComposedSlowQueryLog,-} from "@/types";-import type { Duration } from "@/types/proto/google/protobuf/duration";-import { instanceV1HasSlowQueryDetail } from "@/utils";-import Long from "long";--const props = withDefaults(- defineProps<{- slowQueryLogList?: ComposedSlowQueryLog[];- showPlaceholder?: boolean;- showProjectColumn?: boolean;- showEnvironmentColumn?: boolean;- showInstanceColumn?: boolean;- showDatabaseColumn?: boolean;- allowAdmin: boolean;- }>(),- {- slowQueryLogList: () => [],- showPlaceholder: true,- showProjectColumn: true,- showEnvironmentColumn: true,- showInstanceColumn: true,- showDatabaseColumn: true,- }-);--const emit = defineEmits<{- (event: "select", log: ComposedSlowQueryLog): void;-}>();--const { t } = useI18n();--const dataTableColumns = computed(- (): DataTableColumn<ComposedSlowQueryLog>[] => {- const columns: DataTableColumn<ComposedSlowQueryLog>[] = [- {- type: "expand",- expandable: (_) => true,- renderExpand: (item) =>- h(- "div",- { class: "w-full max-h-[20rem] overflow-auto text-xs pl-2" },- h(HighlightCodeBlock, {- class: "whitespace-pre-wrap",- code: item.log.statistics?.sqlFingerprint ?? "",- })- ),- },- {- title: t("slow-query.sql-statement"),- key: "statement",- render: (item) =>- h("div", { class: "truncate" }, item.log.statistics?.sqlFingerprint),- },- {- title: t("slow-query.total-query-count"),- key: "total_query_count",- sorter: (rowA, rowB) =>- (rowA.log.statistics?.count ?? Long.ZERO).compare(rowB.log.statistics?.count ?? Long.ZERO),- render: (item) => (item.log.statistics?.count ?? Long.ZERO).toString(),- },- {- title: t("slow-query.query-count-percent"),- key: "query_count_percentage",- render: (item) =>- `${((item.log.statistics?.countPercent ?? 0) * 100).toFixed(2)}%`,- },- {- title: t("slow-query.max-query-time"),- key: "max_query_time",- sorter: (rowA, rowB) =>- durationSeconds(rowA.log.statistics?.maximumQueryTime) -- durationSeconds(rowB.log.statistics?.maximumQueryTime),- render: (item) => durationText(item.log.statistics?.maximumQueryTime),- },- {- title: t("slow-query.avg-query-time"),- key: "avg_query_time",- sorter: (rowA, rowB) =>- durationSeconds(rowA.log.statistics?.averageQueryTime) -- durationSeconds(rowB.log.statistics?.averageQueryTime),- render: (item) => durationText(item.log.statistics?.averageQueryTime),- },- {- title: t("slow-query.query-time-percent"),- key: "query_time_percentage",- render: (item) =>- `${((item.log.statistics?.queryTimePercent ?? 0) * 100).toFixed(2)}%`,- },- {- title: t("slow-query.max-rows-examined"),- key: "max_rows_examined",- sorter: (rowA, rowB) =>- (rowA.log.statistics?.maximumRowsExamined ?? Long.ZERO).compare(rowB.log.statistics?.maximumRowsExamined ?? Long.ZERO),- render: (item) =>- instanceV1HasSlowQueryDetail(item.database.instanceResource)- ? (item.log.statistics?.maximumRowsExamined ?? Long.ZERO).toString()- : "-",- },- {- title: t("slow-query.avg-rows-examined"),- key: "avg_rows_examined",- sorter: (rowA, rowB) =>- (rowA.log.statistics?.averageRowsExamined ?? Long.ZERO).compare(rowB.log.statistics?.averageRowsExamined ?? Long.ZERO),- render: (item) =>- instanceV1HasSlowQueryDetail(item.database.instanceResource)- ? (item.log.statistics?.averageRowsExamined ?? Long.ZERO).toString()- : "-",- },- {- title: t("slow-query.max-rows-sent"),- key: "max_rows_sent",- sorter: (rowA, rowB) =>- (rowA.log.statistics?.maximumRowsSent ?? Long.ZERO).compare(rowB.log.statistics?.maximumRowsSent ?? Long.ZERO),- render: (item) =>- instanceV1HasSlowQueryDetail(item.database.instanceResource)- ? (item.log.statistics?.maximumRowsSent ?? Long.ZERO).toString()- : "-",- },- {- title: t("slow-query.avg-rows-sent"),- key: "avg_rows_sent",- sorter: (rowA, rowB) =>- (rowA.log.statistics?.averageRowsSent ?? Long.ZERO).compare(rowB.log.statistics?.averageRowsSent ?? Long.ZERO),- render: (item) => (item.log.statistics?.averageRowsSent ?? Long.ZERO).toString(),- },- ];-- if (props.showProjectColumn) {- columns.push({- title: t("common.project"),- key: "project",- render: (item) =>- h(ProjectV1Name, {- project: item.database.projectEntity,- link: false,- }),- });- }- if (props.showEnvironmentColumn) {- columns.push({- title: t("common.environment"),- key: "environment",- render: (item) =>- h(EnvironmentV1Name, {- environment: item.database.effectiveEnvironmentEntity,- link: false,- }),- });- }- if (props.showInstanceColumn) {- columns.push({- title: t("common.instance"),- key: "instance",- render: (item) =>- h(InstanceV1Name, {- instance: item.database.instanceResource,- link: false,- }),- });- }- if (props.showDatabaseColumn) {- columns.push({- title: t("common.database"),- key: "database",- render: (item) =>- h(DatabaseV1Name, {- database: item.database,- link: false,- }),- });- }-- columns.push({- title: t("slow-query.last-query-time"),- key: "last_query_time",- sorter: (rowA, rowB) =>- getTimeForPbTimestamp(rowA.log.statistics?.latestLogTime, 0) -- getTimeForPbTimestamp(rowB.log.statistics?.latestLogTime, 0),- render: (item) =>- dayjs(getDateForPbTimestamp(item.log.statistics?.latestLogTime)).format(- "YYYY-MM-DD HH:mm:ss"- ),- });-- return columns;- }-);--const rowKey = (item: ComposedSlowQueryLog) => {- return item.id;-};--const expandedRowKeys = ref<string[]>([]);--const durationSeconds = (duration: Duration | undefined) => {- if (!duration) return 0;- const { seconds, nanos } = duration;- return seconds.toNumber() + nanos / 1e9;-};--const durationText = (duration: Duration | undefined) => {- if (!duration) return "-";- const total = durationSeconds(duration);- return total.toFixed(2) + "s";-};--const rowProps = (row: ComposedSlowQueryLog) => {- return {- style: "cursor: pointer;",- onClick: () => {- emit("select", row);- },- };-};-</script>diff --git a/frontend/src/components/SlowQuery/Panel/SlowQueryPanel.vue b/frontend/src/components/SlowQuery/Panel/SlowQueryPanel.vuedeleted file mode 100644index 476efcaa27..0000000000--- a/frontend/src/components/SlowQuery/Panel/SlowQueryPanel.vue+++ /dev/null@@ -1,229 +0,0 @@-<template>- <div class="space-y-4" v-bind="$attrs">- <LogFilter- v-model:params="state.params"- :loading="loading"- :readonly-scopes="readonlySearchScopes"- :support-option-id-list="supportOptionIdList"- >- <template #suffix>- <NButton- v-if="allowAdmin"- type="default"- @click="state.showSetting = true"- >- {{ $t("common.configure") }}- </NButton>- <NButton- v-if="hasSyncPermission"- type="primary"- :disabled="!allowSync"- :loading="syncing"- @click="syncNow"- >- {{ $t("common.sync-now") }}- </NButton>- </template>- </LogFilter>- <div class="relative min-h-[8rem] w-full max-w-full overflow-auto">- <LogTable- :slow-query-log-list="slowQueryLogList"- :show-placeholder="!loading"- :show-project-column="showProjectColumn"- :show-environment-column="showEnvironmentColumn"- :show-instance-column="showInstanceColumn"- :show-database-column="showDatabaseColumn"- :allow-admin="allowAdmin"- @select="selectSlowQueryLog"- />- <div- v-if="loading"- class="absolute inset-0 bg-white/50 flex flex-col items-center pt-[6rem]"- >- <BBSpin />- </div>- </div>-- <DetailPanel- :slow-query-log="selectedSlowQueryLog"- @close="selectedSlowQueryLog = undefined"- />- </div>-- <Drawer v-model:show="state.showSetting" width="auto">- <DrawerContent- :closable="true"- class="w-[calc(100vw-2rem)] lg:max-w-[64rem] xl:max-w-[72rem]"- >- <SlowQuerySettings />- </DrawerContent>- </Drawer>-</template>--<script lang="ts" setup>-import dayjs from "dayjs";-import { NButton } from "naive-ui";-import { computed, shallowRef, watch, reactive } from "vue";-import { useI18n } from "vue-i18n";-import { BBSpin } from "@/bbkit";-import { Drawer, DrawerContent } from "@/components/v2";-import {- pushNotification,- useGracefulRequest,- useSlowQueryPolicyList,- useSlowQueryPolicyStore,- useSlowQueryStore,-} from "@/store";-import type { ComposedSlowQueryLog, Permission } from "@/types";-import type { SearchScope, SearchParams, SearchScopeId } from "@/utils";-import { extractInstanceResourceName, hasWorkspacePermissionV2 } from "@/utils";-import { SlowQuerySettings } from "../Settings";-import DetailPanel from "./DetailPanel.vue";-import LogFilter from "./LogFilter.vue";-import LogTable from "./LogTable.vue";-import { buildListSlowQueriesRequest } from "./types";--const props = withDefaults(- defineProps<{- supportOptionIdList?: SearchScopeId[];- readonlySearchScopes?: SearchScope[];- showProjectColumn?: boolean;- showEnvironmentColumn?: boolean;- showInstanceColumn?: boolean;- showDatabaseColumn?: boolean;- }>(),- {- supportOptionIdList: () => ["environment", "project", "database"],- readonlySearchScopes: () => [],- showProjectColumn: true,- showEnvironmentColumn: true,- showInstanceColumn: true,- showDatabaseColumn: true,- }-);--interface LocalState {- params: SearchParams;- showSetting: boolean;-}--const defaultSlowQueryTimeRange = computed(() => {- const now = dayjs();- const aWeekAgo = now.subtract(7, "days").startOf("day").valueOf();- const tonight = now.endOf("day").valueOf();- return {- fromTime: aWeekAgo,- toTime: tonight,- };-});--const state = reactive<LocalState>({- params: {- query: "",- scopes: [- ...props.readonlySearchScopes,- {- id: "created",- value: `${defaultSlowQueryTimeRange.value.fromTime},${defaultSlowQueryTimeRange.value.toTime}`,- },- ],- },- showSetting: false,-});--const { t } = useI18n();-const slowQueryStore = useSlowQueryStore();-const loading = shallowRef(false);-const slowQueryLogList = shallowRef<ComposedSlowQueryLog[]>([]);-const selectedSlowQueryLog = shallowRef<ComposedSlowQueryLog>();-const syncing = shallowRef(false);--const hasSyncPermission = computed(() =>- hasWorkspacePermissionV2("bb.instances.sync")-);--const selectedInstanceName = computed(() => {- return state.params.scopes.find((s) => s.id === "instance")?.value;-});--const selectedProjectName = computed(() => {- return state.params.scopes.find((s) => s.id === "project")?.value;-});--const params = computed(() => buildListSlowQueriesRequest(state.params));--const allowAdmin = computed(() => {- const neededWorkspacePermissions: Permission[] = [- "bb.instances.list",- "bb.policies.update",- ];- return neededWorkspacePermissions.every((permission) =>- hasWorkspacePermissionV2(permission)- );-});--const { list: slowQueryPolicyList } = useSlowQueryPolicyList();--const allowSync = computed(() => {- return (- slowQueryPolicyList.value.filter((policy) => policy.slowQueryPolicy?.active)- .length > 0- );-});--const fetchSlowQueryLogList = async () => {- loading.value = true;- try {- const list = await slowQueryStore.fetchSlowQueryLogList(params.value);- slowQueryLogList.value = list;- } finally {- loading.value = false;- }-};--const selectSlowQueryLog = (log: ComposedSlowQueryLog) => {- selectedSlowQueryLog.value = log;-};--const syncNow = async () => {- syncing.value = true;- try {- await useGracefulRequest(async () => {- if (selectedInstanceName.value) {- await slowQueryStore.syncSlowQueries(- `instances/${selectedInstanceName.value}`- );- } else if (selectedProjectName.value) {- await slowQueryStore.syncSlowQueries(- `projects/${selectedProjectName.value}`- );- } else {- const policyList = await useSlowQueryPolicyStore().fetchPolicyList();- const requestList = policyList- .filter((policy) => {- return policy.slowQueryPolicy?.active;- })- .map(async (policy) => {- return slowQueryStore.syncSlowQueries(- `instances/${extractInstanceResourceName(policy.name)}`- );- });- await Promise.all(requestList);- }-- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("slow-query.sync-job-started"),- });- });- } finally {- syncing.value = false;- }-};--// Fetch the list while params changed.-watch(() => JSON.stringify(params.value), fetchSlowQueryLogList, {- immediate: true,-});-</script>diff --git a/frontend/src/components/SlowQuery/Panel/index.ts b/frontend/src/components/SlowQuery/Panel/index.tsdeleted file mode 100644index 7a80007fc7..0000000000--- a/frontend/src/components/SlowQuery/Panel/index.ts+++ /dev/null@@ -1,4 +0,0 @@-import SlowQueryPanel from "./SlowQueryPanel.vue";--export * from "./types";-export { SlowQueryPanel };diff --git a/frontend/src/components/SlowQuery/Panel/types.ts b/frontend/src/components/SlowQuery/Panel/types.tsdeleted file mode 100644index 01c978781f..0000000000--- a/frontend/src/components/SlowQuery/Panel/types.ts+++ /dev/null@@ -1,38 +0,0 @@-import dayjs from "dayjs";-import { useDatabaseV1Store } from "@/store";-import { isValidDatabaseName } from "@/types";-import { ListSlowQueriesRequest } from "@/types/proto/v1/database_service";-import { getTsRangeFromSearchParams, type SearchParams } from "@/utils";--export const buildListSlowQueriesRequest = (searchParams: SearchParams) => {- const request = {} as Partial<ListSlowQueriesRequest>;-- const { scopes } = searchParams;- const project = scopes.find((s) => s.id === "project")?.value;- const environment = scopes.find((s) => s.id === "environment")?.value;- const database = scopes.find((s) => s.id === "database")?.value;- const createdTsRange = getTsRangeFromSearchParams(searchParams, "created");-- const query: string[] = [];- request.parent = `projects/${project}`;- if (database) {- const db = useDatabaseV1Store().getDatabaseByName(database);- if (isValidDatabaseName(db.name)) {- query.push(`database = "${db.name}"`);- }- } else if (environment) {- query.push(`environment = "environments/${environment}"`);- }- if (createdTsRange) {- const start = dayjs(createdTsRange[0]).toISOString();- const end = dayjs(createdTsRange[1]).toISOString();- query.push(`start_time >= "${start}"`);- query.push(`start_time <= "${end}"`);- }- if (query.length > 0) {- request.filter = query.join(" && ");- }-- request.orderBy = "maximum_query_time desc";- return ListSlowQueriesRequest.fromJSON(request);-};diff --git a/frontend/src/components/SlowQuery/Settings/SlowQuerySettings.vue b/frontend/src/components/SlowQuery/Settings/SlowQuerySettings.vuedeleted file mode 100644index 6eca8fe86d..0000000000--- a/frontend/src/components/SlowQuery/Settings/SlowQuerySettings.vue+++ /dev/null@@ -1,182 +0,0 @@-<template>- <div class="space-y-4 pb-4 max-w-full">- <div class="textinfolabel">- {{ $t("slow-query.attention-description") }}- <a- href="https://www.bytebase.com/docs/slow-query/overview?source=console"- target="_blank"- class="normal-link inline-flex flex-row items-center"- >- {{ $t("common.learn-more") }}- <heroicons-outline:external-link class="w-4 h-4" />- </a>- </div>- <div class="flex items-center justify-between">- <EnvironmentTabFilter- :environment="state.filter.environment?.name"- :include-all="true"- @update:environment="changeEnvironment"- />- <SearchBox v-model:value="state.filter.keyword" />- </div>- <SlowQueryPolicyTable- :composed-slow-query-policy-list="filteredComposedSlowQueryPolicyList"- :policy-list="policyList"- :toggle-active="toggleActive"- :ready="state.ready"- :show-placeholder="true"- />- </div>-</template>--<script lang="ts" setup>-import { orderBy, head } from "lodash-es";-import { computed, onMounted, reactive } from "vue";-import { useI18n } from "vue-i18n";-import { EnvironmentTabFilter, SearchBox } from "@/components/v2";-import {- pushNotification,- useEnvironmentV1List,- useEnvironmentV1Store,- useInstanceV1List,- useInstanceV1Store,- useSlowQueryPolicyStore,- useSlowQueryStore,-} from "@/store";-import { useGracefulRequest } from "@/store/modules/utils";-import { getInstanceId, getInstanceIdPolicyId } from "@/store/modules/v1/common";-import type { ComposedSlowQueryPolicy } from "@/types";-import { isValidEnvironmentName } from "@/types";-import type { Environment } from "@/types/proto/v1/environment_service";-import type { InstanceResource } from "@/types/proto/v1/instance_service";-import { instanceV1SupportSlowQuery, wrapRefAsPromise } from "@/utils";-import { SlowQueryPolicyTable } from "./components";--type LocalState = {- ready: boolean;- filter: {- environment: Environment | undefined;- keyword: string;- };-};--const state = reactive<LocalState>({- ready: false,- filter: {- environment: undefined,- keyword: "",- },-});--const { t } = useI18n();-const environmentList = useEnvironmentV1List(false /* !showDeleted */);-const environmentStore = useEnvironmentV1Store();-const slowQueryPolicyStore = useSlowQueryPolicyStore();-const slowQueryStore = useSlowQueryStore();-const instanceV1Store = useInstanceV1Store();--const policyList = computed(() => {- return slowQueryPolicyStore.getPolicyList();-});--const instanceList = computed(() => {- return instanceV1Store.instanceList.filter(instanceV1SupportSlowQuery);-});--const composedSlowQueryPolicyList = computed(() => {- const list = instanceList.value.map<ComposedSlowQueryPolicy>((instance) => {- const policy = policyList.value.find(- (p) => head(getInstanceIdPolicyId(p.name)) === head(getInstanceId(instance.name))- );- return {- instance,- active: policy?.slowQueryPolicy?.active ?? false,- };- });-- return orderBy(- list,- [- (item) => item.instance.engine,- (item) =>- environmentStore.getEnvironmentByName(item.instance.environment).order,- (item) => item.instance.name,- ],- ["asc", "desc", "asc"]- );-});--const filteredComposedSlowQueryPolicyList = computed(() => {- let list = [...composedSlowQueryPolicyList.value];- const { environment } = state.filter;- if (isValidEnvironmentName(environment?.name)) {- list = list.filter(- (item) => item.instance.environment === environment.name- );- }- const keyword = state.filter.keyword.trim().toLowerCase();- if (keyword) {- list = list.filter((item) =>- item.instance.name.toLowerCase().includes(keyword)- );- }-- return list;-});--const prepare = async () => {- try {- const prepareInstanceList = async () => {- await wrapRefAsPromise(useInstanceV1List().ready, true);- };- const preparePolicyList = async () => {- await slowQueryPolicyStore.fetchPolicyList();- };- await Promise.all([prepareInstanceList(), preparePolicyList()]);- } finally {- state.ready = true;- }-};--const changeEnvironment = (name: string | undefined) => {- state.filter.environment = environmentList.value.find(- (env) => env.name === name- );-};--const patchInstanceSlowQueryPolicy = async (- instance: InstanceResource,- active: boolean-) => {- return slowQueryPolicyStore.upsertPolicy({- parentPath: instance.name,- active,- });-};--const toggleActive = async (instance: InstanceResource, active: boolean) => {- try {- await patchInstanceSlowQueryPolicy(instance, active);- if (active) {- // When turning ON an instance's slow query, call the corresponding- // API endpoint to sync slow queries from the instance immediately.- try {- await useGracefulRequest(() =>- slowQueryStore.syncSlowQueries(instance.name)- );- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.updated"),- });- } catch {- await patchInstanceSlowQueryPolicy(instance, false);- }- }- } catch {- // nothing- }-};--onMounted(prepare);-</script>diff --git a/frontend/src/components/SlowQuery/Settings/components/SlowQueryPolicyTable.vue b/frontend/src/components/SlowQuery/Settings/components/SlowQueryPolicyTable.vuedeleted file mode 100644index 84938dff66..0000000000--- a/frontend/src/components/SlowQuery/Settings/components/SlowQueryPolicyTable.vue+++ /dev/null@@ -1,75 +0,0 @@-<template>- <BBGrid- :column-list="COLUMNS"- :data-source="composedSlowQueryPolicyList"- :row-clickable="false"- :row-key="(item: ComposedSlowQueryPolicy) => item.instance.name"- class="border"- >- <template #item="{ item }: { item: ComposedSlowQueryPolicy }">- <div class="bb-grid-cell">- <InstanceV1Name :instance="item.instance" :link="false" />- </div>-- <div class="bb-grid-cell">- <EnvironmentV1Name- :environment="- environmentStore.getEnvironmentByName(item.instance.environment)- "- :link="false"- />- </div>- <div class="bb-grid-cell">- <SpinnerSwitch- :value="item.active"- :disabled="!allowAdmin"- :on-toggle="(active) => toggleActive(item.instance, active)"- />- </div>- </template>- </BBGrid>-</template>--<script lang="ts" setup>-import { computed } from "vue";-import { useI18n } from "vue-i18n";-import { type BBGridColumn, BBGrid } from "@/bbkit";-import {- InstanceV1Name,- EnvironmentV1Name,- SpinnerSwitch,-} from "@/components/v2";-import { useEnvironmentV1Store } from "@/store";-import type { ComposedSlowQueryPolicy } from "@/types";-import type { InstanceResource } from "@/types/proto/v1/instance_service";-import { hasWorkspacePermissionV2 } from "@/utils";--defineProps<{- composedSlowQueryPolicyList: ComposedSlowQueryPolicy[];- toggleActive: (instance: InstanceResource, active: boolean) => Promise<void>;-}>();--const { t } = useI18n();-const environmentStore = useEnvironmentV1Store();--const COLUMNS = computed((): BBGridColumn[] => {- return [- {- title: t("common.instance"),- width: "2fr",- },- {- title: t("common.environment"),- width: "minmax(auto, 1fr)",- },- {- title: t("slow-query.report"),- width: "minmax(auto, 6rem)",- },- ];-});--const allowAdmin = computed(() => {- return hasWorkspacePermissionV2("bb.policies.update");-});-</script>diff --git a/frontend/src/components/SlowQuery/Settings/components/index.ts b/frontend/src/components/SlowQuery/Settings/components/index.tsdeleted file mode 100644index c501e35400..0000000000--- a/frontend/src/components/SlowQuery/Settings/components/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import SlowQueryPolicyTable from "./SlowQueryPolicyTable.vue";--export { SlowQueryPolicyTable };diff --git a/frontend/src/components/SlowQuery/Settings/index.ts b/frontend/src/components/SlowQuery/Settings/index.tsdeleted file mode 100644index 9cb796ae50..0000000000--- a/frontend/src/components/SlowQuery/Settings/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import SlowQuerySettings from "./SlowQuerySettings.vue";--export { SlowQuerySettings };diff --git a/frontend/src/components/SlowQuery/index.ts b/frontend/src/components/SlowQuery/index.tsdeleted file mode 100644index 1b257b334e..0000000000--- a/frontend/src/components/SlowQuery/index.ts+++ /dev/null@@ -1,2 +0,0 @@-export * from "./Settings";-export * from "./Panel";diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 1855aa28a8..f6b3cc3a21 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -79,7 +79,6 @@"updated-at": "Updated","statement": "Statement","statement-size": "Statement size",- "sql-statement": "SQL statement","snapshot": "Snapshot","status": "Status","stage": "Stage",@@ -153,7 +152,6 @@"view-doc": "View doc","write-only": "write only","sync": "Sync",- "sync-now": "Sync Now","success": "Succeed","failed": "Failed","load-more": "Load more",@@ -2326,35 +2324,9 @@},"slow-query": {"slow-queries": "Slow queries",- "report": "Report",- "last-query-time": "Last query time",- "sql-statement": "SQL statement",- "total-query-count": "Total query count",- "query-count-percent": "Query count %",- "max-query-time": "Max query time",- "avg-query-time": "Avg query time",- "query-time-percent": "Query time %",- "max-rows-examined": "Max rows examined",- "avg-rows-examined": "Avg rows examined",- "max-rows-sent": "Max rows sent",- "avg-rows-sent": "Avg rows sent",- "query-start-time": "Query start time",- "rows-examined": "Rows examined",- "rows-sent": "Rows sent",- "lock-time": "Lock time",- "query-time": "Query time",- "attention-description": "Bytebase periodically syncs slow query logs from instances. For MySQL instance, slow_query must be enabled first. For PostgreSQL instance, only databases with pg_stat_statements enabled will collect slow queries.",- "sync-job-started": "Sync jobs started. Please wait for the jobs to complete.",- "detail": "Slow Query Detail","advise-index": {- "current-index": "Current Index",- "suggestion": "Suggestion",- "create-index": "Create Index",- "setup-openai-key-to-enable": "Setup OpenAI key to enable index advisor"},"no-log-placeholder": {- "admin": "Click the \"Configure\" button to fetch slow queries from the database instances or click the \"Sync Now\" button to sync slow query logs immediately",- "developer": "Click the \"Sync Now\" button to sync slow query logs immediately or contact Bytebase admins/DBAs to configure slow queries"}},"schema-template": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex e333bb93dc..68ad6524f0 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -79,7 +79,6 @@"updated-at": "Actualizado","statement": "Declaración","statement-size": "Tamaño de la declaración",- "sql-statement": "Declaración SQL","snapshot": "Instantánea","status": "Estado","stage": "Etapa",@@ -153,7 +152,6 @@"view-doc": "Ver doc","write-only": "solo escritura","sync": "Sincronizar",- "sync-now": "Sincronizar ahora","success": "Éxito","failed": "Falló","load-more": "Cargar más",@@ -2325,35 +2323,9 @@},"slow-query": {"slow-queries": "Consultas lentas",- "report": "Reportar",- "last-query-time": "Hora de la última consulta",- "sql-statement": "Sentencia SQL",- "total-query-count": "Total de consultas",- "query-count-percent": "% de consultas",- "max-query-time": "Tiempo máximo de consulta",- "avg-query-time": "Tiempo promedio de consulta",- "query-time-percent": "% de tiempo de consulta",- "max-rows-examined": "Máximo de filas examinadas",- "avg-rows-examined": "Promedio de filas examinadas",- "max-rows-sent": "Máximo de filas enviadas",- "avg-rows-sent": "Promedio de filas enviadas",- "query-start-time": "Hora de inicio de la consulta",- "rows-examined": "Filas examinadas",- "rows-sent": "Filas enviadas",- "lock-time": "Tiempo de bloqueo",- "query-time": "Tiempo de consulta",- "attention-description": "Bytebase sincroniza periódicamente los registros de consultas lentas de las instancias. Para una instancia de MySQL, slow_query debe estar habilitado primero. Para una instancia de PostgreSQL, solo se recopilarán las consultas lentas si se habilita pg_stat_statements en la base de datos.",- "sync-job-started": "Se iniciaron trabajos de sincronización. Espere a que los trabajos se completen.",- "detail": "Detalles de la consulta lenta","advise-index": {- "current-index": "Índice actual",- "suggestion": "Sugerencia",- "create-index": "Crear índice",- "setup-openai-key-to-enable": "Configure la clave de OpenAI para habilitar el asesor de índices"},"no-log-placeholder": {- "admin": "Haga clic en el botón \"Configurar\" para obtener consultas lentas de las instancias de la base de datos o haga clic en el botón \"Sincronizar ahora\" para sincronizar los registros de consultas lentas de inmediato",- "developer": "Haga clic en el botón \"Sincronizar ahora\" para sincronizar los registros de consultas lentas inmediatamente o comuníquese con los administradors/DBA de Bytebase para configurar consultas lentas"}},"schema-template": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 9e2deb3cf6..2b71e2e82a 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -79,7 +79,6 @@"updated-at": "更新日時","statement": "ステートメント","statement-size": "ステートメントサイズ",- "sql-statement": "SQL@:{'common.statement'}","snapshot": "スナップショット","status": "州","stage": "ステージ",@@ -153,7 +152,6 @@"view-doc": "ドキュメントを見る","write-only": "書き込み専用","sync": "同期する",- "sync-now": "今すぐ同期する","success": "成功","failed": "失敗","load-more": "もっと読み込む",@@ -2325,35 +2323,9 @@},"slow-query": {"slow-queries": "遅いクエリ",- "report": "報告",- "last-query-time": "最終実行時刻",- "sql-statement": "SQL文",- "total-query-count": "合計実行時間",- "query-count-percent": "約定比率",- "max-query-time": "最大実行時間",- "avg-query-time": "平均実行時間",- "query-time-percent": "実行時間比率",- "max-rows-examined": "最大走査線数",- "avg-rows-examined": "平均スキャンライン数",- "max-rows-sent": "返される行の最大数",- "avg-rows-sent": "返される平均行数",- "query-start-time": "実行開始時刻",- "rows-examined": "解析された行数",- "rows-sent": "行数を返す",- "lock-time": "ロックが保持される時間",- "query-time": "実行時間",- "attention-description": "Bytebase は、インスタンスからの低速クエリ ログを定期的に同期します。 MySQL インスタンスの場合は、まず、slow_query を有効にする必要があります。 PostgreSQL インスタンスの場合、pg_stat_statements がオンになっているデータベースのみが遅いクエリを収集します。",- "sync-job-started": "同期ジョブが開始されました。同期が完了するまでお待ちください。",- "detail": "遅いクエリの詳細","advise-index": {- "current-index": "現在のインデックス",- "suggestion": "提案",- "create-index": "インデックスの作成",- "setup-openai-key-to-enable": "OpenAI API キーを設定して、インデックス提案機能を有効にします。"},"no-log-placeholder": {- "admin": "[設定] ボタンをクリックしてデータベース インスタンスからスロー クエリ ログを取得するか、[今すぐ同期] ボタンをクリックしてスロー クエリ ログをすぐに同期します。",- "developer": "[今すぐ同期] ボタンをクリックしてスロー クエリ ログをすぐに同期するか、ワークスペース管理者または DBA に問い合わせてスロー クエリ機能を設定してください。"}},"schema-template": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 9001d3457e..b2c79fb666 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -79,7 +79,6 @@"updated-at": "Thời gian cập nhật","statement": "Câu lệnh","statement-size": "Kích thước câu lệnh",- "sql-statement": "Câu lệnh SQL","snapshot": "Ảnh chụp nhanh","status": "Trạng thái","stage": "Giai đoạn",@@ -153,7 +152,6 @@"view-doc": "Xem tài liệu","write-only": "chỉ ghi","sync": "Đồng bộ hóa",- "sync-now": "Đồng bộ hóa ngay","success": "Thành công","failed": "Thất bại","load-more": "Tải thêm",@@ -2325,35 +2323,9 @@},"slow-query": {"slow-queries": "Truy vấn chậm",- "report": "Báo cáo",- "last-query-time": "Thời gian truy vấn cuối cùng",- "sql-statement": "Câu lệnh SQL",- "total-query-count": "Tổng số truy vấn",- "query-count-percent": "Phần trăm số truy vấn",- "max-query-time": "Thời gian truy vấn tối đa",- "avg-query-time": "Thời gian truy vấn trung bình",- "query-time-percent": "Phần trăm thời gian truy vấn",- "max-rows-examined": "Số dòng được kiểm tra tối đa",- "avg-rows-examined": "Số dòng được kiểm tra trung bình",- "max-rows-sent": "Số dòng được gửi tối đa",- "avg-rows-sent": "Số dòng được gửi trung bình",- "query-start-time": "Thời gian bắt đầu truy vấn",- "rows-examined": "Số dòng đã kiểm tra",- "rows-sent": "Số dòng đã gửi",- "lock-time": "Thời gian khóa",- "query-time": "Thời gian truy vấn",- "attention-description": "Bytebase định kỳ đồng bộ nhật ký truy vấn chậm từ các phiên bản. Đối với phiên bản MySQL, slow_query phải được bật trước. Đối với phiên bản PostgreSQL, chỉ những cơ sở dữ liệu đã bật pg_stat_statements mới thu thập các truy vấn chậm.",- "sync-job-started": "Đã bắt đầu công việc đồng bộ. Vui lòng đợi công việc hoàn thành.",- "detail": "Chi tiết truy vấn chậm","advise-index": {- "current-index": "Chỉ mục hiện tại",- "suggestion": "Đề xuất",- "create-index": "Tạo chỉ mục",- "setup-openai-key-to-enable": "Thiết lập khóa OpenAI để bật cố vấn chỉ mục"},"no-log-placeholder": {- "admin": "Nhấp vào nút \"Định cấu hình\" để tìm nạp các truy vấn chậm từ các phiên bản cơ sở dữ liệu hoặc nhấp vào nút \"Đồng bộ hóa ngay\" để đồng bộ nhật ký truy vấn chậm ngay lập tức",- "developer": "Nhấp vào nút \"Đồng bộ hóa ngay\" để đồng bộ nhật ký truy vấn chậm ngay lập tức hoặc liên hệ với quản trị viên/DBA Bytebase để định cấu hình các truy vấn chậm"}},"schema-template": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 2321d98dd3..21f939d0be 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -79,7 +79,6 @@"updated-at": "更新于","statement": "语句","statement-size": "语句大小",- "sql-statement": "SQL @:{'common.statement'}","snapshot": "快照","status": "状态","stage": "阶段",@@ -153,7 +152,6 @@"view-doc": "查看文档","write-only": "仅写入","sync": "同步",- "sync-now": "现在同步","success": "成功","failed": "失败","load-more": "加载更多",@@ -2325,35 +2323,9 @@},"slow-query": {"slow-queries": "慢查询",- "report": "报告",- "last-query-time": "最近执行时间",- "sql-statement": "SQL 语句",- "total-query-count": "总执行次数",- "query-count-percent": "执行次数比例",- "max-query-time": "最大执行时长",- "avg-query-time": "平均执行时长",- "query-time-percent": "执行时长比例",- "max-rows-examined": "最大扫描行数",- "avg-rows-examined": "平均扫描行数",- "max-rows-sent": "最大返回行数",- "avg-rows-sent": "平均返回行数",- "query-start-time": "执行开始时间",- "rows-examined": "解析行数",- "rows-sent": "返回行数",- "lock-time": "持有锁时长",- "query-time": "执行时长",- "attention-description": "Bytebase 定期从实例上同步慢查询日志。对 MySQL 实例,需要先开启 slow_query。对 PostgreSQL 实例,只有开启 pg_stat_statements 的数据库才会收集慢查询。",- "sync-job-started": "同步作业已启动。请等待同步完成。",- "detail": "慢查询详情","advise-index": {- "current-index": "当前索引",- "suggestion": "建议",- "create-index": "创建索引",- "setup-openai-key-to-enable": "设置 OpenAI API Key 以开启索引建议功能。"},"no-log-placeholder": {- "admin": "点击「配置」按钮从数据库实例上抓取慢查询日志或点击「立即同步」按钮立即同步慢查询日志",- "developer": "点击「立即同步」按钮立即同步慢查询日志或联系工作空间管理员或 DBA 配置慢查询功能"}},"schema-template": {diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.tsindex 3b8def621e..937f8c177a 100644--- a/frontend/src/router/dashboard/projectV1.ts+++ b/frontend/src/router/dashboard/projectV1.ts@@ -19,7 +19,6 @@ export const PROJECT_V1_ROUTE_PLAN_DETAIL = `${PROJECT_V1_ROUTE_DASHBOARD}.plan.export const PROJECT_V1_ROUTE_CHANGELISTS = `${PROJECT_V1_ROUTE_DASHBOARD}.changelist`;export const PROJECT_V1_ROUTE_CHANGELIST_DETAIL = `${PROJECT_V1_ROUTE_DASHBOARD}.changelist.detail`;export const PROJECT_V1_ROUTE_SYNC_SCHEMA = `${PROJECT_V1_ROUTE_DASHBOARD}.sync-schema`;-export const PROJECT_V1_ROUTE_SLOW_QUERIES = `${PROJECT_V1_ROUTE_DASHBOARD}.slow-queries`;export const PROJECT_V1_ROUTE_ANOMALIES = `${PROJECT_V1_ROUTE_DASHBOARD}.anomalies`;export const PROJECT_V1_ROUTE_AUDIT_LOGS = `${PROJECT_V1_ROUTE_DASHBOARD}.audit-logs`;export const PROJECT_V1_ROUTE_WEBHOOKS = `${PROJECT_V1_ROUTE_DASHBOARD}.webhook`;@@ -218,20 +217,6 @@ const projectV1Routes: RouteRecordRaw[] = [import("@/views/project/ProjectSyncDatabasePanelV1.vue"),props: true,},- {- path: "slow-queries",- name: PROJECT_V1_ROUTE_SLOW_QUERIES,- meta: {- overrideTitle: true,- requiredProjectPermissionList: () => [- "bb.projects.get",- "bb.slowQueries.list",- ],- },- component: () =>- import("@/views/project/ProjectSlowQueryDashboard.vue"),- props: true,- },{path: "anomalies",name: PROJECT_V1_ROUTE_ANOMALIES,diff --git a/frontend/src/store/modules/index.ts b/frontend/src/store/modules/index.tsindex 4eaf1ef7b8..07e73c83f1 100644--- a/frontend/src/store/modules/index.ts+++ b/frontend/src/store/modules/index.ts@@ -2,7 +2,6 @@ export * from "./auth";export * from "./command";export * from "./help";export * from "./notification";-export * from "./slowQueryPolicy";export * from "./router";export * from "./sqlEditor";export * from "./uistate";@@ -12,7 +11,6 @@ export * from "./idp";export * from "./user";export * from "./risk";export * from "./workspaceApprovalSetting";-export * from "./slowQuery";export * from "./role";export * from "./dbGroup";export * from "./utils";diff --git a/frontend/src/store/modules/slowQuery.ts b/frontend/src/store/modules/slowQuery.tsdeleted file mode 100644index 1f198c398c..0000000000--- a/frontend/src/store/modules/slowQuery.ts+++ /dev/null@@ -1,46 +0,0 @@-import { defineStore } from "pinia";-import { databaseServiceClient, instanceServiceClient } from "@/grpcweb";-import type { ComposedSlowQueryLog } from "@/types";-import type {- ListSlowQueriesRequest,- SlowQueryLog,-} from "@/types/proto/v1/database_service";-import { useDatabaseV1Store, batchGetOrFetchDatabases } from "./v1/database";--export const useSlowQueryStore = defineStore("slow-query", () => {- const fetchSlowQueryLogList = async (- request: Partial<ListSlowQueriesRequest> = {}- ) => {- try {- const response = await databaseServiceClient.listSlowQueries(request);- const composedLogList = await composeSlowQueryLogDatabase(- response.slowQueryLogs- );- return composedLogList;- } catch {- return [];- }- };-- const syncSlowQueries = async (parent: string) => {- await instanceServiceClient.syncSlowQueries({- parent,- });- };-- return { fetchSlowQueryLogList, syncSlowQueries };-});--const composeSlowQueryLogDatabase = async (- slowQueryLogList: SlowQueryLog[]-) => {- const databaseNameList = slowQueryLogList.map((log) => log.resource);- await batchGetOrFetchDatabases(databaseNameList);- const databaseStore = useDatabaseV1Store();-- return slowQueryLogList.map<ComposedSlowQueryLog>((log, index) => ({- id: `${index}`,- log,- database: databaseStore.getDatabaseByName(log.resource),- }));-};diff --git a/frontend/src/store/modules/slowQueryPolicy.ts b/frontend/src/store/modules/slowQueryPolicy.tsdeleted file mode 100644index e409e2907e..0000000000--- a/frontend/src/store/modules/slowQueryPolicy.ts+++ /dev/null@@ -1,86 +0,0 @@-import { defineStore } from "pinia";-import { computed, ref, watchEffect } from "vue";-import { UNKNOWN_USER_NAME } from "@/types";-import type { Policy } from "@/types/proto/v1/org_policy_service";-import {- PolicyType,- PolicyResourceType,-} from "@/types/proto/v1/org_policy_service";-import { useCurrentUserV1 } from "./auth";-import { usePolicyV1Store } from "./v1/policy";--export const useSlowQueryPolicyStore = defineStore("slow-query-policy", () => {- const policyStore = usePolicyV1Store();- const policyMapByName = ref(new Map<string, Policy>());-- const getPolicyList = () => {- return [...policyMapByName.value.values()];- };-- const setPolicyList = (policyList: Policy[]) => {- for (const policy of policyList) {- policyMapByName.value.set(policy.name, policy);- }- };-- const fetchPolicyList = async () => {- const policyList = await policyStore.fetchPolicies({- resourceType: PolicyResourceType.INSTANCE,- policyType: PolicyType.SLOW_QUERY,- showDeleted: true,- });-- setPolicyList(policyList);- return policyList;- };-- const upsertPolicy = async ({- parentPath,- active,- }: {- parentPath: string;- active: boolean;- }) => {- const policy = await policyStore.upsertPolicy({- parentPath,- policy: {- type: PolicyType.SLOW_QUERY,- slowQueryPolicy: {- active,- },- },- });-- if (policy) {- policyMapByName.value.set(policy.name, policy);- }-- return policy;- };-- return {- getPolicyList,- fetchPolicyList,- upsertPolicy,- };-});--export const useSlowQueryPolicyList = () => {- const store = useSlowQueryPolicyStore();- const currentUserV1 = useCurrentUserV1();- const ready = ref(false);-- watchEffect(() => {- if (currentUserV1.value.name === UNKNOWN_USER_NAME) return;- ready.value = false;- store.fetchPolicyList().finally(() => {- ready.value = true;- });- });-- const list = computed(() => {- return store.getPolicyList();- });-- return { list, ready };-};diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.tsindex 4e38b9b6ec..a3eb39a25c 100644--- a/frontend/src/types/index.ts+++ b/frontend/src/types/index.ts@@ -20,7 +20,6 @@ export * from "./utils";export * from "./risk";export * from "./workspaceApprovalSetting";export * from "./review";-export * from "./slowQuery";export * from "./dbGroup";export * from "./setting";export * from "./changelog";diff --git a/frontend/src/types/slowQuery.ts b/frontend/src/types/slowQuery.tsdeleted file mode 100644index 0fdad98bc8..0000000000--- a/frontend/src/types/slowQuery.ts+++ /dev/null@@ -1,14 +0,0 @@-import type { SlowQueryLog } from "./proto/v1/database_service";-import type { InstanceResource } from "./proto/v1/instance_service";-import type { ComposedDatabase } from "./v1/database";--export type ComposedSlowQueryLog = {- id: string;- log: SlowQueryLog;- database: ComposedDatabase;-};--export type ComposedSlowQueryPolicy = {- instance: InstanceResource;- active: boolean;-};diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.tsindex 17de3f0d9d..5432d3cba7 100644--- a/frontend/src/utils/index.ts+++ b/frontend/src/utils/index.ts@@ -17,7 +17,6 @@ export * from "./sso";export * from "./math";export * from "./idp";export * from "./workspaceApprovalSetting";-export * from "./slowQuery";export * from "./resource-composer";export * from "./TinyTimer";export * from "./sheet";diff --git a/frontend/src/utils/slowQuery.ts b/frontend/src/utils/slowQuery.tsdeleted file mode 100644index a532eb28f2..0000000000--- a/frontend/src/utils/slowQuery.ts+++ /dev/null@@ -1,35 +0,0 @@-import { Engine } from "@/types/proto/v1/common";-import type {- InstanceResource,- Instance as InstanceV1,-} from "@/types/proto/v1/instance_service";-import { semverCompare } from "./util";--export const InstanceV1ListSupportSlowQuery: [Engine, string][] = [- [Engine.MYSQL, "5.7"],- [Engine.POSTGRES, "0"],-];--export const instanceV1SupportSlowQuery = (- instance: InstanceV1 | InstanceResource-) => {- const { engine } = instance;- const item = InstanceV1ListSupportSlowQuery.find(- (item) => item[0] === engine- );- if (item) {- const [_, minVersion] = item;- if (minVersion === "0") return true;- return semverCompare(instance.engineVersion, minVersion, "gte");- }- return false;-};--export const instanceV1HasSlowQueryDetail = (- instance: InstanceV1 | InstanceResource-) => {- const { engine } = instance;- if (engine === Engine.MYSQL) return true;-- return false;-};diff --git a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail/DatabaseDetail.vueindex cd00156272..7198943400 100644--- a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue@@ -133,13 +133,6 @@><DatabaseRevisionPanel class="mt-2" :database="database" /></NTabPane>- <NTabPane- v-if="allowListSlowQueries"- name="slow-query"- :tab="$t('slow-query.slow-queries')"- >- <DatabaseSlowQueryPanel class="mt-2" :database="database" />- </NTabPane><NTabPane name="catalog" :tab="$t('common.catalog')"><DatabaseSensitiveDataPanel class="mt-2" :database="database" /></NTabPane>@@ -210,7 +203,6 @@ import DatabaseChangelogPanel from "@/components/Database/DatabaseChangelogPanelimport DatabaseOverviewPanel from "@/components/Database/DatabaseOverviewPanel.vue";import DatabaseRevisionPanel from "@/components/Database/DatabaseRevisionPanel.vue";import DatabaseSensitiveDataPanel from "@/components/Database/DatabaseSensitiveDataPanel.vue";-import DatabaseSlowQueryPanel from "@/components/Database/DatabaseSlowQueryPanel.vue";import { useDatabaseDetailContext } from "@/components/Database/context";import {DatabaseSettingsPanel,@@ -256,7 +248,6 @@ const databaseHashList = ["overview","changelog","revision",- "slow-query","setting","catalog",] as const;@@ -298,7 +289,6 @@ const {allowChangeData,allowAlterSchema,allowListChangelogs,- allowListSlowQueries,} = useDatabaseDetailContext();const disableSchemaEditor = useAppFeature("bb.feature.issue.disable-schema-editor"diff --git a/frontend/src/views/project/ProjectSlowQueryDashboard.vue b/frontend/src/views/project/ProjectSlowQueryDashboard.vuedeleted file mode 100644index a5b34956fe..0000000000--- a/frontend/src/views/project/ProjectSlowQueryDashboard.vue+++ /dev/null@@ -1,18 +0,0 @@-<template>- <ProjectSlowQueryPanel :project="project" />-</template>--<script setup lang="ts">-import { computed } from "vue";-import ProjectSlowQueryPanel from "@/components/ProjectSlowQueryPanel.vue";-import { useProjectByName } from "@/store";-import { projectNamePrefix } from "@/store/modules/v1/common";--const props = defineProps<{- projectId: string;-}>();--const { project } = useProjectByName(- computed(() => `${projectNamePrefix}${props.projectId}`)-);-</script>