fix(data): decouple table open limit from result page size

This commit is contained in:
t8y2 committed 2026-07-01 15:14:32 +08:00
1 parent a529344ac7
commit 74165cc045
5 files changed
+70 -10

No files matched your search

@@ -74,6 +74,7 @@ import { connectionFilePath, defaultSqliteBackupFileName, isMemorySqlitePath, sq
import { revealPathInFileManager } from "@/lib/tauri";
import { clearActiveTableReferencePayload, createTableReferencePayload, createTableReferenceDropEvent, setActiveTableReferencePayload, type QueryEditorTableReferencePayload } from "@/lib/queryEditorTableDrop";
import { editableRowIdentifierColumns, usesSyntheticRowIdKey } from "@/lib/tableEditing";
import { tableOpenPageLimit } from "@/lib/tableOpenPageLimit";
import { supportsDatabaseCreation, supportsDatabaseSearch, supportsFieldLineage, supportsObjectBrowserTreeNode, supportsSchemaDiagram, supportsSqlFileExecution, supportsTableImport, supportsTableTruncate, supportsTableStructureEditing, usesTreeSchemaMode } from "@/lib/databaseCapabilities";
import { copyNameForTreeNode, objectSourceKindForTreeNode, sidebarSelectionCopyAction, treeNodeRowAction, treeNodeRowDoubleClickAction } from "@/lib/treeNodeClick";
import { formatSqlInsert } from "@/lib/exportFormats";
@@ -1047,7 +1048,7 @@ async function openData() {
const querySchema = connectionObjectTreeQuerySchema(config, node.database, tableSchema);
const effectiveDbType = effectiveDatabaseTypeForConnection(config);
const limit = settingsStore.editorSettings.pageSize;
const limit = tableOpenPageLimit();
const refreshTableMetaInBackground = async () => {
const metadataStartedAt = performance.now();
console.info("[DBX][openData:metadata:start]", {
@@ -1134,7 +1135,11 @@ async function openData() {
logPhase("sql-updated", { tabId });
console.info("[DBX][openData:execute:start]", { traceId, tabId, elapsed: elapsed() });
await queryStore.executeTabSql(tabId, sql, { sourceTraceId: traceId, skipEnsureConnected: true });
await queryStore.executeTabSql(tabId, sql, {
sourceTraceId: traceId,
skipEnsureConnected: true,
pagination: { limit, offset: 0 },
});
console.info("[DBX][openData:execute:done]", { traceId, tabId, elapsed: elapsed() });
logPhase("execute-tab-sql", { tabId });
if (shouldRefreshTableMeta && isCurrentDataTab()) {
@@ -3,6 +3,7 @@ import { effectiveDatabaseTypeForConnection, metadataSchemaForConnection } from
import { isNoSnapshotErrorResult } from "@/lib/queryResultError";
import { buildTableSelectSql } from "@/lib/tableSelectSql";
import { editableRowIdentifierColumns, usesSyntheticRowIdKey } from "@/lib/tableEditing";
import { tableOpenPageLimit } from "@/lib/tableOpenPageLimit";
import { useConnectionStore } from "@/stores/connectionStore";
import { useQueryStore } from "@/stores/queryStore";
import { useSettingsStore } from "@/stores/settingsStore";
@@ -21,7 +22,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
const connectionStore = useConnectionStore();
const queryStore = useQueryStore();
const settingsStore = useSettingsStore();
const pageLimit = settingsStore.editorSettings.pageSize;
const pageLimit = tableOpenPageLimit();
connectionStore.activeConnectionId = target.connectionId;
const config = connectionStore.getConfig(target.connectionId);
@@ -74,7 +75,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
columns,
primaryKeys,
});
await queryStore.executeTabSql(tabId, sql);
await queryStore.executeTabSql(tabId, sql, { pagination: { limit: pageLimit, offset: 0 } });
return;
}
const sql = await buildTableSelectSql({
@@ -92,7 +93,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
columns: [],
primaryKeys: [],
});
await queryStore.executeTabSql(tabId, sql);
await queryStore.executeTabSql(tabId, sql, { pagination: { limit: pageLimit, offset: 0 } });
// executeTabSql surfaces query failures as an "Error" result instead of throwing.
// A snapshot-less lake table fails the data preview above but its metadata still
// reads fine — retry with LIMIT 0 so the user sees the table structure (columns +
@@ -109,7 +110,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
limit: 0,
});
queryStore.updateSql(tabId, emptySql);
await queryStore.executeTabSql(tabId, emptySql);
await queryStore.executeTabSql(tabId, emptySql, { pagination: { limit: pageLimit, offset: 0 } });
}
try {
const columns = await api.getColumns(target.connectionId, target.database, querySchema, target.tableName);
@@ -135,7 +136,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
limit: pageLimit,
});
queryStore.updateSql(tabId, newSql);
await queryStore.executeTabSql(tabId, newSql);
await queryStore.executeTabSql(tabId, newSql, { pagination: { limit: pageLimit, offset: 0 } });
}
} catch (reason) {
console.error("[DBX] ERROR fetching table metadata:", reason);
@@ -0,0 +1,8 @@
import { DEFAULT_RESULT_PAGE_SIZE, normalizeResultPageSize } from "@/lib/paginationPageSize";
export const DEFAULT_TABLE_OPEN_PAGE_LIMIT = DEFAULT_RESULT_PAGE_SIZE;
export function tableOpenPageLimit(): number {
// Opening a table should not inherit the mutable SQL result-grid rows-per-page setting.
return normalizeResultPageSize(DEFAULT_TABLE_OPEN_PAGE_LIMIT);
}
+3 -3
View File
@@ -34,6 +34,7 @@ import { usesAgentCursorForQuery } from "@/lib/databaseDriverManifest";
import { canUseKeylessRowPredicate, editableRowIdentifierColumns } from "@/lib/tableEditing";
import { TABLE_DATA_EXPORT_PAGE_SIZE } from "@/lib/tableDataExport";
import { tableMetaForDataTab } from "@/lib/tableDataTabMeta";
import { tableOpenPageLimit } from "@/lib/tableOpenPageLimit";
import { quoteTableIdentifier } from "@/lib/tableSelectSql";
import { connectionUsesDatabaseObjectTreeMode, connectionUsesSchemaExecutionContext, effectiveDatabaseTypeForConnection, metadataSchemaForConnection } from "@/lib/jdbcDialect";
import { queryTimeoutSecsForConnection } from "@/lib/queryTimeout";
@@ -1607,7 +1608,7 @@ export const useQueryStore = defineStore("query", () => {
countSql = plan.countSql;
useAgentResultSession = plan.useAgentResultSession;
} else if (tab.mode === "data") {
pageLimit = options?.pagination?.limit ?? settingsStore.editorSettings.pageSize;
pageLimit = options?.pagination?.limit ?? tableOpenPageLimit();
pageOffset = options?.pagination?.offset ?? 0;
}
const mongoFind = conn?.db_type === "mongodb" ? parseMongoFindCommand(sql) : null;
@@ -2276,14 +2277,13 @@ export const useQueryStore = defineStore("query", () => {
tab.resultEvicted = false;
const sql = tab.lastExecutedSql ?? tab.sql;
if (!sql?.trim()) return;
const settingsStore = useSettingsStore();
await executeTabSql(tab.id, sql, {
resultBaseSql: tab.resultBaseSql ?? sql,
resultSortedSql: tab.resultSortedSql,
pagination:
tab.mode === "data"
? {
limit: tab.resultPageLimit ?? settingsStore.editorSettings.pageSize,
limit: tab.resultPageLimit ?? tableOpenPageLimit(),
offset: tab.resultPageOffset ?? 0,
}
: undefined,