Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
perf: sql editor (part4) (#17247)
ecmadao02c731ce7914
diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/HoverPanel.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/HoverPanel.vueindex b4ebedca8e..06cabb46b2 100644--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/HoverPanel.vue+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/HoverPanel/HoverPanel.vue@@ -100,10 +100,10 @@ const displayPosition = computed(() => {});useEventListener(popoverRef, "mouseenter", () => {- // Reset the value immediately to cancel other pending setting values- update(state.value, "before", 0 /* overrideDelay */);+ // Keep the hover panel visible with a small delay to prevent flicker+ update(state.value, "before", 50);});useEventListener(popoverRef, "mouseleave", () => {- update(undefined, "before");+ update(undefined, "after");});</script>diff --git a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vue b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vueindex 2694b78a2c..08b9d318bb 100644--- a/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vue+++ b/frontend/src/views/sql-editor/AsidePanel/SchemaPane/SchemaPane.vue@@ -87,7 +87,7 @@ import {type TreeOption,} from "naive-ui";import { storeToRefs } from "pinia";-import { computed, h, nextTick, reactive, ref, watch } from "vue";+import { computed, h, nextTick, ref, watch } from "vue";import { watchEffect } from "vue";import { BBModal } from "@/bbkit";import TableSchemaViewer from "@/components/TableSchemaViewer.vue";@@ -131,7 +131,7 @@ const { height: treeContainerHeight } = useElementSize(box: "content-box",});-const searchPatternByTabId = reactive(new Map<string, string>());+const { viewState: panelViewState } = useCurrentTabViewStateContext();const { schemaViewer } = useSQLEditorContext();const {@@ -145,17 +145,18 @@ const {const { selectAllFromTableOrView } = useActions();const { currentTab } = storeToRefs(useSQLEditorTabStore());const { database } = useConnectionOfCurrentSQLEditorTab();-const searchPattern = computed({- get() {- const id = currentTab.value?.id ?? "";- return searchPatternByTabId.get(id) ?? "";- },- set(value) {- const id = currentTab.value?.id ?? "";- searchPatternByTabId.set(id, value);- },-});++// Simple search pattern that resets when tab changes+const searchPattern = ref("");const debouncedSearchPattern = refDebounced(searchPattern, 200);++// Reset search when tab changes+watch(+ () => currentTab.value?.id,+ () => {+ searchPattern.value = "";+ }+);const isFetchingMetadata = ref(false);const metadata = computedAsync(async () => {@@ -263,17 +264,18 @@ const nodeProps = ({ option }: { option: TreeOption }) => {const target = node.meta.target as NodeTarget<"table" | "external-table" | "column" | "view">;- if (hoverState.value) {- updateHoverState(target, "before", 0 /* overrideDelay */);- } else {- updateHoverState(target, "before");- }+ // Use a small delay even when transitioning between nodes+ // to prevent excessive re-renders when moving quickly+ const delay = hoverState.value ? 150 : undefined;+ updateHoverState(target, "before", delay);+nextTick().then(() => {// Find the node element and put the database panel to the bottom// of the node, near the cursorconst wrapper = findAncestor(e.target as HTMLElement, ".n-tree-node");if (!wrapper) {- updateHoverState(undefined, "after", 0 /* overrideDelay */);+ // Clear hover state if we can't find the wrapper+ updateHoverState(undefined, "after", 150);return;}const bounding = wrapper.getBoundingClientRect();diff --git a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseHoverPanel/DatabaseHoverPanel.vue b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseHoverPanel/DatabaseHoverPanel.vueindex 5dcab84400..538d6ac7d2 100644--- a/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseHoverPanel/DatabaseHoverPanel.vue+++ b/frontend/src/views/sql-editor/ConnectionPanel/ConnectionPane/DatabaseHoverPanel/DatabaseHoverPanel.vue@@ -131,10 +131,10 @@ const displayPosition = computed(() => {});useEventListener(popoverRef, "mouseenter", () => {- // Reset the value immediately to cancel other pending setting values- update(state.value, "before", 0 /* overrideDelay */);+ // Keep the hover panel visible with a small delay to prevent flicker+ update(state.value, "before", 50);});useEventListener(popoverRef, "mouseleave", () => {- update(undefined, "before");+ update(undefined, "after");});</script>diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vueindex 15bfd27bbe..18c1b90bd9 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue@@ -30,12 +30,12 @@</template></NInput><span class="ml-2 whitespace-nowrap text-sm text-gray-500">{{- `${data.length} ${t("sql-editor.rows", data.length)}`+ resultRowsText}}</span><spanv-if="currentTab?.mode !== 'ADMIN' &&- data.length === editorStore.resultRowsLimit+ dataLength === editorStore.resultRowsLimit"class="ml-2 whitespace-nowrap text-sm text-gray-500">@@ -333,7 +333,7 @@ const disallowExportQueryData = computed(() => {const viewMode = computed((): ViewMode => {const { result } = props;- if (result.error && data.value.length === 0) {+ if (result.error && dataLength.value === 0) {return "ERROR";}const columnNames = result.columnNames;@@ -407,21 +407,34 @@ const columns = computed(() => {);});+// Memoize the filtered data to avoid filtering on every renderconst data = computed(() => {- let temp = props.result.rows;const search = keyword.value.trim().toLowerCase();- if (search) {- temp = temp.filter((item) => {- return item.values.some((col) => {- const value = extractSQLRowValuePlain(col);- if (isNullOrUndefined(value)) {- return false;- }- return String(value).toLowerCase().includes(search);- });- });++ // Return original rows if no search+ if (!search) {+ return props.result.rows;}- return temp;++ // Only filter when there's a search term+ return props.result.rows.filter((item) => {+ return item.values.some((col) => {+ const value = extractSQLRowValuePlain(col);+ if (isNullOrUndefined(value)) {+ return false;+ }+ return String(value).toLowerCase().includes(search);+ });+ });+});++// Cache data length to avoid multiple accesses+const dataLength = computed(() => data.value.length);++// Computed property for result rows text to avoid accessing data.length twice+const resultRowsText = computed(() => {+ const length = dataLength.value;+ return `${length} ${t("sql-editor.rows", length)}`;});const isSensitiveColumn = (columnIndex: number): boolean => {