perf(mysql): batch adjacent DML into multi-statement COM_QUERY for large scripts
This commit is contained in:
9 files changed
+683
-82
No files matched your search
+7
-1
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { frontendQueryTimeoutSecsForSql, queryTimeoutSecsForConnection } from "@/lib/sql/queryTimeout";
|
||||
import { frontendQueryTimeoutDelayMs, frontendQueryTimeoutSecsForSql, queryTimeoutSecsForConnection } from "@/lib/sql/queryTimeout";
|
||||
|
||||
describe("queryTimeout", () => {
|
||||
it("lets PostgreSQL row queries use the backend inactivity timeout", () => {
|
||||
@@ -19,6 +19,12 @@ describe("queryTimeout", () => {
|
||||
expect(queryTimeoutSecsForConnection({ query_timeout_secs: undefined })).toBe(30);
|
||||
});
|
||||
|
||||
it("does not schedule frontend timeouts beyond the browser timer limit", () => {
|
||||
expect(frontendQueryTimeoutDelayMs(60)).toBe(60_000);
|
||||
expect(frontendQueryTimeoutDelayMs(11_401_200)).toBeUndefined();
|
||||
expect(frontendQueryTimeoutDelayMs(0)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("uses the global timeout only for inheriting connections", () => {
|
||||
expect(queryTimeoutSecsForConnection({ query_timeout_secs: 30, query_timeout_inherit: true }, 12)).toBe(12);
|
||||
expect(queryTimeoutSecsForConnection({ query_timeout_secs: 30, query_timeout_inherit: false }, 12)).toBe(30);
|
||||
|
||||
@@ -234,6 +234,35 @@ describe("execution summary", () => {
|
||||
{ status: "error", isError: true },
|
||||
]);
|
||||
});
|
||||
|
||||
it("maps out-of-order results to their explicit statement indexes", () => {
|
||||
const items = executionSummaryItems({
|
||||
results: [
|
||||
{ columns: ["value"], rows: [["third"]], affected_rows: 0, execution_time_ms: 3, statement_index: 2 },
|
||||
{ columns: ["value"], rows: [["first"]], affected_rows: 0, execution_time_ms: 1, statement_index: 0 },
|
||||
],
|
||||
batchSqlExecution: {
|
||||
executionId: "run-out-of-order",
|
||||
submittedSql: "SELECT 'first'; SELECT 'second'; SELECT 'third'",
|
||||
editorFingerprint: "fingerprint",
|
||||
sourceOffset: 0,
|
||||
completed: 2,
|
||||
total: 3,
|
||||
startedAt: 1,
|
||||
items: [
|
||||
{ statementIndex: 0, sql: "SELECT 'first'", from: 0, to: 14, status: "success" },
|
||||
{ statementIndex: 1, sql: "SELECT 'second'", from: 16, to: 31, status: "skipped" },
|
||||
{ statementIndex: 2, sql: "SELECT 'third'", from: 33, to: 47, status: "success" },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(items.map((item) => [item.statementIndex, item.result?.rows[0]?.[0]])).toEqual([
|
||||
[0, "first"],
|
||||
[1, undefined],
|
||||
[2, "third"],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("statement execution markers", () => {
|
||||
|
||||
Reference in new issue
Block a user