1 parent
d0e027bb17
commit
e18d1ddedf
4 files changed
+140
-4
No files matched your search
@@ -308,6 +308,7 @@ export interface QueryPaginationExecutionPlan {
|
||||
pageLimit?: number;
|
||||
pageOffset?: number;
|
||||
countSql?: string;
|
||||
exactQueryRowBound?: number;
|
||||
useAgentResultSession: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -3915,6 +3915,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
let pageLimit: number | undefined;
|
||||
let pageOffset: number | undefined;
|
||||
let countSql: string | undefined;
|
||||
let exactQueryRowBound: number | undefined;
|
||||
let useAgentResultSession = false;
|
||||
let executionDispatched = false;
|
||||
let producedResult = false;
|
||||
@@ -4493,6 +4494,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
pageLimit = plan.pageLimit;
|
||||
pageOffset = plan.pageOffset;
|
||||
countSql = plan.countSql;
|
||||
exactQueryRowBound = plan.exactQueryRowBound;
|
||||
useAgentResultSession = plan.useAgentResultSession;
|
||||
const hasBoundedPagination = typeof pageLimit === "number" && typeof pageOffset === "number";
|
||||
if (options?.appendResult && !hasBoundedPagination && !useAgentResultSession) {
|
||||
@@ -4689,7 +4691,16 @@ export const useQueryStore = defineStore("query", () => {
|
||||
current.result.truncated = true;
|
||||
current.resultTotalRowCount = queryResultMaxRows;
|
||||
}
|
||||
const totalKnownFromIncompletePage = !!current.result && typeof exactTotalFromIncompletePage(current.result, pageLimit, pageOffset, useAgentResultSession) === "number";
|
||||
const paginationPageResult = shouldAppendResult ? results[0] : current.result;
|
||||
const exactIncompletePageTotal = paginationPageResult ? exactTotalFromIncompletePage(paginationPageResult, pageLimit, pageOffset, useAgentResultSession) : undefined;
|
||||
const totalKnownFromIncompletePage = typeof exactIncompletePageTotal === "number";
|
||||
let totalRowCountResolved = false;
|
||||
if (current.mode === "query" && current.result && !isQueryExecutionErrorResult(current.result) && typeof exactQueryRowBound === "number") {
|
||||
const boundedTotal = capQueryResultTotal(exactQueryRowBound, queryResultMaxRows);
|
||||
current.resultTotalRowCount = Math.min(boundedTotal, exactIncompletePageTotal ?? boundedTotal);
|
||||
current.resultTotalRowCountLoading = false;
|
||||
totalRowCountResolved = true;
|
||||
}
|
||||
const dataCountTarget =
|
||||
current.mode === "data"
|
||||
? (() => {
|
||||
@@ -4707,14 +4718,20 @@ export const useQueryStore = defineStore("query", () => {
|
||||
})()
|
||||
: undefined;
|
||||
const canAutoCalculateTotalRows =
|
||||
!options?.appendResult && !!current.result && resultRowCount > 0 && !resultLimitReached && !totalKnownFromIncompletePage && settingsStore.editorSettings.autoCalculateTotalRows && ((current.mode === "query" && !!countSql) || (current.mode === "data" && !!dataCountTarget));
|
||||
!options?.appendResult &&
|
||||
!!current.result &&
|
||||
resultRowCount > 0 &&
|
||||
!resultLimitReached &&
|
||||
!totalKnownFromIncompletePage &&
|
||||
!totalRowCountResolved &&
|
||||
settingsStore.editorSettings.autoCalculateTotalRows &&
|
||||
((current.mode === "query" && !!countSql) || (current.mode === "data" && !!dataCountTarget));
|
||||
current.resultTotalRowCountLoading = canAutoCalculateTotalRows;
|
||||
// Server-side pagination without a countSql: the backend (currently
|
||||
// the Elasticsearch driver) already reports the true match total via
|
||||
// affected_rows. Use it directly so the result-grid can compute the
|
||||
// page count without issuing a separate COUNT query.
|
||||
let totalRowCountResolved = false;
|
||||
if (current.result && current.result.total_is_exact !== false && current.mode === "query" && typeof pageLimit === "number" && !countSql && typeof current.result.affected_rows === "number" && current.result.affected_rows > current.result.rows.length) {
|
||||
if (!totalRowCountResolved && current.result && current.result.total_is_exact !== false && current.mode === "query" && typeof pageLimit === "number" && !countSql && typeof current.result.affected_rows === "number" && current.result.affected_rows > current.result.rows.length) {
|
||||
current.resultTotalRowCount = current.result.affected_rows;
|
||||
current.resultTotalRowCountLoading = false;
|
||||
totalRowCountResolved = true;
|
||||
|
||||
Reference in new issue
Block a user