Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore(sql-editor): performance tuning for searching the database tree (#6891)

Liu Ji30e84b33a745
diff --git a/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue b/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue
index 12be55548d..e52c825313 100644
--- a/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/DatabaseTree.vue
@@ -20,7 +20,7 @@
<NTree
block-line
:data="treeData"
- :pattern="mounted ? searchPattern : ''"
+ :pattern="mounted ? throttledSearchPattern : ''"
:show-irrelevant-nodes="false"
:expand-on-click="true"
:selected-keys="selectedKeys"
@@ -29,6 +29,7 @@
:render-prefix="renderPrefix"
:render-suffix="renderSuffix"
:node-props="nodeProps"
+ :virtual-scroll="true"
@update:expanded-keys="updateExpandedKeys"
/>
</div>
@@ -53,7 +54,7 @@
import { ref, computed, h, nextTick, watch } from "vue";
import { NTree, NInput, NDropdown, DropdownOption, TreeOption } from "naive-ui";
import { useI18n } from "vue-i18n";
-import { useMounted } from "@vueuse/core";
+import { useMounted, useThrottleFn } from "@vueuse/core";
import type {
ConnectionAtom,
@@ -113,6 +114,7 @@ const isLoggedIn = useIsLoggedIn();
const currentUserV1 = useCurrentUserV1();
const mounted = useMounted();
+const throttledSearchPattern = ref(props.searchPattern);
const showDropdown = ref(false);
const dropdownPosition = ref<Position>({
x: 0,
@@ -374,6 +376,21 @@ watch(
},
{ immediate: true }
);
+
+watch(
+ () => props.searchPattern,
+ useThrottleFn(
+ (searchPattern: string | undefined) => {
+ throttledSearchPattern.value = searchPattern;
+ },
+ 100,
+ true /* trailing */,
+ true /* leading */
+ ),
+ {
+ immediate: true,
+ }
+);
</script>
<style postcss>
diff --git a/frontend/src/views/sql-editor/EditorCommon/index.ts b/frontend/src/views/sql-editor/EditorCommon/index.ts
index 2e8543fad0..997c04ff0e 100644
--- a/frontend/src/views/sql-editor/EditorCommon/index.ts
+++ b/frontend/src/views/sql-editor/EditorCommon/index.ts
@@ -4,7 +4,7 @@ import EditorAction from "./EditorAction.vue";
import ExecutingHintModal from "./ExecutingHintModal.vue";
import SaveSheetModal from "./SaveSheetModal.vue";
import SharePopover from "./SharePopover.vue";
-import { ResultView, ResultViewV1 } from "./ResultView";
+import { ResultViewV1 } from "./ResultView";
export {
ConnectionHolder,
@@ -13,6 +13,5 @@ export {
ExecutingHintModal,
SaveSheetModal,
SharePopover,
- ResultView,
ResultViewV1,
};