feat(query): cross-database timing details, drop OceanBase audit query
This commit is contained in:
1 parent
4b9a1c4d5c
commit
d0497e0ca6
69 files changed
+973
-180
No files matched your search
+13
-11
@@ -57,18 +57,18 @@ cd agents
|
|||||||
|
|
||||||
## 项目结构
|
## 项目结构
|
||||||
|
|
||||||
| 路径 | 说明 |
|
| 路径 | 说明 |
|
||||||
| --- | --- |
|
| ----------------------- | --------------------------------- |
|
||||||
| `apps/desktop/src/` | Vue 前端 |
|
| `apps/desktop/src/` | Vue 前端 |
|
||||||
| `src-tauri/` | Tauri 桌面端壳层与命令层 |
|
| `src-tauri/` | Tauri 桌面端壳层与命令层 |
|
||||||
| `crates/dbx-core/` | 共享 Rust 数据库逻辑 |
|
| `crates/dbx-core/` | 共享 Rust 数据库逻辑 |
|
||||||
| `crates/dbx-web/` | Docker / Web HTTP 后端 |
|
| `crates/dbx-web/` | Docker / Web HTTP 后端 |
|
||||||
| `packages/cli/` | `@dbx-app/cli` |
|
| `packages/cli/` | `@dbx-app/cli` |
|
||||||
| `packages/mcp-server/` | `@dbx-app/mcp-server` |
|
| `packages/mcp-server/` | `@dbx-app/mcp-server` |
|
||||||
| `packages/mongo-shell/` | 桌面端内部 MongoDB 编辑器解析工具 |
|
| `packages/mongo-shell/` | 桌面端内部 MongoDB 编辑器解析工具 |
|
||||||
| `docs/` | 官方文档站 |
|
| `docs/` | 官方文档站 |
|
||||||
| `examples/` | 配置与自动化示例 |
|
| `examples/` | 配置与自动化示例 |
|
||||||
| `agents/` | JDBC Agent 驱动工程 |
|
| `agents/` | JDBC Agent 驱动工程 |
|
||||||
|
|
||||||
## 开发约定
|
## 开发约定
|
||||||
|
|
||||||
@@ -84,6 +84,8 @@ cd agents
|
|||||||
|
|
||||||
一个 PR 只做一类事。文档 PR 不要夹带无关代码;修 Bug 时也不要顺手大重构,除非重构是修复所必需的。
|
一个 PR 只做一类事。文档 PR 不要夹带无关代码;修 Bug 时也不要顺手大重构,除非重构是修复所必需的。
|
||||||
|
|
||||||
|
提交前和推送后请按 [PR 提交与 CI 核查](docs/testing/pr-preflight.md) 检查多语言完整性、相关工作流及远端状态。
|
||||||
|
|
||||||
### 提交说明
|
### 提交说明
|
||||||
|
|
||||||
提交信息用自然语言写清楚即可:
|
提交信息用自然语言写清楚即可:
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ public abstract class AbstractJdbcAgent extends BaseDatabaseAgent {
|
|||||||
private boolean sessionAffinity;
|
private boolean sessionAffinity;
|
||||||
private boolean pooledConnectionPoisoned;
|
private boolean pooledConnectionPoisoned;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsQueryTiming() { return true; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final Connection getConnection() {
|
public final Connection getConnection() {
|
||||||
return connection;
|
return connection;
|
||||||
@@ -185,8 +188,10 @@ public abstract class AbstractJdbcAgent extends BaseDatabaseAgent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryResult executeQuery(String sql, String schema, ExecuteQueryOptions options) {
|
public QueryResult executeQuery(String sql, String schema, ExecuteQueryOptions options) {
|
||||||
|
long prepareStarted = System.nanoTime();
|
||||||
Connection conn = requireConnected();
|
Connection conn = requireConnected();
|
||||||
uncheckedVoid(() -> beforeQueryExecution(conn, options.getTimeoutSecs()));
|
uncheckedVoid(() -> beforeQueryExecution(conn, options.getTimeoutSecs()));
|
||||||
|
QueryTiming.record("session_prepare", prepareStarted);
|
||||||
return JdbcExecutor.current().execute(
|
return JdbcExecutor.current().execute(
|
||||||
conn,
|
conn,
|
||||||
sql,
|
sql,
|
||||||
@@ -204,8 +209,10 @@ public abstract class AbstractJdbcAgent extends BaseDatabaseAgent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryPageResult executeQueryPage(String sql, String schema, QueryPageOptions options) {
|
public QueryPageResult executeQueryPage(String sql, String schema, QueryPageOptions options) {
|
||||||
|
long prepareStarted = System.nanoTime();
|
||||||
Connection conn = requireConnected();
|
Connection conn = requireConnected();
|
||||||
uncheckedVoid(() -> beforeQueryExecution(conn, options.getTimeoutSecs()));
|
uncheckedVoid(() -> beforeQueryExecution(conn, options.getTimeoutSecs()));
|
||||||
|
QueryTiming.record("session_prepare", prepareStarted);
|
||||||
return JdbcExecutor.current().executePage(
|
return JdbcExecutor.current().executePage(
|
||||||
conn,
|
conn,
|
||||||
sql,
|
sql,
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public interface DatabaseAgent {
|
public interface DatabaseAgent {
|
||||||
|
/** Opt in to request-boundary timing, including pooled connection lifecycle. */
|
||||||
|
default boolean supportsQueryTiming() { return false; }
|
||||||
|
|
||||||
void connect(ConnectParams params);
|
void connect(ConnectParams params);
|
||||||
|
|
||||||
boolean testConnection(ConnectParams params);
|
boolean testConnection(ConnectParams params);
|
||||||
|
|||||||
@@ -140,7 +140,10 @@ public final class JdbcExecutor {
|
|||||||
String trimmedSql = trimSql(sql);
|
String trimmedSql = trimSql(sql);
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
long phaseStarted = System.nanoTime();
|
||||||
applySchema(conn, schema, setSchemaSql, resetSchemaSql);
|
applySchema(conn, schema, setSchemaSql, resetSchemaSql);
|
||||||
|
QueryTiming.record("schema", phaseStarted);
|
||||||
|
phaseStarted = System.nanoTime();
|
||||||
|
|
||||||
try (Statement stmt = conn.createStatement()) {
|
try (Statement stmt = conn.createStatement()) {
|
||||||
activeStatements.add(stmt);
|
activeStatements.add(stmt);
|
||||||
@@ -153,7 +156,10 @@ public final class JdbcExecutor {
|
|||||||
}
|
}
|
||||||
// SQL dumps often contain BEGIN/COMMIT/ROLLBACK as executable statements.
|
// SQL dumps often contain BEGIN/COMMIT/ROLLBACK as executable statements.
|
||||||
// Do not translate them to Connection.commit(), which requires autoCommit=false.
|
// Do not translate them to Connection.commit(), which requires autoCommit=false.
|
||||||
|
QueryTiming.record("statement_prepare", phaseStarted);
|
||||||
|
phaseStarted = System.nanoTime();
|
||||||
boolean hasResultSet = stmt.execute(trimmedSql);
|
boolean hasResultSet = stmt.execute(trimmedSql);
|
||||||
|
QueryTiming.record("jdbc_execute", phaseStarted);
|
||||||
long elapsed = System.currentTimeMillis() - start;
|
long elapsed = System.currentTimeMillis() - start;
|
||||||
long affectedRows;
|
long affectedRows;
|
||||||
if (advancePastUpdateCounts) {
|
if (advancePastUpdateCounts) {
|
||||||
@@ -210,6 +216,7 @@ public final class JdbcExecutor {
|
|||||||
ResultValueReader valueReader
|
ResultValueReader valueReader
|
||||||
) {
|
) {
|
||||||
return unchecked(() -> {
|
return unchecked(() -> {
|
||||||
|
long phaseStarted = System.nanoTime();
|
||||||
ResultSetMetaData meta = rs.getMetaData();
|
ResultSetMetaData meta = rs.getMetaData();
|
||||||
int colCount = meta.getColumnCount();
|
int colCount = meta.getColumnCount();
|
||||||
List<String> columns = new ArrayList<>(colCount);
|
List<String> columns = new ArrayList<>(colCount);
|
||||||
@@ -226,6 +233,8 @@ public final class JdbcExecutor {
|
|||||||
typeNameByIndex[i - 1] = typeName;
|
typeNameByIndex[i - 1] = typeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QueryTiming.record("metadata", phaseStarted);
|
||||||
|
phaseStarted = System.nanoTime();
|
||||||
List<List<Object>> rows = new ArrayList<>(initialRowCapacity(maxRows));
|
List<List<Object>> rows = new ArrayList<>(initialRowCapacity(maxRows));
|
||||||
boolean truncated = false;
|
boolean truncated = false;
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@@ -236,6 +245,7 @@ public final class JdbcExecutor {
|
|||||||
rows.add(rowValues(rs, valueReader, sqlTypeByIndex, typeNameByIndex));
|
rows.add(rowValues(rs, valueReader, sqlTypeByIndex, typeNameByIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QueryTiming.record("fetch", phaseStarted);
|
||||||
return new QueryResult(columns, columnTypes, rows, 0L, executionTimeMs, truncated);
|
return new QueryResult(columns, columnTypes, rows, 0L, executionTimeMs, truncated);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -383,7 +393,10 @@ public final class JdbcExecutor {
|
|||||||
String trimmedSql = trimSql(sql);
|
String trimmedSql = trimSql(sql);
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
long phaseStarted = System.nanoTime();
|
||||||
applySchema(conn, schema, setSchemaSql, resetSchemaSql);
|
applySchema(conn, schema, setSchemaSql, resetSchemaSql);
|
||||||
|
QueryTiming.record("schema", phaseStarted);
|
||||||
|
phaseStarted = System.nanoTime();
|
||||||
|
|
||||||
Statement stmt = conn.createStatement();
|
Statement stmt = conn.createStatement();
|
||||||
QuerySession createdSession = null;
|
QuerySession createdSession = null;
|
||||||
@@ -395,7 +408,10 @@ public final class JdbcExecutor {
|
|||||||
}
|
}
|
||||||
// Keep script transaction-control statements in the SQL stream.
|
// Keep script transaction-control statements in the SQL stream.
|
||||||
// JDBC transaction APIs are reserved for executeTransaction.
|
// JDBC transaction APIs are reserved for executeTransaction.
|
||||||
|
QueryTiming.record("statement_prepare", phaseStarted);
|
||||||
|
phaseStarted = System.nanoTime();
|
||||||
boolean hasResultSet = stmt.execute(trimmedSql);
|
boolean hasResultSet = stmt.execute(trimmedSql);
|
||||||
|
QueryTiming.record("jdbc_execute", phaseStarted);
|
||||||
long elapsed = System.currentTimeMillis() - start;
|
long elapsed = System.currentTimeMillis() - start;
|
||||||
long affectedRows;
|
long affectedRows;
|
||||||
if (advancePastUpdateCounts) {
|
if (advancePastUpdateCounts) {
|
||||||
@@ -442,6 +458,7 @@ public final class JdbcExecutor {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
phaseStarted = System.nanoTime();
|
||||||
ResultSet rs = stmt.getResultSet();
|
ResultSet rs = stmt.getResultSet();
|
||||||
ResultSetMetaData meta = rs.getMetaData();
|
ResultSetMetaData meta = rs.getMetaData();
|
||||||
String sessionId = UUID.randomUUID().toString();
|
String sessionId = UUID.randomUUID().toString();
|
||||||
@@ -471,7 +488,10 @@ public final class JdbcExecutor {
|
|||||||
);
|
);
|
||||||
createdSession = session;
|
createdSession = session;
|
||||||
targetSessions.put(sessionId, session);
|
targetSessions.put(sessionId, session);
|
||||||
|
QueryTiming.record("metadata", phaseStarted);
|
||||||
|
phaseStarted = System.nanoTime();
|
||||||
QueryPageResult page = readSessionPage(targetSessions, session, options.getPageSize(), elapsed);
|
QueryPageResult page = readSessionPage(targetSessions, session, options.getPageSize(), elapsed);
|
||||||
|
QueryTiming.record("fetch", phaseStarted);
|
||||||
// Same reason as `execute`: pulling the first page's rows is
|
// Same reason as `execute`: pulling the first page's rows is
|
||||||
// part of the duration the caller waited for.
|
// part of the duration the caller waited for.
|
||||||
page.setExecution_time_ms(System.currentTimeMillis() - start);
|
page.setExecution_time_ms(System.currentTimeMillis() - start);
|
||||||
@@ -724,7 +744,9 @@ public final class JdbcExecutor {
|
|||||||
synchronized (session) {
|
synchronized (session) {
|
||||||
long fetchStart = System.currentTimeMillis();
|
long fetchStart = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
|
long phaseStarted = System.nanoTime();
|
||||||
QueryPageResult page = readSessionPage(targetSessions, session, pageSize, 0L);
|
QueryPageResult page = readSessionPage(targetSessions, session, pageSize, 0L);
|
||||||
|
QueryTiming.record("fetch", phaseStarted);
|
||||||
// A later page reads its rows after `stmt.execute()` has long
|
// A later page reads its rows after `stmt.execute()` has long
|
||||||
// returned, so it has to measure the fetch itself instead of
|
// returned, so it has to measure the fetch itself instead of
|
||||||
// reporting 0ms while the caller waits.
|
// reporting 0ms while the caller waits.
|
||||||
|
|||||||
@@ -89,6 +89,26 @@ public final class JsonRpcServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object dispatchForRuntime(String method, JsonObject params) throws Exception {
|
Object dispatchForRuntime(String method, JsonObject params) throws Exception {
|
||||||
|
boolean timedQuery = agent.supportsQueryTiming()
|
||||||
|
&& (AgentProtocol.METHOD_EXECUTE_QUERY.equals(method)
|
||||||
|
|| AgentProtocol.METHOD_EXECUTE_QUERY_PAGE.equals(method)
|
||||||
|
|| AgentProtocol.METHOD_FETCH_QUERY_PAGE.equals(method));
|
||||||
|
try (QueryTiming timing = timedQuery ? QueryTiming.begin() : null) {
|
||||||
|
Object result = dispatchWithConnection(method, params);
|
||||||
|
// Capture after connection return/reset, which runs in the finally
|
||||||
|
// block below. Driver-only snapshots omit that lifecycle work.
|
||||||
|
if (timing != null) {
|
||||||
|
if (result instanceof QueryResult) {
|
||||||
|
((QueryResult) result).setQuery_timings_ms(timing.finish());
|
||||||
|
} else if (result instanceof QueryPageResult) {
|
||||||
|
((QueryPageResult) result).setQuery_timings_ms(timing.finish());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object dispatchWithConnection(String method, JsonObject params) throws Exception {
|
||||||
return AgentExecutionContext.withJdbcExecutor(jdbcExecutor, () -> {
|
return AgentExecutionContext.withJdbcExecutor(jdbcExecutor, () -> {
|
||||||
AbstractJdbcAgent jdbcAgent = pooledJdbcAgent();
|
AbstractJdbcAgent jdbcAgent = pooledJdbcAgent();
|
||||||
if (AgentProtocol.METHOD_VALIDATE_CONNECTION.equals(method)
|
if (AgentProtocol.METHOD_VALIDATE_CONNECTION.equals(method)
|
||||||
@@ -98,7 +118,12 @@ public final class JsonRpcServer {
|
|||||||
}
|
}
|
||||||
boolean manageConnection = jdbcAgent != null && requiresConnectedConnection(method);
|
boolean manageConnection = jdbcAgent != null && requiresConnectedConnection(method);
|
||||||
if (manageConnection) {
|
if (manageConnection) {
|
||||||
jdbcAgent.beginPooledRequest();
|
long acquireStarted = System.nanoTime();
|
||||||
|
try {
|
||||||
|
jdbcAgent.beginPooledRequest();
|
||||||
|
} finally {
|
||||||
|
QueryTiming.record("pool_acquire", acquireStarted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
boolean succeeded = false;
|
boolean succeeded = false;
|
||||||
try {
|
try {
|
||||||
@@ -107,14 +132,19 @@ public final class JsonRpcServer {
|
|||||||
return result;
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
if (manageConnection) {
|
if (manageConnection) {
|
||||||
jdbcAgent.finishPooledRequest(
|
long releaseStarted = System.nanoTime();
|
||||||
jdbcExecutor,
|
try {
|
||||||
succeeded,
|
jdbcAgent.finishPooledRequest(
|
||||||
requiresSessionAffinity(method, params),
|
jdbcExecutor,
|
||||||
evictAfterRequest(method),
|
succeeded,
|
||||||
endsSessionAffinity(method),
|
requiresSessionAffinity(method, params),
|
||||||
preservesSchemaContext()
|
evictAfterRequest(method),
|
||||||
);
|
endsSessionAffinity(method),
|
||||||
|
preservesSchemaContext()
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
QueryTiming.record("pool_release", releaseStarted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public final class QueryPageResult {
|
|||||||
private long affected_rows;
|
private long affected_rows;
|
||||||
private long execution_time_ms;
|
private long execution_time_ms;
|
||||||
private Long server_execute_time_us;
|
private Long server_execute_time_us;
|
||||||
|
private java.util.Map<String, Double> query_timings_ms;
|
||||||
/** Number of rows read by this JDBC cursor across all pages; never sent over JSON RPC. */
|
/** Number of rows read by this JDBC cursor across all pages; never sent over JSON RPC. */
|
||||||
private transient long cursor_rows_read;
|
private transient long cursor_rows_read;
|
||||||
private boolean truncated;
|
private boolean truncated;
|
||||||
@@ -100,6 +101,10 @@ public final class QueryPageResult {
|
|||||||
return execution_time_ms;
|
return execution_time_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public java.util.Map<String, Double> getQuery_timings_ms() { return query_timings_ms; }
|
||||||
|
|
||||||
|
public void setQuery_timings_ms(java.util.Map<String, Double> value) { query_timings_ms = value; }
|
||||||
|
|
||||||
public Long getServer_execute_time_us() {
|
public Long getServer_execute_time_us() {
|
||||||
return server_execute_time_us;
|
return server_execute_time_us;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public final class QueryResult {
|
|||||||
private long affected_rows;
|
private long affected_rows;
|
||||||
private long execution_time_ms;
|
private long execution_time_ms;
|
||||||
private Long server_execute_time_us;
|
private Long server_execute_time_us;
|
||||||
|
private java.util.Map<String, Double> query_timings_ms;
|
||||||
private boolean truncated;
|
private boolean truncated;
|
||||||
|
|
||||||
public QueryResult() {
|
public QueryResult() {
|
||||||
@@ -85,6 +86,10 @@ public final class QueryResult {
|
|||||||
return execution_time_ms;
|
return execution_time_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public java.util.Map<String, Double> getQuery_timings_ms() { return query_timings_ms; }
|
||||||
|
|
||||||
|
public void setQuery_timings_ms(java.util.Map<String, Double> value) { query_timings_ms = value; }
|
||||||
|
|
||||||
public Long getServer_execute_time_us() {
|
public Long getServer_execute_time_us() {
|
||||||
return server_execute_time_us;
|
return server_execute_time_us;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.dbx.agent;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/** Request-scoped, monotonic timings. Disabled unless a driver explicitly opens a scope. */
|
||||||
|
public final class QueryTiming implements AutoCloseable {
|
||||||
|
private static final ThreadLocal<QueryTiming> CURRENT = new ThreadLocal<>();
|
||||||
|
private final Map<String, Double> stages = new LinkedHashMap<>();
|
||||||
|
private final long started = System.nanoTime();
|
||||||
|
private final QueryTiming previous;
|
||||||
|
|
||||||
|
private QueryTiming() {
|
||||||
|
previous = CURRENT.get();
|
||||||
|
CURRENT.set(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static QueryTiming begin() { return new QueryTiming(); }
|
||||||
|
|
||||||
|
public static void record(String stage, long started) {
|
||||||
|
QueryTiming timing = CURRENT.get();
|
||||||
|
if (timing != null) timing.stages.merge(stage, (System.nanoTime() - started) / 1_000_000.0, Double::sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Double> finish() {
|
||||||
|
Map<String, Double> result = new LinkedHashMap<>(stages);
|
||||||
|
result.put("agent_total", (System.nanoTime() - started) / 1_000_000.0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void close() {
|
||||||
|
// A driver scope also works for direct calls. When invoked through the
|
||||||
|
// RPC boundary, carry its non-overlapping stages into the outer request.
|
||||||
|
// agent_total is a snapshot only; never merge nested totals.
|
||||||
|
if (previous != null) stages.forEach((key, value) -> previous.stages.merge(key, value, Double::sum));
|
||||||
|
if (previous == null) CURRENT.remove(); else CURRENT.set(previous);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1112,6 +1112,12 @@ class JdbcConnectionPoolingTest {
|
|||||||
pageParams
|
pageParams
|
||||||
));
|
));
|
||||||
assertTrue(firstPage.get("has_more").getAsBoolean());
|
assertTrue(firstPage.get("has_more").getAsBoolean());
|
||||||
|
JsonObject timings = firstPage.getAsJsonObject("query_timings_ms");
|
||||||
|
assertNotNull(timings, "all JDBC agents expose timings through JSON RPC");
|
||||||
|
assertTrue(timings.get("pool_acquire").getAsDouble() >= 0);
|
||||||
|
assertTrue(timings.get("jdbc_execute").getAsDouble() >= 0);
|
||||||
|
assertTrue(timings.get("fetch").getAsDouble() >= 0);
|
||||||
|
assertTrue(timings.get("pool_release").getAsDouble() >= 0);
|
||||||
String querySessionId = firstPage.get("session_id").getAsString();
|
String querySessionId = firstPage.get("session_id").getAsString();
|
||||||
|
|
||||||
Future<JsonObject> waiting = worker.submit(
|
Future<JsonObject> waiting = worker.submit(
|
||||||
|
|||||||
+15
-82
@@ -27,6 +27,7 @@ import com.dbx.agent.PartitionInfo;
|
|||||||
import com.dbx.agent.QueryPageOptions;
|
import com.dbx.agent.QueryPageOptions;
|
||||||
import com.dbx.agent.QueryPageResult;
|
import com.dbx.agent.QueryPageResult;
|
||||||
import com.dbx.agent.QueryResult;
|
import com.dbx.agent.QueryResult;
|
||||||
|
import com.dbx.agent.QueryTiming;
|
||||||
import com.dbx.agent.TableInfo;
|
import com.dbx.agent.TableInfo;
|
||||||
import com.dbx.agent.TriggerInfo;
|
import com.dbx.agent.TriggerInfo;
|
||||||
|
|
||||||
@@ -34,7 +35,6 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -66,9 +66,6 @@ public final class OceanBaseOracleAgent extends ConfiguredJdbcAgent {
|
|||||||
"GGSYS", "FLOWS_FILES", "APEX_PUBLIC_USER", "GSMROOTUSER", "SYSRAC"
|
"GGSYS", "FLOWS_FILES", "APEX_PUBLIC_USER", "GSMROOTUSER", "SYSRAC"
|
||||||
);
|
);
|
||||||
private boolean queryTimeoutChanged;
|
private boolean queryTimeoutChanged;
|
||||||
private String auditEligibleCursorId;
|
|
||||||
private static final String SQL_AUDIT_BY_TRACE = "SELECT EXECUTE_TIME, RETURN_ROWS FROM SYS.GV$OB_SQL_AUDIT "
|
|
||||||
+ "WHERE TRACE_ID = ? AND IS_INNER_SQL = 0 AND IS_EXECUTOR_RPC = 0 AND ROWNUM <= 2";
|
|
||||||
|
|
||||||
public static final JdbcAgentProfile OCEANBASE_ORACLE_PROFILE = new JdbcAgentProfile(
|
public static final JdbcAgentProfile OCEANBASE_ORACLE_PROFILE = new JdbcAgentProfile(
|
||||||
"com.oceanbase.jdbc.Driver",
|
"com.oceanbase.jdbc.Driver",
|
||||||
@@ -88,97 +85,33 @@ public final class OceanBaseOracleAgent extends ConfiguredJdbcAgent {
|
|||||||
super(OCEANBASE_ORACLE_PROFILE);
|
super(OCEANBASE_ORACLE_PROFILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsQueryTiming() { return true; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryResult executeQuery(String sql, String schema, ExecuteQueryOptions options) {
|
public QueryResult executeQuery(String sql, String schema, ExecuteQueryOptions options) {
|
||||||
auditEligibleCursorId = null;
|
try (QueryTiming timing = QueryTiming.begin()) {
|
||||||
QueryResult result = super.executeQuery(sql, schema, options);
|
QueryResult result = super.executeQuery(sql, schema, options);
|
||||||
if (!result.getTruncated() && !result.getColumns().isEmpty()) {
|
result.setQuery_timings_ms(timing.finish());
|
||||||
result.setServer_execute_time_us(availableServerExecuteTimeUs(
|
return result;
|
||||||
result.getRows().size(), JdbcExecutor.statementMaxRows(options.getMaxRows())
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryPageResult executeQueryPage(String sql, String schema, QueryPageOptions options) {
|
public QueryPageResult executeQueryPage(String sql, String schema, QueryPageOptions options) {
|
||||||
auditEligibleCursorId = null;
|
try (QueryTiming timing = QueryTiming.begin()) {
|
||||||
QueryPageResult result = super.executeQueryPage(sql, schema, options);
|
QueryPageResult result = super.executeQueryPage(sql, schema, options);
|
||||||
if (result.getHas_more()) {
|
result.setQuery_timings_ms(timing.finish());
|
||||||
auditEligibleCursorId = result.getSession_id();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return withCompletedCursorServerTiming(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryPageResult fetchQueryPage(String sessionId, int pageSize) {
|
public QueryPageResult fetchQueryPage(String sessionId, int pageSize) {
|
||||||
boolean auditEligible = sessionId != null && sessionId.equals(auditEligibleCursorId);
|
try (QueryTiming timing = QueryTiming.begin()) {
|
||||||
QueryPageResult result = super.fetchQueryPage(sessionId, pageSize);
|
QueryPageResult result = super.fetchQueryPage(sessionId, pageSize);
|
||||||
if (!result.getHas_more()) auditEligibleCursorId = null;
|
result.setQuery_timings_ms(timing.finish());
|
||||||
return auditEligible ? withCompletedCursorServerTiming(result) : result;
|
return result;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void beforeAgentMethod(String method, String querySessionId) {
|
|
||||||
if (!AgentProtocol.METHOD_FETCH_QUERY_PAGE.equals(method)
|
|
||||||
|| auditEligibleCursorId == null
|
|
||||||
|| !auditEligibleCursorId.equals(querySessionId)) {
|
|
||||||
auditEligibleCursorId = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private QueryPageResult withCompletedCursorServerTiming(QueryPageResult result) {
|
|
||||||
// JdbcExecutor closes the ResultSet and Statement before returning a terminal
|
|
||||||
// page. Never issue audit SQL while Connector/J still owns an open cursor.
|
|
||||||
// executePage limits rows while reading, without Statement.setMaxRows.
|
|
||||||
// Preserve its JDBC default of 0 here; QueryPageOptions.maxRows is a
|
|
||||||
// client-side cap, not the statement limit used by Connector/J.
|
|
||||||
if (!result.getHas_more() && !result.getTruncated() && !result.getColumns().isEmpty()) {
|
|
||||||
result.setServer_execute_time_us(availableServerExecuteTimeUs(result.getCursor_rows_read(), 0));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Long availableServerExecuteTimeUs(long expectedRows, int statementMaxRows) {
|
|
||||||
try {
|
|
||||||
return serverExecuteTimeUs(requireConnected(), expectedRows, statementMaxRows);
|
|
||||||
} catch (RuntimeException ignored) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static Long serverExecuteTimeUs(Connection connection, long expectedRows, int statementMaxRows) {
|
|
||||||
try {
|
|
||||||
String traceId;
|
|
||||||
try (Statement statement = connection.createStatement()) {
|
|
||||||
// Connector/J resets the session's SQL_SELECT_LIMIT in execute prolog
|
|
||||||
// when this differs from the previous statement. That SET would
|
|
||||||
// replace the query's LAST_TRACE_ID before we can read it.
|
|
||||||
statement.setMaxRows(statementMaxRows);
|
|
||||||
statement.setQueryTimeout(1);
|
|
||||||
try (ResultSet traces = statement.executeQuery("SELECT LAST_TRACE_ID() FROM DUAL")) {
|
|
||||||
traceId = traces.next() ? traces.getString(1) : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (traceId == null || traceId.isBlank()) return null;
|
|
||||||
try (PreparedStatement statement = connection.prepareStatement(SQL_AUDIT_BY_TRACE)) {
|
|
||||||
statement.setMaxRows(statementMaxRows);
|
|
||||||
statement.setQueryTimeout(1);
|
|
||||||
statement.setString(1, traceId);
|
|
||||||
try (ResultSet audit = statement.executeQuery()) {
|
|
||||||
if (!audit.next()) return null;
|
|
||||||
long executionUs = audit.getLong(1);
|
|
||||||
if (audit.wasNull() || executionUs < 0) return null;
|
|
||||||
long returnedRows = audit.getLong(2);
|
|
||||||
if (audit.wasNull() || returnedRows != expectedRows || audit.next()) return null;
|
|
||||||
return executionUs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (SQLException | RuntimeException ignored) {
|
|
||||||
// SQL Audit can be disabled, unavailable to this account, or evicted.
|
|
||||||
// The user's query result remains valid; no wall-clock substitute is used.
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-26
@@ -1,6 +1,5 @@
|
|||||||
package com.dbx.agent.oceanbaseoracle;
|
package com.dbx.agent.oceanbaseoracle;
|
||||||
|
|
||||||
import com.dbx.agent.AgentProtocol;
|
|
||||||
import com.dbx.agent.ColumnInfo;
|
import com.dbx.agent.ColumnInfo;
|
||||||
import com.dbx.agent.CompletionAssistantMatchMode;
|
import com.dbx.agent.CompletionAssistantMatchMode;
|
||||||
import com.dbx.agent.CompletionAssistantObjectKind;
|
import com.dbx.agent.CompletionAssistantObjectKind;
|
||||||
@@ -141,28 +140,9 @@ class OceanBaseOracleAgentTest {
|
|||||||
Assertions.assertThrows(IllegalArgumentException.class, () -> OceanBaseOracleAgent.queryTimeoutSql(-1));
|
Assertions.assertThrows(IllegalArgumentException.class, () -> OceanBaseOracleAgent.queryTimeoutSql(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void readsServerExecutionOnlyFromOneMatchingAuditRow() {
|
|
||||||
List<String> statements = new ArrayList<>();
|
|
||||||
List<String> parameters = new ArrayList<>();
|
|
||||||
List<Integer> maxRows = new ArrayList<>();
|
|
||||||
Assertions.assertEquals(370L, OceanBaseOracleAgent.serverExecuteTimeUs(
|
|
||||||
auditTimingConnection(1, 500, false, statements, parameters, maxRows), 500, 1001
|
|
||||||
));
|
|
||||||
Assertions.assertEquals(List.of(1001, 1001), maxRows,
|
|
||||||
"trace and audit statements must preserve the target statement's session row limit");
|
|
||||||
Assertions.assertEquals(List.of("trace-1"), parameters);
|
|
||||||
Assertions.assertTrue(statements.get(1).contains("IS_INNER_SQL = 0 AND IS_EXECUTOR_RPC = 0"));
|
|
||||||
Assertions.assertEquals(null, OceanBaseOracleAgent.serverExecuteTimeUs(auditTimingConnection(0, 500, false, new ArrayList<>(), new ArrayList<>(), new ArrayList<>()), 500, 0));
|
|
||||||
Assertions.assertEquals(null, OceanBaseOracleAgent.serverExecuteTimeUs(auditTimingConnection(2, 500, false, new ArrayList<>(), new ArrayList<>(), new ArrayList<>()), 500, 0));
|
|
||||||
Assertions.assertEquals(null, OceanBaseOracleAgent.serverExecuteTimeUs(auditTimingConnection(1, 1, false, new ArrayList<>(), new ArrayList<>(), new ArrayList<>()), 500, 0));
|
|
||||||
Assertions.assertEquals(null, OceanBaseOracleAgent.serverExecuteTimeUs(auditTimingConnection(1, 500, true, new ArrayList<>(), new ArrayList<>(), new ArrayList<>()), 500, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@CsvSource({"10, 1000, false", "1, 1000, false", "1, 1, true", "2, 2, false"})
|
@CsvSource({"10, 1000, false", "1, 1000, false", "1, 1, true", "2, 2, false"})
|
||||||
void preservesTheCursorStatementLimitWhenSamplingItsTerminalPage(int pageSize, int maxRows, boolean truncated) {
|
void returnsCursorRowsWithoutAdditionalAuditQueries(int pageSize, int maxRows, boolean truncated) {
|
||||||
List<Integer> auditLimits = new ArrayList<>();
|
List<Integer> auditLimits = new ArrayList<>();
|
||||||
List<String> auditSql = new ArrayList<>();
|
List<String> auditSql = new ArrayList<>();
|
||||||
Connection auditConnection = auditTimingConnection(1, 2, false, auditSql, new ArrayList<>(), auditLimits);
|
Connection auditConnection = auditTimingConnection(1, 2, false, auditSql, new ArrayList<>(), auditLimits);
|
||||||
@@ -219,12 +199,13 @@ class OceanBaseOracleAgentTest {
|
|||||||
Assertions.assertEquals(truncated, result.getTruncated());
|
Assertions.assertEquals(truncated, result.getTruncated());
|
||||||
Assertions.assertEquals(truncated ? List.of(List.of(1)) : List.of(List.of(1), List.of(2)), rows);
|
Assertions.assertEquals(truncated ? List.of(List.of(1)) : List.of(List.of(1), List.of(2)), rows);
|
||||||
Assertions.assertEquals(0, queryLimit[0], "the paging cap must not change the JDBC statement limit");
|
Assertions.assertEquals(0, queryLimit[0], "the paging cap must not change the JDBC statement limit");
|
||||||
Assertions.assertEquals(truncated ? List.of() : List.of(0, 0), auditLimits);
|
Assertions.assertTrue(auditSql.isEmpty(), "completed queries must not read trace or audit records");
|
||||||
Assertions.assertEquals(truncated ? null : Long.valueOf(370), result.getServer_execute_time_us());
|
Assertions.assertTrue(auditLimits.isEmpty());
|
||||||
|
Assertions.assertNull(result.getServer_execute_time_us());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void doesNotAuditAnOpenCursorAfterAnotherSessionMethodCanReplaceItsTrace() {
|
void finishesCursorWithoutCreatingDiagnosticStatements() {
|
||||||
int[] row = {-1};
|
int[] row = {-1};
|
||||||
ResultSetMetaData meta = proxy(ResultSetMetaData.class, (method, args) -> {
|
ResultSetMetaData meta = proxy(ResultSetMetaData.class, (method, args) -> {
|
||||||
if ("getColumnCount".equals(method.getName())) return 1;
|
if ("getColumnCount".equals(method.getName())) return 1;
|
||||||
@@ -259,11 +240,11 @@ class OceanBaseOracleAgentTest {
|
|||||||
Assertions.assertTrue(first.getHas_more());
|
Assertions.assertTrue(first.getHas_more());
|
||||||
Assertions.assertEquals(2, statementsCreated[0]);
|
Assertions.assertEquals(2, statementsCreated[0]);
|
||||||
|
|
||||||
agent.beforeAgentMethod(AgentProtocol.METHOD_LIST_TABLES, null);
|
|
||||||
QueryPageResult last = agent.fetchQueryPage(first.getSession_id(), 1);
|
QueryPageResult last = agent.fetchQueryPage(first.getSession_id(), 1);
|
||||||
Assertions.assertFalse(last.getHas_more());
|
Assertions.assertFalse(last.getHas_more());
|
||||||
Assertions.assertNull(last.getServer_execute_time_us());
|
Assertions.assertNull(last.getServer_execute_time_us());
|
||||||
Assertions.assertEquals(2, statementsCreated[0], "no LAST_TRACE_ID query may run for an invalidated cursor");
|
Assertions.assertEquals(2, statementsCreated[0], "no diagnostic query may run when the cursor finishes");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import QueryTimingDetails from "./QueryTimingDetails.vue";
|
||||||
import { applyDdlStoragePreference } from "@/lib/sql/ddlStorage";
|
import { applyDdlStoragePreference } from "@/lib/sql/ddlStorage";
|
||||||
import { applyDdlSearchMarks } from "@/lib/sql/ddlSearchMarks";
|
import { applyDdlSearchMarks } from "@/lib/sql/ddlSearchMarks";
|
||||||
import DdlStorageToggle from "@/components/objects/DdlStorageToggle.vue";
|
import DdlStorageToggle from "@/components/objects/DdlStorageToggle.vue";
|
||||||
@@ -6713,7 +6714,7 @@ let dataGridIsActive = true;
|
|||||||
let canvasRuntime: DataGridCanvasRuntime;
|
let canvasRuntime: DataGridCanvasRuntime;
|
||||||
const { elapsedMs: resultViewUpdateMs, canvasDrawCompleted: completeResultCanvasDraw } = useResultViewUpdateTiming(
|
const { elapsedMs: resultViewUpdateMs, canvasDrawCompleted: completeResultCanvasDraw } = useResultViewUpdateTiming(
|
||||||
() => props.result,
|
() => props.result,
|
||||||
() => resolvedDatabaseType.value === "oceanbase-oracle" && isResultsContext.value,
|
() => isResultsContext.value,
|
||||||
() => (useCanvasGridRows.value ? "canvas" : "dom"),
|
() => (useCanvasGridRows.value ? "canvas" : "dom"),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -13987,12 +13988,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val
|
|||||||
</span>
|
</span>
|
||||||
<span v-if="showTruncationWarning" class="shrink-0 text-amber-500 text-xs">(truncated)</span>
|
<span v-if="showTruncationWarning" class="shrink-0 text-amber-500 text-xs">(truncated)</span>
|
||||||
<span v-if="!hasData" class="shrink-0">{{ t("grid.rowsAffected", { count: result.affected_rows }) }}</span>
|
<span v-if="!hasData" class="shrink-0">{{ t("grid.rowsAffected", { count: result.affected_rows }) }}</span>
|
||||||
<template v-if="resolvedDatabaseType === 'oceanbase-oracle' && isResultsContext">
|
<QueryTimingDetails v-if="isResultsContext" :result="result" :render-ms="resultViewUpdateMs" />
|
||||||
<span class="shrink-0" :title="t('grid.serverExecuteTimeHint')">{{ result.server_execute_time_us !== undefined ? t("grid.serverExecuteTime", { us: result.server_execute_time_us }) : t("grid.serverExecuteTimeUnavailable") }}</span>
|
|
||||||
<span class="shrink-0" :title="t('grid.agentExecuteTimeHint')">{{ t("grid.agentExecuteTime", { ms: result.execution_time_ms }) }}</span>
|
|
||||||
<span v-if="result.client_request_wait_ms !== undefined" class="shrink-0" :title="t('grid.clientRequestWaitHint')">{{ t("grid.clientRequestWait", { ms: result.client_request_wait_ms }) }}</span>
|
|
||||||
<span v-if="resultViewUpdateMs !== undefined" class="shrink-0" :title="t('grid.resultViewUpdateHint')">{{ t("grid.resultViewUpdate", { ms: resultViewUpdateMs }) }}</span>
|
|
||||||
</template>
|
|
||||||
<span v-else class="shrink-0">{{ result.execution_time_ms }}ms</span>
|
<span v-else class="shrink-0">{{ result.execution_time_ms }}ms</span>
|
||||||
|
|
||||||
<template v-if="editable && hasDataGridSaveTarget">
|
<template v-if="editable && hasDataGridSaveTarget">
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from "vue";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||||
|
import type { QueryResult } from "@/types/database";
|
||||||
|
|
||||||
|
const props = defineProps<{ result: QueryResult; renderMs?: number }>();
|
||||||
|
const { t } = useI18n();
|
||||||
|
const measured = (value: number | undefined): value is number => typeof value === "number" && Number.isFinite(value) && value >= 0;
|
||||||
|
const format = (value: number | undefined) => (measured(value) ? `${Number(value.toFixed(3))}ms` : t("grid.timingUnavailable"));
|
||||||
|
const wait = computed(() => (measured(props.result.client_request_wait_ms) ? `${Math.round(props.result.client_request_wait_ms)}ms` : "—"));
|
||||||
|
const hasAgentTiming = computed(() => measured(props.result.query_timings_ms?.agent_total));
|
||||||
|
const phases = computed(() => {
|
||||||
|
const m = props.result.query_timings_ms ?? {};
|
||||||
|
const waitMs = props.result.client_request_wait_ms;
|
||||||
|
// This is a cross-boundary remainder, not a measured network duration.
|
||||||
|
const remainder = measured(waitMs) && measured(m.agent_total) && measured(m.core_lock) ? Math.max(0, waitMs - m.agent_total - m.core_lock) : undefined;
|
||||||
|
const agentOther = measured(m.agent_total)
|
||||||
|
? Math.max(
|
||||||
|
0,
|
||||||
|
m.agent_total -
|
||||||
|
Object.entries(m)
|
||||||
|
.filter(([key]) => !["agent_total", "core_lock"].includes(key))
|
||||||
|
.reduce((sum, [, value]) => sum + (measured(value) ? value : 0), 0),
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
|
const stages = [
|
||||||
|
{ key: "prepare", value: props.result.client_prepare_ms },
|
||||||
|
{ key: "request", value: waitMs },
|
||||||
|
{ key: "core_lock", value: m.core_lock },
|
||||||
|
{ key: "pool_acquire", value: m.pool_acquire },
|
||||||
|
{ key: "session_prepare", value: m.session_prepare },
|
||||||
|
{ key: "schema", value: m.schema },
|
||||||
|
{ key: "statement_prepare", value: m.statement_prepare },
|
||||||
|
{ key: "jdbc_execute", value: m.jdbc_execute },
|
||||||
|
{ key: "metadata", value: m.metadata },
|
||||||
|
{ key: "fetch", value: m.fetch },
|
||||||
|
{ key: "pool_release", value: m.pool_release },
|
||||||
|
{ key: "agent_other", value: agentOther },
|
||||||
|
{ key: "remainder", value: remainder },
|
||||||
|
{ key: "result", value: props.result.client_result_ms },
|
||||||
|
{ key: "render", value: props.renderMs },
|
||||||
|
];
|
||||||
|
return stages.filter((stage) => {
|
||||||
|
if (["prepare", "result", "render"].includes(stage.key)) return true;
|
||||||
|
if (stage.key === "request") return !hasAgentTiming.value;
|
||||||
|
return hasAgentTiming.value && measured(stage.value);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<TooltipProvider>
|
||||||
|
<Tooltip :delay-duration="200">
|
||||||
|
<TooltipTrigger as-child>
|
||||||
|
<button type="button" class="shrink-0 cursor-help rounded-sm tabular-nums focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring" :aria-label="t('grid.timingDetails') + ': ' + wait" data-testid="query-timing-trigger">{{ wait }}</button>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent side="top" align="start" class="block max-w-sm max-h-[var(--reka-tooltip-content-available-height)] overflow-y-auto">
|
||||||
|
<div class="space-y-2" data-testid="query-timing-details">
|
||||||
|
<p class="font-medium">{{ t("grid.clientRequestWait", { ms: measured(result.client_request_wait_ms) ? Number(result.client_request_wait_ms.toFixed(3)) : t("grid.timingUnavailable") }) }}</p>
|
||||||
|
<p v-if="(result.timing_page_count ?? 1) > 1">{{ t("grid.timingPages", { count: result.timing_page_count }) }}</p>
|
||||||
|
<table class="w-full border-collapse text-left" :aria-label="t('grid.timingDetails')">
|
||||||
|
<thead class="border-b border-current/20">
|
||||||
|
<tr>
|
||||||
|
<th scope="col" class="pb-1 pr-3 font-medium">{{ t("grid.timingNumber") }}</th>
|
||||||
|
<th scope="col" class="pb-1 pr-4 font-medium">{{ t("grid.timingStage") }}</th>
|
||||||
|
<th scope="col" class="pb-1 text-right font-medium">{{ t("grid.timingDuration") }}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="(phase, index) in phases" :key="phase.key">
|
||||||
|
<td class="py-0.5 pr-3 tabular-nums">{{ index + 1 }}.</td>
|
||||||
|
<th scope="row" class="py-0.5 pr-4 font-normal">{{ t(`grid.timingPhase_${phase.key}`) }}</th>
|
||||||
|
<td class="whitespace-nowrap py-0.5 text-right tabular-nums">{{ format(phase.value) }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<dl v-if="hasAgentTiming" class="border-t border-current/20 pt-2">
|
||||||
|
<div class="flex justify-between gap-4">
|
||||||
|
<dt>{{ t("grid.timingBackend") }}</dt>
|
||||||
|
<dd class="tabular-nums">{{ format(result.execution_time_ms) }}</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
// @vitest-environment happy-dom
|
||||||
|
import { createApp, nextTick } from "vue";
|
||||||
|
import { createI18n } from "vue-i18n";
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import QueryTimingDetails from "../QueryTimingDetails.vue";
|
||||||
|
import zh from "@/i18n/locales/zh-CN";
|
||||||
|
|
||||||
|
describe("query timing disclosure", () => {
|
||||||
|
it("shows only wait, then ordered details on keyboard focus", async () => {
|
||||||
|
const host = document.createElement("div");
|
||||||
|
document.body.append(host);
|
||||||
|
const app = createApp(QueryTimingDetails, {
|
||||||
|
result: {
|
||||||
|
columns: [],
|
||||||
|
rows: [],
|
||||||
|
affected_rows: 0,
|
||||||
|
execution_time_ms: 55,
|
||||||
|
client_request_wait_ms: 7030,
|
||||||
|
server_execute_time_us: 1019,
|
||||||
|
query_timings_ms: { pool_acquire: 350, pool_release: 5, session_prepare: 2, schema: 3, statement_prepare: 1, jdbc_execute: 40, metadata: 2, fetch: 7, trace: 1, audit: 6000, agent_total: 6411 },
|
||||||
|
},
|
||||||
|
renderMs: 4,
|
||||||
|
});
|
||||||
|
app.use(createI18n({ legacy: false, locale: "zh-CN", messages: { "zh-CN": zh } }));
|
||||||
|
app.mount(host);
|
||||||
|
await nextTick();
|
||||||
|
expect(host.textContent).toBe("7030ms");
|
||||||
|
expect(host.textContent).not.toContain("数据库执行");
|
||||||
|
host.querySelector<HTMLButtonElement>("button")!.focus();
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
|
await nextTick();
|
||||||
|
const text = document.body.textContent!;
|
||||||
|
expect(text).toContain("1.");
|
||||||
|
expect(text).not.toContain("读取审计记录");
|
||||||
|
expect(text).not.toContain("读取追踪 ID");
|
||||||
|
expect(text).not.toContain("数据库计划");
|
||||||
|
expect(text).toContain("后端报告耗时");
|
||||||
|
expect(text).not.toContain("驱动报告耗时");
|
||||||
|
expect(text).toContain("获取连接");
|
||||||
|
expect(text).toContain("归还连接");
|
||||||
|
const details = document.querySelector('[data-testid="query-timing-details"]')!;
|
||||||
|
const stages = [...details.querySelectorAll("tbody tr")].map((row) => row.textContent!);
|
||||||
|
// No Core lock sample means both the lock and dependent remainder are absent.
|
||||||
|
expect(stages).toHaveLength(12);
|
||||||
|
expect([...details.querySelectorAll("thead th")].map((cell) => cell.textContent)).toEqual(["序号", "阶段", "耗时"]);
|
||||||
|
expect(stages.findIndex((s) => s.includes("获取连接"))).toBeLessThan(stages.findIndex((s) => s.includes("会话")));
|
||||||
|
expect(stages.findIndex((s) => s.includes("归还连接"))).toBeGreaterThan(stages.findIndex((s) => s.includes("读取结果")));
|
||||||
|
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }));
|
||||||
|
app.unmount();
|
||||||
|
host.remove();
|
||||||
|
});
|
||||||
|
it("shows common request stages without inventing JDBC steps for a native or HTTP result", async () => {
|
||||||
|
const host = document.createElement("div");
|
||||||
|
document.body.append(host);
|
||||||
|
const app = createApp(QueryTimingDetails, { result: { columns: [], rows: [], affected_rows: 0, execution_time_ms: 4, client_request_wait_ms: 12, client_prepare_ms: 2, client_result_ms: 1 }, renderMs: 3 });
|
||||||
|
app.use(createI18n({ legacy: false, locale: "zh-CN", messages: { "zh-CN": zh } }));
|
||||||
|
app.mount(host);
|
||||||
|
await nextTick();
|
||||||
|
host.querySelector<HTMLButtonElement>("button")!.focus();
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
|
await nextTick();
|
||||||
|
const details = document.querySelector('[data-testid="query-timing-details"]')!;
|
||||||
|
expect(details.querySelectorAll("tbody tr")).toHaveLength(4);
|
||||||
|
expect(details.textContent).toContain("请求等待");
|
||||||
|
expect(details.textContent).not.toContain("JDBC");
|
||||||
|
expect(details.textContent).not.toContain("获取连接");
|
||||||
|
document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }));
|
||||||
|
app.unmount();
|
||||||
|
host.remove();
|
||||||
|
});
|
||||||
|
it("does not substitute execution time when wait or phases are missing", async () => {
|
||||||
|
const host = document.createElement("div");
|
||||||
|
document.body.append(host);
|
||||||
|
const app = createApp(QueryTimingDetails, { result: { columns: [], rows: [], affected_rows: 0, execution_time_ms: 55 } });
|
||||||
|
app.use(createI18n({ legacy: false, locale: "zh-CN", messages: { "zh-CN": zh } }));
|
||||||
|
app.mount(host);
|
||||||
|
await nextTick();
|
||||||
|
expect(host.textContent).toBe("—");
|
||||||
|
app.unmount();
|
||||||
|
host.remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -2094,8 +2094,30 @@ export default {
|
|||||||
serverExecuteTimeHint:
|
serverExecuteTimeHint:
|
||||||
"OceanBase SQL Audit EXECUTE_TIME measures server plan execution. A JDBC cursor shows its completed statement sample; independent page queries show the sum only when every page is sampled. This overlaps with execution and wait timings. Unavailable while a cursor remains open or when audit data cannot be read or matched.",
|
"OceanBase SQL Audit EXECUTE_TIME measures server plan execution. A JDBC cursor shows its completed statement sample; independent page queries show the sum only when every page is sampled. This overlaps with execution and wait timings. Unavailable while a cursor remains open or when audit data cannot be read or matched.",
|
||||||
agentExecuteTimeHint: "Agent time from schema setup through JDBC execute. Excludes row fetching; not database server execution time.",
|
agentExecuteTimeHint: "Agent time from schema setup through JDBC execute. Excludes row fetching; not database server execution time.",
|
||||||
|
timingNumber: "No.",
|
||||||
|
timingStage: "Stage",
|
||||||
|
timingDuration: "Time",
|
||||||
|
timingDetails: "Query timing details",
|
||||||
|
timingUnavailable: "Not measured",
|
||||||
|
timingPages: "Cumulative across {count} requests; rendering is for the latest update.",
|
||||||
|
timingPhase_request: "Request wait",
|
||||||
|
timingPhase_prepare: "Preparation (outside wait)",
|
||||||
|
timingPhase_core_lock: "Wait for execution lock",
|
||||||
|
timingPhase_pool_acquire: "Acquire connection",
|
||||||
|
timingPhase_session_prepare: "Prepare session",
|
||||||
|
timingPhase_pool_release: "Return connection",
|
||||||
|
timingPhase_schema: "Set schema",
|
||||||
|
timingPhase_statement_prepare: "Prepare statement",
|
||||||
|
timingPhase_jdbc_execute: "Execute SQL (JDBC)",
|
||||||
|
timingPhase_metadata: "Read column metadata",
|
||||||
|
timingPhase_fetch: "Read rows and close cursor",
|
||||||
|
timingPhase_agent_other: "Other Agent processing (remainder)",
|
||||||
|
timingPhase_remainder: "Other wait (remainder, not network time)",
|
||||||
|
timingPhase_result: "Process results (outside wait)",
|
||||||
|
timingBackend: "Backend-reported time (overlaps stages)",
|
||||||
|
timingPhase_render: "Update grid (outside wait)",
|
||||||
clientRequestWait: "Wait: {ms} ms",
|
clientRequestWait: "Wait: {ms} ms",
|
||||||
clientRequestWaitHint: "Desktop time from query request dispatch until the full result payload arrives. Includes fetching, the optional server audit lookup, and transport; excludes SQL preparation and grid rendering. Summed across loaded pages.",
|
clientRequestWaitHint: "Desktop time from query request dispatch until the full result payload arrives. Includes backend processing, fetching, and transport; excludes request preparation and grid rendering. Summed across loaded pages.",
|
||||||
resultViewUpdate: "Grid update: {ms} ms",
|
resultViewUpdate: "Grid update: {ms} ms",
|
||||||
resultViewUpdateHint: "Time from the grid observing this result until its DOM update completes or a Canvas draw is submitted. Excludes GPU compositing and screen presentation.",
|
resultViewUpdateHint: "Time from the grid observing this result until its DOM update completes or a Canvas draw is submitted. Excludes GPU compositing and screen presentation.",
|
||||||
querySuccess: "Query executed successfully",
|
querySuccess: "Query executed successfully",
|
||||||
|
|||||||
@@ -1992,6 +1992,28 @@ export default withEnglishFallback({
|
|||||||
serverExecuteTimeHint:
|
serverExecuteTimeHint:
|
||||||
"EXECUTE_TIME de OceanBase SQL Audit mide la ejecución del plan en el servidor. Los cursores JDBC muestran la muestra al finalizar la sentencia original; la paginación con consultas independientes solo muestra la suma si todas las páginas tienen muestras. Se solapa con los tiempos de ejecución y espera. No está disponible si el cursor sigue abierto o si los datos de auditoría no se pueden leer o asociar.",
|
"EXECUTE_TIME de OceanBase SQL Audit mide la ejecución del plan en el servidor. Los cursores JDBC muestran la muestra al finalizar la sentencia original; la paginación con consultas independientes solo muestra la suma si todas las páginas tienen muestras. Se solapa con los tiempos de ejecución y espera. No está disponible si el cursor sigue abierto o si los datos de auditoría no se pueden leer o asociar.",
|
||||||
agentExecuteTimeHint: "Tiempo del Agent desde la configuración del esquema hasta que retorna JDBC execute. No incluye la lectura de filas ni equivale al tiempo de ejecución del servidor de base de datos.",
|
agentExecuteTimeHint: "Tiempo del Agent desde la configuración del esquema hasta que retorna JDBC execute. No incluye la lectura de filas ni equivale al tiempo de ejecución del servidor de base de datos.",
|
||||||
|
timingNumber: "N.º",
|
||||||
|
timingStage: "Etapa",
|
||||||
|
timingDuration: "Tiempo",
|
||||||
|
timingDetails: "Detalles del tiempo de consulta",
|
||||||
|
timingUnavailable: "Sin medir",
|
||||||
|
timingPages: "Acumulado de {count} solicitudes; el renderizado corresponde a la última actualización.",
|
||||||
|
timingPhase_request: "Espera de la solicitud",
|
||||||
|
timingPhase_prepare: "Preparación (fuera de la espera)",
|
||||||
|
timingPhase_core_lock: "Espera del bloqueo de ejecución",
|
||||||
|
timingPhase_pool_acquire: "Obtener conexión",
|
||||||
|
timingPhase_session_prepare: "Preparar sesión",
|
||||||
|
timingPhase_pool_release: "Devolver conexión",
|
||||||
|
timingPhase_schema: "Establecer esquema",
|
||||||
|
timingPhase_statement_prepare: "Preparar sentencia",
|
||||||
|
timingPhase_jdbc_execute: "Ejecutar SQL (JDBC)",
|
||||||
|
timingPhase_metadata: "Leer metadatos de columnas",
|
||||||
|
timingPhase_fetch: "Leer filas y cerrar cursor",
|
||||||
|
timingPhase_agent_other: "Otros procesos del Agent (diferencia)",
|
||||||
|
timingPhase_remainder: "Otras esperas (diferencia, no es tiempo de red)",
|
||||||
|
timingPhase_result: "Procesar resultados (fuera de la espera)",
|
||||||
|
timingBackend: "Tiempo informado por el backend (se solapa con las etapas)",
|
||||||
|
timingPhase_render: "Actualizar tabla (fuera de la espera)",
|
||||||
clientRequestWait: "Espera: {ms} ms",
|
clientRequestWait: "Espera: {ms} ms",
|
||||||
clientRequestWaitHint:
|
clientRequestWaitHint:
|
||||||
"Tiempo desde que la aplicación de escritorio envía la consulta hasta que recibe el resultado completo. Incluye la lectura de filas, la consulta de auditoría del servidor cuando está disponible y la transferencia; excluye la preparación del SQL y el renderizado de la tabla. Se suma entre las páginas cargadas.",
|
"Tiempo desde que la aplicación de escritorio envía la consulta hasta que recibe el resultado completo. Incluye la lectura de filas, la consulta de auditoría del servidor cuando está disponible y la transferencia; excluye la preparación del SQL y el renderizado de la tabla. Se suma entre las páginas cargadas.",
|
||||||
|
|||||||
@@ -1926,6 +1926,28 @@ export default withEnglishFallback({
|
|||||||
serverExecuteTimeHint:
|
serverExecuteTimeHint:
|
||||||
"EXECUTE_TIME di OceanBase SQL Audit misura l'esecuzione del piano sul server. I cursori JDBC mostrano il campione al termine dell'istruzione originale; la paginazione con query indipendenti mostra la somma solo se tutte le pagine hanno un campione. Si sovrappone ai tempi di esecuzione e attesa. Non è disponibile se il cursore è ancora aperto o se i dati di audit non possono essere letti o associati.",
|
"EXECUTE_TIME di OceanBase SQL Audit misura l'esecuzione del piano sul server. I cursori JDBC mostrano il campione al termine dell'istruzione originale; la paginazione con query indipendenti mostra la somma solo se tutte le pagine hanno un campione. Si sovrappone ai tempi di esecuzione e attesa. Non è disponibile se il cursore è ancora aperto o se i dati di audit non possono essere letti o associati.",
|
||||||
agentExecuteTimeHint: "Tempo dell'Agent dall'impostazione dello schema al ritorno di JDBC execute. Esclude la lettura delle righe e non equivale al tempo di esecuzione del server di database.",
|
agentExecuteTimeHint: "Tempo dell'Agent dall'impostazione dello schema al ritorno di JDBC execute. Esclude la lettura delle righe e non equivale al tempo di esecuzione del server di database.",
|
||||||
|
timingNumber: "N.",
|
||||||
|
timingStage: "Fase",
|
||||||
|
timingDuration: "Tempo",
|
||||||
|
timingDetails: "Dettagli dei tempi della query",
|
||||||
|
timingUnavailable: "Non misurato",
|
||||||
|
timingPages: "Totale di {count} richieste; il rendering si riferisce al più recente aggiornamento.",
|
||||||
|
timingPhase_request: "Attesa della richiesta",
|
||||||
|
timingPhase_prepare: "Preparazione (fuori dal tempo di attesa)",
|
||||||
|
timingPhase_core_lock: "Attesa del blocco di esecuzione",
|
||||||
|
timingPhase_pool_acquire: "Acquisizione connessione",
|
||||||
|
timingPhase_session_prepare: "Preparazione sessione",
|
||||||
|
timingPhase_pool_release: "Restituzione connessione",
|
||||||
|
timingPhase_schema: "Impostazione schema",
|
||||||
|
timingPhase_statement_prepare: "Preparazione istruzione",
|
||||||
|
timingPhase_jdbc_execute: "Esecuzione SQL (JDBC)",
|
||||||
|
timingPhase_metadata: "Lettura metadati delle colonne",
|
||||||
|
timingPhase_fetch: "Lettura righe e chiusura cursore",
|
||||||
|
timingPhase_agent_other: "Altre elaborazioni Agent (differenza)",
|
||||||
|
timingPhase_remainder: "Altre attese (differenza, non tempo di rete)",
|
||||||
|
timingPhase_result: "Elaborazione risultati (fuori dal tempo di attesa)",
|
||||||
|
timingBackend: "Tempo riportato dal backend (sovrapposto alle fasi)",
|
||||||
|
timingPhase_render: "Aggiornamento tabella (fuori dal tempo di attesa)",
|
||||||
clientRequestWait: "Attesa: {ms} ms",
|
clientRequestWait: "Attesa: {ms} ms",
|
||||||
clientRequestWaitHint:
|
clientRequestWaitHint:
|
||||||
"Tempo dall'invio della query dall'applicazione desktop alla ricezione del risultato completo. Include la lettura delle righe, la query di audit del server quando disponibile e il trasferimento; esclude la preparazione SQL e il rendering della tabella. Viene sommato tra le pagine caricate.",
|
"Tempo dall'invio della query dall'applicazione desktop alla ricezione del risultato completo. Include la lettura delle righe, la query di audit del server quando disponibile e il trasferimento; esclude la preparazione SQL e il rendering della tabella. Viene sommato tra le pagine caricate.",
|
||||||
|
|||||||
@@ -1948,6 +1948,28 @@ export default withEnglishFallback({
|
|||||||
serverExecuteTimeHint:
|
serverExecuteTimeHint:
|
||||||
"OceanBase SQL Audit の EXECUTE_TIME はサーバーでの実行計画の処理時間です。JDBC カーソルでは元の文の終了後に取得したサンプルを表示します。ページごとに独立した SQL を実行する場合は、すべてのページのサンプルがあるときだけ合計を表示します。実行時間や待機時間と範囲が重複します。カーソルが終了していない場合や、監査データの取得・関連付けができない場合は取得不可となります。",
|
"OceanBase SQL Audit の EXECUTE_TIME はサーバーでの実行計画の処理時間です。JDBC カーソルでは元の文の終了後に取得したサンプルを表示します。ページごとに独立した SQL を実行する場合は、すべてのページのサンプルがあるときだけ合計を表示します。実行時間や待機時間と範囲が重複します。カーソルが終了していない場合や、監査データの取得・関連付けができない場合は取得不可となります。",
|
||||||
agentExecuteTimeHint: "スキーマの設定から JDBC execute が戻るまでの Agent の処理時間です。行の取得は含まず、データベースサーバーだけの実行時間ではありません。",
|
agentExecuteTimeHint: "スキーマの設定から JDBC execute が戻るまでの Agent の処理時間です。行の取得は含まず、データベースサーバーだけの実行時間ではありません。",
|
||||||
|
timingNumber: "番号",
|
||||||
|
timingStage: "段階",
|
||||||
|
timingDuration: "時間",
|
||||||
|
timingDetails: "クエリ時間の詳細",
|
||||||
|
timingUnavailable: "未計測",
|
||||||
|
timingPages: "{count} 件のリクエストの累計。描画時間は直近の更新分です。",
|
||||||
|
timingPhase_request: "リクエスト待機",
|
||||||
|
timingPhase_prepare: "準備(待機時間に含まない)",
|
||||||
|
timingPhase_core_lock: "実行ロック待機",
|
||||||
|
timingPhase_pool_acquire: "接続の取得",
|
||||||
|
timingPhase_session_prepare: "セッションの準備",
|
||||||
|
timingPhase_pool_release: "接続の返却",
|
||||||
|
timingPhase_schema: "スキーマの設定",
|
||||||
|
timingPhase_statement_prepare: "ステートメントの準備",
|
||||||
|
timingPhase_jdbc_execute: "SQL の実行(JDBC)",
|
||||||
|
timingPhase_metadata: "列メタデータの取得",
|
||||||
|
timingPhase_fetch: "行の読み取りとカーソルの終了",
|
||||||
|
timingPhase_agent_other: "その他の Agent 処理(差分)",
|
||||||
|
timingPhase_remainder: "その他の待機(差分、通信時間ではない)",
|
||||||
|
timingPhase_result: "結果の処理(待機時間に含まない)",
|
||||||
|
timingBackend: "バックエンド報告時間(各段階と重複)",
|
||||||
|
timingPhase_render: "表の更新(待機時間に含まない)",
|
||||||
clientRequestWait: "待機時間:{ms} ms",
|
clientRequestWait: "待機時間:{ms} ms",
|
||||||
clientRequestWaitHint: "デスクトップ側がクエリ要求を送信してから結果全体を受信するまでの時間です。行の取得、利用可能な場合のサーバー監査クエリ、転送を含み、SQL の準備とテーブル描画は含みません。複数ページを読み込んだ場合は各ページの待機時間を合計します。",
|
clientRequestWaitHint: "デスクトップ側がクエリ要求を送信してから結果全体を受信するまでの時間です。行の取得、利用可能な場合のサーバー監査クエリ、転送を含み、SQL の準備とテーブル描画は含みません。複数ページを読み込んだ場合は各ページの待機時間を合計します。",
|
||||||
resultViewUpdate: "テーブル更新:{ms} ms",
|
resultViewUpdate: "テーブル更新:{ms} ms",
|
||||||
|
|||||||
@@ -1877,6 +1877,28 @@ export default withEnglishFallback({
|
|||||||
serverExecuteTimeHint:
|
serverExecuteTimeHint:
|
||||||
"OceanBase SQL Audit의 EXECUTE_TIME은 서버에서 실행 계획을 수행한 시간입니다. JDBC 커서는 원래 구문이 끝난 후의 샘플을 표시하며, 페이지별 독립 SQL은 모든 페이지에 샘플이 있을 때만 합계를 표시합니다. 실행 시간 및 대기 시간과 측정 범위가 겹칩니다. 커서가 끝나지 않았거나 감사 데이터를 읽거나 연결할 수 없으면 사용할 수 없습니다.",
|
"OceanBase SQL Audit의 EXECUTE_TIME은 서버에서 실행 계획을 수행한 시간입니다. JDBC 커서는 원래 구문이 끝난 후의 샘플을 표시하며, 페이지별 독립 SQL은 모든 페이지에 샘플이 있을 때만 합계를 표시합니다. 실행 시간 및 대기 시간과 측정 범위가 겹칩니다. 커서가 끝나지 않았거나 감사 데이터를 읽거나 연결할 수 없으면 사용할 수 없습니다.",
|
||||||
agentExecuteTimeHint: "스키마 설정부터 JDBC execute가 반환될 때까지의 Agent 처리 시간입니다. 행 가져오기는 포함하지 않으며 데이터베이스 서버만의 실행 시간은 아닙니다.",
|
agentExecuteTimeHint: "스키마 설정부터 JDBC execute가 반환될 때까지의 Agent 처리 시간입니다. 행 가져오기는 포함하지 않으며 데이터베이스 서버만의 실행 시간은 아닙니다.",
|
||||||
|
timingNumber: "번호",
|
||||||
|
timingStage: "단계",
|
||||||
|
timingDuration: "시간",
|
||||||
|
timingDetails: "쿼리 시간 상세",
|
||||||
|
timingUnavailable: "측정되지 않음",
|
||||||
|
timingPages: "{count}개 요청의 누적 시간입니다. 렌더링은 최근 업데이트 기준입니다.",
|
||||||
|
timingPhase_request: "요청 대기",
|
||||||
|
timingPhase_prepare: "준비 (대기 시간 제외)",
|
||||||
|
timingPhase_core_lock: "실행 잠금 대기",
|
||||||
|
timingPhase_pool_acquire: "연결 획득",
|
||||||
|
timingPhase_session_prepare: "세션 준비",
|
||||||
|
timingPhase_pool_release: "연결 반환",
|
||||||
|
timingPhase_schema: "스키마 설정",
|
||||||
|
timingPhase_statement_prepare: "문 준비",
|
||||||
|
timingPhase_jdbc_execute: "SQL 실행 (JDBC)",
|
||||||
|
timingPhase_metadata: "열 메타데이터 읽기",
|
||||||
|
timingPhase_fetch: "행 읽기 및 커서 닫기",
|
||||||
|
timingPhase_agent_other: "기타 Agent 처리 (차이값)",
|
||||||
|
timingPhase_remainder: "기타 대기 (차이값, 네트워크 시간 아님)",
|
||||||
|
timingPhase_result: "결과 처리 (대기 시간 제외)",
|
||||||
|
timingBackend: "백엔드 보고 시간 (단계별 시간과 중복)",
|
||||||
|
timingPhase_render: "표 업데이트 (대기 시간 제외)",
|
||||||
clientRequestWait: "대기 시간: {ms} ms",
|
clientRequestWait: "대기 시간: {ms} ms",
|
||||||
clientRequestWaitHint: "데스크톱에서 쿼리 요청을 보낸 시점부터 전체 결과를 받을 때까지의 시간입니다. 행 가져오기, 사용 가능한 경우의 서버 감사 조회 및 전송을 포함하며 SQL 준비와 테이블 렌더링은 제외합니다. 여러 페이지를 불러오면 각 페이지의 대기 시간을 합산합니다.",
|
clientRequestWaitHint: "데스크톱에서 쿼리 요청을 보낸 시점부터 전체 결과를 받을 때까지의 시간입니다. 행 가져오기, 사용 가능한 경우의 서버 감사 조회 및 전송을 포함하며 SQL 준비와 테이블 렌더링은 제외합니다. 여러 페이지를 불러오면 각 페이지의 대기 시간을 합산합니다.",
|
||||||
resultViewUpdate: "테이블 갱신: {ms} ms",
|
resultViewUpdate: "테이블 갱신: {ms} ms",
|
||||||
|
|||||||
@@ -1928,6 +1928,28 @@ export default withEnglishFallback({
|
|||||||
serverExecuteTimeHint:
|
serverExecuteTimeHint:
|
||||||
"EXECUTE_TIME do OceanBase SQL Audit mede a execução do plano no servidor. Os cursores JDBC mostram a amostra após o término da instrução original; a paginação com consultas independentes só mostra a soma quando todas as páginas têm amostras. Há sobreposição com os tempos de execução e espera. Indisponível enquanto o cursor não terminar ou quando os dados de auditoria não puderem ser lidos ou associados.",
|
"EXECUTE_TIME do OceanBase SQL Audit mede a execução do plano no servidor. Os cursores JDBC mostram a amostra após o término da instrução original; a paginação com consultas independentes só mostra a soma quando todas as páginas têm amostras. Há sobreposição com os tempos de execução e espera. Indisponível enquanto o cursor não terminar ou quando os dados de auditoria não puderem ser lidos ou associados.",
|
||||||
agentExecuteTimeHint: "Tempo do Agent desde a configuração do esquema até o retorno de JDBC execute. Exclui a leitura de linhas e não equivale ao tempo de execução do servidor de banco de dados.",
|
agentExecuteTimeHint: "Tempo do Agent desde a configuração do esquema até o retorno de JDBC execute. Exclui a leitura de linhas e não equivale ao tempo de execução do servidor de banco de dados.",
|
||||||
|
timingNumber: "Nº",
|
||||||
|
timingStage: "Etapa",
|
||||||
|
timingDuration: "Tempo",
|
||||||
|
timingDetails: "Detalhes do tempo da consulta",
|
||||||
|
timingUnavailable: "Não medido",
|
||||||
|
timingPages: "Acumulado de {count} solicitações; a renderização corresponde à última atualização.",
|
||||||
|
timingPhase_request: "Espera da solicitação",
|
||||||
|
timingPhase_prepare: "Preparação (fora da espera)",
|
||||||
|
timingPhase_core_lock: "Espera pelo bloqueio de execução",
|
||||||
|
timingPhase_pool_acquire: "Obter conexão",
|
||||||
|
timingPhase_session_prepare: "Preparar sessão",
|
||||||
|
timingPhase_pool_release: "Devolver conexão",
|
||||||
|
timingPhase_schema: "Definir esquema",
|
||||||
|
timingPhase_statement_prepare: "Preparar instrução",
|
||||||
|
timingPhase_jdbc_execute: "Executar SQL (JDBC)",
|
||||||
|
timingPhase_metadata: "Ler metadados das colunas",
|
||||||
|
timingPhase_fetch: "Ler linhas e fechar cursor",
|
||||||
|
timingPhase_agent_other: "Outros processamentos do Agent (diferença)",
|
||||||
|
timingPhase_remainder: "Outras esperas (diferença, não é tempo de rede)",
|
||||||
|
timingPhase_result: "Processar resultados (fora da espera)",
|
||||||
|
timingBackend: "Tempo informado pelo backend (sobrepõe as etapas)",
|
||||||
|
timingPhase_render: "Atualizar tabela (fora da espera)",
|
||||||
clientRequestWait: "Espera: {ms} ms",
|
clientRequestWait: "Espera: {ms} ms",
|
||||||
clientRequestWaitHint:
|
clientRequestWaitHint:
|
||||||
"Tempo entre o envio da consulta pelo aplicativo desktop e o recebimento do resultado completo. Inclui a leitura de linhas, a consulta de auditoria do servidor quando disponível e a transferência; exclui a preparação do SQL e a renderização da tabela. Soma os tempos de espera das páginas carregadas.",
|
"Tempo entre o envio da consulta pelo aplicativo desktop e o recebimento do resultado completo. Inclui a leitura de linhas, a consulta de auditoria do servidor quando disponível e a transferência; exclui a preparação do SQL e a renderização da tabela. Soma os tempos de espera das páginas carregadas.",
|
||||||
|
|||||||
@@ -1976,6 +1976,28 @@ export default withEnglishFallback({
|
|||||||
serverExecuteTimeHint:
|
serverExecuteTimeHint:
|
||||||
"OceanBase SQL Audit EXECUTE_TIME измеряет выполнение плана на сервере. Курсор JDBC показывает образец завершённого оператора; независимые запросы страниц показывают сумму только тогда, когда каждая страница попала в выборку. Эти данные пересекаются со временем выполнения и ожидания. Недоступно, пока курсор остаётся открытым или пока данные аудита нельзя прочитать или сопоставить.",
|
"OceanBase SQL Audit EXECUTE_TIME измеряет выполнение плана на сервере. Курсор JDBC показывает образец завершённого оператора; независимые запросы страниц показывают сумму только тогда, когда каждая страница попала в выборку. Эти данные пересекаются со временем выполнения и ожидания. Недоступно, пока курсор остаётся открытым или пока данные аудита нельзя прочитать или сопоставить.",
|
||||||
agentExecuteTimeHint: "Время агента от настройки схемы до выполнения JDBC. Не включает выборку строк; это не время выполнения на сервере БД.",
|
agentExecuteTimeHint: "Время агента от настройки схемы до выполнения JDBC. Не включает выборку строк; это не время выполнения на сервере БД.",
|
||||||
|
timingNumber: "№",
|
||||||
|
timingStage: "Этап",
|
||||||
|
timingDuration: "Время",
|
||||||
|
timingDetails: "Подробности времени запроса",
|
||||||
|
timingUnavailable: "Не измерено",
|
||||||
|
timingPages: "Суммарно по {count} запросам; отрисовка относится к последнему обновлению.",
|
||||||
|
timingPhase_request: "Ожидание запроса",
|
||||||
|
timingPhase_prepare: "Подготовка (вне ожидания)",
|
||||||
|
timingPhase_core_lock: "Ожидание блокировки выполнения",
|
||||||
|
timingPhase_pool_acquire: "Получение соединения",
|
||||||
|
timingPhase_session_prepare: "Подготовка сеанса",
|
||||||
|
timingPhase_pool_release: "Возврат соединения",
|
||||||
|
timingPhase_schema: "Установка схемы",
|
||||||
|
timingPhase_statement_prepare: "Подготовка оператора",
|
||||||
|
timingPhase_jdbc_execute: "Выполнение SQL (JDBC)",
|
||||||
|
timingPhase_metadata: "Чтение метаданных столбцов",
|
||||||
|
timingPhase_fetch: "Чтение строк и закрытие курсора",
|
||||||
|
timingPhase_agent_other: "Прочая обработка Agent (разница)",
|
||||||
|
timingPhase_remainder: "Прочее ожидание (разница, не время сети)",
|
||||||
|
timingPhase_result: "Обработка результатов (вне ожидания)",
|
||||||
|
timingBackend: "Время от backend (перекрывается с этапами)",
|
||||||
|
timingPhase_render: "Обновление таблицы (вне ожидания)",
|
||||||
clientRequestWait: "Ожидание: {ms} мс",
|
clientRequestWait: "Ожидание: {ms} мс",
|
||||||
clientRequestWaitHint: "Время настольного приложения от отправки запроса до получения полного ответа. Включает выборку, необязательный поиск в аудите сервера и передачу данных; не включает подготовку SQL и отрисовку таблицы. Суммируется по загруженным страницам.",
|
clientRequestWaitHint: "Время настольного приложения от отправки запроса до получения полного ответа. Включает выборку, необязательный поиск в аудите сервера и передачу данных; не включает подготовку SQL и отрисовку таблицы. Суммируется по загруженным страницам.",
|
||||||
resultViewUpdate: "Обновление таблицы: {ms} мс",
|
resultViewUpdate: "Обновление таблицы: {ms} мс",
|
||||||
|
|||||||
@@ -2006,8 +2006,30 @@ export default withEnglishFallback({
|
|||||||
serverExecuteTimeUnavailable: "数据库执行:不可用",
|
serverExecuteTimeUnavailable: "数据库执行:不可用",
|
||||||
serverExecuteTimeHint: "OceanBase SQL Audit EXECUTE_TIME 表示服务端执行计划的耗时。JDBC 游标显示原语句结束后的样本;独立分页 SQL 仅在各页均有样本时显示总和。与执行耗时和等待耗时范围重叠。游标未结束或审计数据无法读取、关联时不可用。",
|
serverExecuteTimeHint: "OceanBase SQL Audit EXECUTE_TIME 表示服务端执行计划的耗时。JDBC 游标显示原语句结束后的样本;独立分页 SQL 仅在各页均有样本时显示总和。与执行耗时和等待耗时范围重叠。游标未结束或审计数据无法读取、关联时不可用。",
|
||||||
agentExecuteTimeHint: "从设置 schema 到 JDBC execute 返回的 Agent 耗时;不含取行,并非数据库服务端纯执行时间。",
|
agentExecuteTimeHint: "从设置 schema 到 JDBC execute 返回的 Agent 耗时;不含取行,并非数据库服务端纯执行时间。",
|
||||||
|
timingNumber: "序号",
|
||||||
|
timingStage: "阶段",
|
||||||
|
timingDuration: "耗时",
|
||||||
|
timingDetails: "查询耗时详情",
|
||||||
|
timingUnavailable: "未采集",
|
||||||
|
timingPages: "累计 {count} 次请求;表格更新为最近一次。",
|
||||||
|
timingPhase_request: "请求等待",
|
||||||
|
timingPhase_prepare: "请求准备(不计入等待)",
|
||||||
|
timingPhase_core_lock: "等待执行锁",
|
||||||
|
timingPhase_pool_acquire: "获取连接",
|
||||||
|
timingPhase_session_prepare: "准备会话",
|
||||||
|
timingPhase_pool_release: "归还连接",
|
||||||
|
timingPhase_schema: "设置 schema",
|
||||||
|
timingPhase_statement_prepare: "准备语句",
|
||||||
|
timingPhase_jdbc_execute: "执行 SQL(JDBC)",
|
||||||
|
timingPhase_metadata: "读取列信息",
|
||||||
|
timingPhase_fetch: "读取结果并关闭游标",
|
||||||
|
timingPhase_agent_other: "Agent 其他处理(差额)",
|
||||||
|
timingPhase_remainder: "其他等待(差额,非网络耗时)",
|
||||||
|
timingPhase_result: "结果整理(不计入等待)",
|
||||||
|
timingBackend: "后端报告耗时(与步骤重叠)",
|
||||||
|
timingPhase_render: "表格更新(不计入等待)",
|
||||||
clientRequestWait: "等待耗时:{ms} 毫秒",
|
clientRequestWait: "等待耗时:{ms} 毫秒",
|
||||||
clientRequestWaitHint: "桌面端发出查询请求至收到完整结果的耗时,包含取行、可用时的服务端审计查询和传输,不含 SQL 准备与表格渲染;加载多页时累加各页等待时间。",
|
clientRequestWaitHint: "桌面端发出查询请求至收到完整结果的耗时,包含后端处理、取行和传输,不含请求准备与表格渲染;加载多页时累加各页等待时间。",
|
||||||
resultViewUpdate: "表格更新:{ms} 毫秒",
|
resultViewUpdate: "表格更新:{ms} 毫秒",
|
||||||
resultViewUpdateHint: "从表格接收到本次结果,到 DOM 更新完成或 Canvas 绘制提交;不含 GPU 合成及屏幕实际呈现。",
|
resultViewUpdateHint: "从表格接收到本次结果,到 DOM 更新完成或 Canvas 绘制提交;不含 GPU 合成及屏幕实际呈现。",
|
||||||
querySuccess: "查询执行成功",
|
querySuccess: "查询执行成功",
|
||||||
|
|||||||
@@ -1951,8 +1951,30 @@ export default withEnglishFallback({
|
|||||||
serverExecuteTimeUnavailable: "資料庫執行:無法取得",
|
serverExecuteTimeUnavailable: "資料庫執行:無法取得",
|
||||||
serverExecuteTimeHint: "OceanBase SQL Audit EXECUTE_TIME 表示伺服端執行計畫的耗時。JDBC 游標顯示原語句結束後的樣本;獨立分頁 SQL 僅在各頁均有樣本時顯示總和。與執行耗時和等待耗時範圍重疊。游標尚未結束或稽核資料無法讀取、關聯時無法取得。",
|
serverExecuteTimeHint: "OceanBase SQL Audit EXECUTE_TIME 表示伺服端執行計畫的耗時。JDBC 游標顯示原語句結束後的樣本;獨立分頁 SQL 僅在各頁均有樣本時顯示總和。與執行耗時和等待耗時範圍重疊。游標尚未結束或稽核資料無法讀取、關聯時無法取得。",
|
||||||
agentExecuteTimeHint: "從設定 schema 到 JDBC execute 返回的 Agent 耗時;不含讀取資料列,並非資料庫伺服端純執行時間。",
|
agentExecuteTimeHint: "從設定 schema 到 JDBC execute 返回的 Agent 耗時;不含讀取資料列,並非資料庫伺服端純執行時間。",
|
||||||
|
timingNumber: "序號",
|
||||||
|
timingStage: "階段",
|
||||||
|
timingDuration: "耗時",
|
||||||
|
timingDetails: "查詢耗時詳情",
|
||||||
|
timingUnavailable: "未採集",
|
||||||
|
timingPages: "累計 {count} 次請求;表格更新為最近一次。",
|
||||||
|
timingPhase_request: "請求等待",
|
||||||
|
timingPhase_prepare: "請求準備(不計入等待)",
|
||||||
|
timingPhase_core_lock: "等待執行鎖",
|
||||||
|
timingPhase_pool_acquire: "取得連線",
|
||||||
|
timingPhase_session_prepare: "準備工作階段",
|
||||||
|
timingPhase_pool_release: "歸還連線",
|
||||||
|
timingPhase_schema: "設定 schema",
|
||||||
|
timingPhase_statement_prepare: "準備語句",
|
||||||
|
timingPhase_jdbc_execute: "執行 SQL(JDBC)",
|
||||||
|
timingPhase_metadata: "讀取欄位資訊",
|
||||||
|
timingPhase_fetch: "讀取結果並關閉游標",
|
||||||
|
timingPhase_agent_other: "Agent 其他處理(差額)",
|
||||||
|
timingPhase_remainder: "其他等待(差額,非網路耗時)",
|
||||||
|
timingPhase_result: "結果整理(不計入等待)",
|
||||||
|
timingBackend: "後端回報耗時(與步驟重疊)",
|
||||||
|
timingPhase_render: "表格更新(不計入等待)",
|
||||||
clientRequestWait: "等待耗時:{ms} 毫秒",
|
clientRequestWait: "等待耗時:{ms} 毫秒",
|
||||||
clientRequestWaitHint: "桌面端送出查詢請求至收到完整結果的耗時,包含讀取資料列、可用時的伺服端稽核查詢與傳輸,不含 SQL 準備與表格呈現;載入多頁時累加各頁等待時間。",
|
clientRequestWaitHint: "桌面端送出查詢請求至收到完整結果的耗時,包含後端處理、讀取資料列與傳輸,不含請求準備與表格呈現;載入多頁時累加各頁等待時間。",
|
||||||
resultViewUpdate: "表格更新:{ms} 毫秒",
|
resultViewUpdate: "表格更新:{ms} 毫秒",
|
||||||
resultViewUpdateHint: "從表格接收到本次結果,到 DOM 更新完成或 Canvas 繪製提交;不含 GPU 合成及螢幕實際呈現。",
|
resultViewUpdateHint: "從表格接收到本次結果,到 DOM 更新完成或 Canvas 繪製提交;不含 GPU 合成及螢幕實際呈現。",
|
||||||
querySuccess: "查詢執行成功",
|
querySuccess: "查詢執行成功",
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { afterEach, expect, it, vi } from "vitest";
|
||||||
|
import { createQueryRequestTiming } from "../queryRequestTiming";
|
||||||
|
|
||||||
|
afterEach(() => vi.restoreAllMocks());
|
||||||
|
|
||||||
|
it("separates preparation, backend waits and local conversion across multiple calls", async () => {
|
||||||
|
let now = 100;
|
||||||
|
vi.spyOn(performance, "now").mockImplementation(() => now);
|
||||||
|
const timing = createQueryRequestTiming(80);
|
||||||
|
const value = await timing.run(async () => {
|
||||||
|
now = 130;
|
||||||
|
return "result";
|
||||||
|
});
|
||||||
|
expect(value).toBe("result");
|
||||||
|
now = 140;
|
||||||
|
await timing.run(async () => {
|
||||||
|
now = 160;
|
||||||
|
});
|
||||||
|
now = 165;
|
||||||
|
const result = { columns: [], rows: [], affected_rows: 0, execution_time_ms: 99 };
|
||||||
|
expect(timing.finish(result)).toMatchObject({ client_prepare_ms: 20, client_request_wait_ms: 50, client_result_ms: 15, timing_page_count: 2, execution_time_ms: 99 });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not invent request timings for a local command and propagates failures without replay", async () => {
|
||||||
|
const result = { columns: [], rows: [], affected_rows: 0, execution_time_ms: 0 };
|
||||||
|
expect(createQueryRequestTiming(0).finish(result)).not.toHaveProperty("client_request_wait_ms");
|
||||||
|
const call = vi.fn().mockRejectedValue(new Error("query failed"));
|
||||||
|
await expect(createQueryRequestTiming(0).run(call)).rejects.toThrow("query failed");
|
||||||
|
expect(call).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
@@ -17,6 +17,18 @@ function backend(name: ResultCacheBackend["name"], overrides: Partial<ResultCach
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("tab result cache statement execution metadata", () => {
|
describe("tab result cache statement execution metadata", () => {
|
||||||
|
it("retains timing details for active, array and historical results through cache restore", async () => {
|
||||||
|
const { buildTabResultSnapshot } = await import("@/lib/tabs/tabResultCache");
|
||||||
|
const timing = { query_timings_ms: { agent_total: 40, pool_acquire: 20, pool_release: 2 }, client_prepare_ms: 3, client_result_ms: 4, timing_page_count: 2 };
|
||||||
|
const result = { columns: ["N"], rows: [[1]], affected_rows: 0, execution_time_ms: 50, ...timing };
|
||||||
|
const tab = { result, results: [result], resultRuns: [{ id: "timed-run", title: "Run", sequence: 1, sql: "SELECT 1", createdAt: 1, result, results: [result] }] };
|
||||||
|
const snapshot = buildTabResultSnapshot(tab as Parameters<typeof buildTabResultSnapshot>[0])!;
|
||||||
|
expect(snapshot.result?.query_timings_ms).not.toBe(result.query_timings_ms);
|
||||||
|
const restored = decodeTabResultSnapshot(encodeTabResultSnapshot(snapshot));
|
||||||
|
for (const value of [restored.result, restored.results?.[0], restored.resultRuns?.[0].result, restored.resultRuns?.[0].results?.[0]]) {
|
||||||
|
expect(value).toMatchObject({ rows: [[1]], ...timing });
|
||||||
|
}
|
||||||
|
});
|
||||||
it("selects one authoritative backend before fallback", () => {
|
it("selects one authoritative backend before fallback", () => {
|
||||||
expect(resultCacheBackendOrder(true)).toEqual(["runtime", "indexed-db"]);
|
expect(resultCacheBackendOrder(true)).toEqual(["runtime", "indexed-db"]);
|
||||||
expect(resultCacheBackendOrder(false)).toEqual(["indexed-db", "runtime"]);
|
expect(resultCacheBackendOrder(false)).toEqual(["indexed-db", "runtime"]);
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import type { QueryResult } from "@/types/database";
|
||||||
|
|
||||||
|
/** Local command timing; run wraps only backend calls, never result conversion. */
|
||||||
|
export function createQueryRequestTiming(prepareStartedAt: number) {
|
||||||
|
let firstRequestAt: number | undefined;
|
||||||
|
let waitMs = 0;
|
||||||
|
let requests = 0;
|
||||||
|
return {
|
||||||
|
async run<T, A extends unknown[]>(request: (...args: A) => Promise<T>, ...args: A): Promise<T> {
|
||||||
|
const startedAt = performance.now();
|
||||||
|
firstRequestAt ??= startedAt;
|
||||||
|
requests += 1;
|
||||||
|
try {
|
||||||
|
return await request(...args);
|
||||||
|
} finally {
|
||||||
|
waitMs += Math.max(0, performance.now() - startedAt);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
finish<T extends QueryResult>(result: T): T {
|
||||||
|
if (firstRequestAt === undefined || result.execution_error) return result;
|
||||||
|
result.client_prepare_ms = Math.max(0, firstRequestAt - prepareStartedAt);
|
||||||
|
result.client_request_wait_ms = waitMs;
|
||||||
|
result.client_result_ms = Math.max(0, performance.now() - firstRequestAt - waitMs);
|
||||||
|
result.timing_page_count = requests;
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -71,6 +71,10 @@ interface ColumnarQueryResult {
|
|||||||
execution_time_ms: number;
|
execution_time_ms: number;
|
||||||
server_execute_time_us?: number;
|
server_execute_time_us?: number;
|
||||||
client_request_wait_ms?: number;
|
client_request_wait_ms?: number;
|
||||||
|
query_timings_ms?: QueryResult["query_timings_ms"];
|
||||||
|
client_prepare_ms?: number;
|
||||||
|
client_result_ms?: number;
|
||||||
|
timing_page_count?: number;
|
||||||
truncated?: boolean;
|
truncated?: boolean;
|
||||||
has_more?: boolean;
|
has_more?: boolean;
|
||||||
sourceLabel?: string;
|
sourceLabel?: string;
|
||||||
@@ -361,6 +365,10 @@ function stripSessionIds(result: QueryResult | undefined): QueryResult | undefin
|
|||||||
execution_time_ms: result.execution_time_ms,
|
execution_time_ms: result.execution_time_ms,
|
||||||
server_execute_time_us: result.server_execute_time_us,
|
server_execute_time_us: result.server_execute_time_us,
|
||||||
client_request_wait_ms: result.client_request_wait_ms,
|
client_request_wait_ms: result.client_request_wait_ms,
|
||||||
|
query_timings_ms: result.query_timings_ms ? { ...result.query_timings_ms } : undefined,
|
||||||
|
client_prepare_ms: result.client_prepare_ms,
|
||||||
|
client_result_ms: result.client_result_ms,
|
||||||
|
timing_page_count: result.timing_page_count,
|
||||||
truncated: result.truncated,
|
truncated: result.truncated,
|
||||||
session_id: undefined,
|
session_id: undefined,
|
||||||
has_more: result.has_more,
|
has_more: result.has_more,
|
||||||
@@ -420,6 +428,10 @@ function toColumnarResult(result: QueryResult | undefined): ColumnarQueryResult
|
|||||||
execution_time_ms: result.execution_time_ms,
|
execution_time_ms: result.execution_time_ms,
|
||||||
server_execute_time_us: result.server_execute_time_us,
|
server_execute_time_us: result.server_execute_time_us,
|
||||||
client_request_wait_ms: result.client_request_wait_ms,
|
client_request_wait_ms: result.client_request_wait_ms,
|
||||||
|
query_timings_ms: result.query_timings_ms ? { ...result.query_timings_ms } : undefined,
|
||||||
|
client_prepare_ms: result.client_prepare_ms,
|
||||||
|
client_result_ms: result.client_result_ms,
|
||||||
|
timing_page_count: result.timing_page_count,
|
||||||
truncated: result.truncated,
|
truncated: result.truncated,
|
||||||
has_more: result.has_more,
|
has_more: result.has_more,
|
||||||
sourceLabel: result.sourceLabel,
|
sourceLabel: result.sourceLabel,
|
||||||
@@ -451,6 +463,10 @@ function fromColumnarResult(result: ColumnarQueryResult | undefined): QueryResul
|
|||||||
execution_time_ms: result.execution_time_ms,
|
execution_time_ms: result.execution_time_ms,
|
||||||
server_execute_time_us: result.server_execute_time_us,
|
server_execute_time_us: result.server_execute_time_us,
|
||||||
client_request_wait_ms: result.client_request_wait_ms,
|
client_request_wait_ms: result.client_request_wait_ms,
|
||||||
|
query_timings_ms: result.query_timings_ms ? { ...result.query_timings_ms } : undefined,
|
||||||
|
client_prepare_ms: result.client_prepare_ms,
|
||||||
|
client_result_ms: result.client_result_ms,
|
||||||
|
timing_page_count: result.timing_page_count,
|
||||||
truncated: result.truncated,
|
truncated: result.truncated,
|
||||||
session_id: undefined,
|
session_id: undefined,
|
||||||
has_more: result.has_more,
|
has_more: result.has_more,
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ describe("queryStore MongoDB execution summary", () => {
|
|||||||
|
|
||||||
const tab = store.tabs.find((item) => item.id === tabId)!;
|
const tab = store.tabs.find((item) => item.id === tabId)!;
|
||||||
expect(tab.result?.rows).toHaveLength(3);
|
expect(tab.result?.rows).toHaveLength(3);
|
||||||
|
expect(tab.result?.client_request_wait_ms).toEqual(expect.any(Number));
|
||||||
|
expect(tab.result?.client_result_ms).toEqual(expect.any(Number));
|
||||||
|
expect(tab.result?.timing_page_count).toBe(1);
|
||||||
expect(tab.batchSqlExecution).toMatchObject({
|
expect(tab.batchSqlExecution).toMatchObject({
|
||||||
total: 1,
|
total: 1,
|
||||||
completed: 1,
|
completed: 1,
|
||||||
|
|||||||
@@ -113,6 +113,24 @@ function structuredSqlError(detail = "duplicate key") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("queryStore multi-statement errors", () => {
|
describe("queryStore multi-statement errors", () => {
|
||||||
|
it.each(["oracle", "oceanbase-oracle"])("preserves the intended offset timing scope for %s", async (dbType) => {
|
||||||
|
mocks.getConnectionConfig.mockReturnValue({ id: "timing-offset", name: "Timing", db_type: dbType, database: "APP", query_timeout_secs: 30 });
|
||||||
|
mocks.analyzeEditableQueryEditability.mockResolvedValue({ editable: false, reason: "complex-query" });
|
||||||
|
mocks.prepareQueryPaginationExecutionPlan.mockImplementation(async (options) => ({ sqlToExecute: options.sql, pageSql: options.sql, pageLimit: options.pagination.limit, pageOffset: options.pagination.offset, countSql: undefined, useAgentResultSession: true }));
|
||||||
|
const timed = true;
|
||||||
|
mocks.executeMulti
|
||||||
|
.mockResolvedValueOnce([{ columns: ["VALUE"], rows: [[1], [2]], affected_rows: 0, execution_time_ms: 12, session_id: "offset-page", has_more: true, ...(timed ? { query_timings_ms: { agent_total: 10 } } : {}) }])
|
||||||
|
.mockResolvedValueOnce([{ columns: ["VALUE"], rows: [[3], [4]], affected_rows: 0, execution_time_ms: 34, has_more: false, ...(timed ? { query_timings_ms: { agent_total: 30 } } : {}) }]);
|
||||||
|
const { useQueryStore } = await import("@/stores/queryStore");
|
||||||
|
const store = useQueryStore();
|
||||||
|
const tabId = store.createTab("timing-offset", "APP", "Query", "query", "APP");
|
||||||
|
await store.executeTabSql(tabId, "SELECT VALUE FROM T", { pagination: { limit: 2, offset: 2 } });
|
||||||
|
const result = store.tabs.find((item) => item.id === tabId)!.result!;
|
||||||
|
expect(result.rows).toEqual([[3], [4]]);
|
||||||
|
expect(result.execution_time_ms).toBe(timed ? 46 : 34);
|
||||||
|
expect(result.query_timings_ms).toEqual(timed ? { agent_total: 40 } : undefined);
|
||||||
|
expect(result.timing_page_count).toBe(timed ? 2 : undefined);
|
||||||
|
});
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
mocks.defaultAutoKeepResults = false;
|
mocks.defaultAutoKeepResults = false;
|
||||||
@@ -160,7 +178,7 @@ describe("queryStore multi-statement errors", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each(["oceanbase-oracle", "mysql"] as const)("measures complete result wait only for a single %s query result", async (databaseType) => {
|
it.each(["oceanbase-oracle", "oracle", "mysql", "postgres", "sqlite", "sqlserver", "db2"] as const)("measures complete result wait only for a single %s query result", async (databaseType) => {
|
||||||
mocks.getConnectionConfig.mockReturnValue({
|
mocks.getConnectionConfig.mockReturnValue({
|
||||||
id: "timing-1",
|
id: "timing-1",
|
||||||
name: "Timing",
|
name: "Timing",
|
||||||
@@ -183,7 +201,7 @@ describe("queryStore multi-statement errors", () => {
|
|||||||
await execution;
|
await execution;
|
||||||
const result = store.tabs.find((item) => item.id === tabId)?.result;
|
const result = store.tabs.find((item) => item.id === tabId)?.result;
|
||||||
expect(result?.execution_time_ms).toBe(12);
|
expect(result?.execution_time_ms).toBe(12);
|
||||||
expect(result?.client_request_wait_ms).toBe(databaseType === "oceanbase-oracle" ? 45 : undefined);
|
expect(result?.client_request_wait_ms).toBe(45);
|
||||||
} finally {
|
} finally {
|
||||||
vi.restoreAllMocks();
|
vi.restoreAllMocks();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { createQueryRequestTiming } from "@/lib/queryRequestTiming";
|
||||||
import { UPDATE_RESTORE_KEY, assertUpdateAllowsInteraction } from "@/lib/app/updatePreparation";
|
import { UPDATE_RESTORE_KEY, assertUpdateAllowsInteraction } from "@/lib/app/updatePreparation";
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { isRedisMonitorCommand, startRedisMonitor } from "@/lib/redis/redisMonitor";
|
import { isRedisMonitorCommand, startRedisMonitor } from "@/lib/redis/redisMonitor";
|
||||||
@@ -346,6 +347,11 @@ export function appendQueryResultSegment(previous: QueryResult, segment: QueryRe
|
|||||||
// Independent page SQLs need every page sampled before a total is shown.
|
// Independent page SQLs need every page sampled before a total is shown.
|
||||||
server_execute_time_us: previous.session_id ? segment.server_execute_time_us : previous.server_execute_time_us !== undefined && segment.server_execute_time_us !== undefined ? previous.server_execute_time_us + segment.server_execute_time_us : undefined,
|
server_execute_time_us: previous.session_id ? segment.server_execute_time_us : previous.server_execute_time_us !== undefined && segment.server_execute_time_us !== undefined ? previous.server_execute_time_us + segment.server_execute_time_us : undefined,
|
||||||
client_request_wait_ms: previous.client_request_wait_ms !== undefined && segment.client_request_wait_ms !== undefined ? previous.client_request_wait_ms + segment.client_request_wait_ms : undefined,
|
client_request_wait_ms: previous.client_request_wait_ms !== undefined && segment.client_request_wait_ms !== undefined ? previous.client_request_wait_ms + segment.client_request_wait_ms : undefined,
|
||||||
|
query_timings_ms:
|
||||||
|
previous.query_timings_ms && segment.query_timings_ms ? Object.fromEntries([...new Set([...Object.keys(previous.query_timings_ms), ...Object.keys(segment.query_timings_ms)])].map((key) => [key, (previous.query_timings_ms![key] ?? 0) + (segment.query_timings_ms![key] ?? 0)])) : undefined,
|
||||||
|
client_prepare_ms: previous.client_prepare_ms !== undefined && segment.client_prepare_ms !== undefined ? previous.client_prepare_ms + segment.client_prepare_ms : undefined,
|
||||||
|
client_result_ms: previous.client_result_ms !== undefined && segment.client_result_ms !== undefined ? previous.client_result_ms + segment.client_result_ms : undefined,
|
||||||
|
timing_page_count: (previous.timing_page_count ?? 1) + (segment.timing_page_count ?? 1),
|
||||||
has_more: previous.rows.length + appendedRowCount >= maxRows ? false : segment.has_more,
|
has_more: previous.rows.length + appendedRowCount >= maxRows ? false : segment.has_more,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -6906,11 +6912,12 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
const skipSafety = options?.skipRedisSafetyCheck;
|
const skipSafety = options?.skipRedisSafetyCheck;
|
||||||
let hadMutatingCommand = false;
|
let hadMutatingCommand = false;
|
||||||
for (const [commandIndex, command] of commands.entries()) {
|
for (const [commandIndex, command] of commands.entries()) {
|
||||||
|
const commandTiming = createQueryRequestTiming(commandIndex === 0 ? startedAt : performance.now());
|
||||||
const commandRange = commandRanges[commandIndex];
|
const commandRange = commandRanges[commandIndex];
|
||||||
const sourceRange = commandRange && options?.sourceOffset !== undefined ? { from: options.sourceOffset + commandRange.from, to: options.sourceOffset + commandRange.to } : undefined;
|
const sourceRange = commandRange && options?.sourceOffset !== undefined ? { from: options.sourceOffset + commandRange.from, to: options.sourceOffset + commandRange.to } : undefined;
|
||||||
try {
|
try {
|
||||||
const result = await api.redisExecuteCommand(executionConnectionId, currentDb, command, skipSafety);
|
const result = await commandTiming.run(api.redisExecuteCommand, executionConnectionId, currentDb, command, skipSafety);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateQueryResultSource(redisCommandResultToQueryResult(result.value, performance.now() - startedAt, command), command, undefined, undefined, sourceRange)));
|
allResults.push(commandTiming.finish(markQueryResultRowsRaw(annotateQueryResultSource(redisCommandResultToQueryResult(result.value, performance.now() - startedAt, command), command, undefined, undefined, sourceRange))));
|
||||||
// Track db switches from SELECT N so later commands in the same batch run on the right db.
|
// Track db switches from SELECT N so later commands in the same batch run on the right db.
|
||||||
currentDb = nextRedisCommandDb(currentDb, command, result.value);
|
currentDb = nextRedisCommandDb(currentDb, command, result.value);
|
||||||
// Write commands (SET/DEL/...) mutate the key set — drop the cached key-name completion
|
// Write commands (SET/DEL/...) mutate the key set — drop the cached key-name completion
|
||||||
@@ -6986,7 +6993,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
let mongoEditTarget: QueryTab["mongoEditTarget"] | undefined;
|
let mongoEditTarget: QueryTab["mongoEditTarget"] | undefined;
|
||||||
let mongoFindPageState: { pageLimit: number; pageOffset: number; total: number; totalIsExact: boolean } | undefined;
|
let mongoFindPageState: { pageLimit: number; pageOffset: number; total: number; totalIsExact: boolean } | undefined;
|
||||||
|
|
||||||
for (const parsedCommand of mongoCommands) {
|
for (const [commandIndex, parsedCommand] of mongoCommands.entries()) {
|
||||||
let mongoCommand = parsedCommand.command;
|
let mongoCommand = parsedCommand.command;
|
||||||
// db.getSiblingDB("x").<command>: target that database for this command only.
|
// db.getSiblingDB("x").<command>: target that database for this command only.
|
||||||
const sessionDatabase = currentDatabase;
|
const sessionDatabase = currentDatabase;
|
||||||
@@ -6998,6 +7005,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
const sourceStatement = parsedCommand.text;
|
const sourceStatement = parsedCommand.text;
|
||||||
const sourceRange = options?.sourceOffset === undefined ? undefined : { from: options.sourceOffset + parsedCommand.from, to: options.sourceOffset + parsedCommand.to };
|
const sourceRange = options?.sourceOffset === undefined ? undefined : { from: options.sourceOffset + parsedCommand.from, to: options.sourceOffset + parsedCommand.to };
|
||||||
const commandStartedAt = performance.now();
|
const commandStartedAt = performance.now();
|
||||||
|
const commandTiming = createQueryRequestTiming(commandIndex === 0 ? startedAt : commandStartedAt);
|
||||||
const annotateMongoResult = (result: QueryResult): QueryResult => {
|
const annotateMongoResult = (result: QueryResult): QueryResult => {
|
||||||
const annotated = annotateQueryResultSource(result, sourceStatement, undefined, undefined, sourceRange);
|
const annotated = annotateQueryResultSource(result, sourceStatement, undefined, undefined, sourceRange);
|
||||||
if ("collection" in mongoCommand) {
|
if ("collection" in mongoCommand) {
|
||||||
@@ -7005,7 +7013,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
annotated.sourceName = mongoCommand.collection;
|
annotated.sourceName = mongoCommand.collection;
|
||||||
annotated.sourceLabel = currentDatabase ? `${currentDatabase}.${mongoCommand.collection}` : mongoCommand.collection;
|
annotated.sourceLabel = currentDatabase ? `${currentDatabase}.${mongoCommand.collection}` : mongoCommand.collection;
|
||||||
}
|
}
|
||||||
return annotated;
|
return commandTiming.finish(annotated);
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
// The frontend parser remains responsible for editor ranges, while
|
// The frontend parser remains responsible for editor ranges, while
|
||||||
@@ -7029,7 +7037,19 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
if (!pagePlan) throw new Error(describeMongoCommandParseFailure(sourceStatement));
|
if (!pagePlan) throw new Error(describeMongoCommandParseFailure(sourceStatement));
|
||||||
// A stale request can point past an explicit .limit() bound. Keep
|
// A stale request can point past an explicit .limit() bound. Keep
|
||||||
// the backend call bounded so limit(0) cannot become unbounded.
|
// the backend call bounded so limit(0) cannot become unbounded.
|
||||||
const result = await api.mongoFindDocuments(executionConnectionId, currentDatabase, mongoCommand.collection, pagePlan.requestSkip, Math.max(1, pagePlan.requestLimit), mongoCommand.filter, mongoCommand.projection, mongoCommand.sort, mongoCommand.collation, executionId);
|
const result = await commandTiming.run(
|
||||||
|
api.mongoFindDocuments,
|
||||||
|
executionConnectionId,
|
||||||
|
currentDatabase,
|
||||||
|
mongoCommand.collection,
|
||||||
|
pagePlan.requestSkip,
|
||||||
|
Math.max(1, pagePlan.requestLimit),
|
||||||
|
mongoCommand.filter,
|
||||||
|
mongoCommand.projection,
|
||||||
|
mongoCommand.sort,
|
||||||
|
mongoCommand.collation,
|
||||||
|
executionId,
|
||||||
|
);
|
||||||
const documents = pagePlan.requestLimit === 0 ? [] : result.documents;
|
const documents = pagePlan.requestLimit === 0 ? [] : result.documents;
|
||||||
const extendedDocuments = pagePlan.requestLimit === 0 ? [] : result.extended_documents;
|
const extendedDocuments = pagePlan.requestLimit === 0 ? [] : result.extended_documents;
|
||||||
const totalIsExact = result.total_is_exact !== false;
|
const totalIsExact = result.total_is_exact !== false;
|
||||||
@@ -7057,7 +7077,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
}
|
}
|
||||||
case "findOne": {
|
case "findOne": {
|
||||||
queryExecutionLog("info", "mongo-find-one:start", { traceId, collection: mongoCommand.collection, database: currentDatabase });
|
queryExecutionLog("info", "mongo-find-one:start", { traceId, collection: mongoCommand.collection, database: currentDatabase });
|
||||||
const result = await api.mongoFindOne(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.projection, mongoCommand.options, executionId);
|
const result = await commandTiming.run(api.mongoFindOne, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.projection, mongoCommand.options, executionId);
|
||||||
const queryResult = markQueryResultRowsRaw(annotateMongoResult(mongoDocumentsToQueryResult(result.documents, performance.now() - commandStartedAt, result.total, result.extended_documents, result.total_is_exact !== false)));
|
const queryResult = markQueryResultRowsRaw(annotateMongoResult(mongoDocumentsToQueryResult(result.documents, performance.now() - commandStartedAt, result.total, result.extended_documents, result.total_is_exact !== false)));
|
||||||
allResults.push(queryResult);
|
allResults.push(queryResult);
|
||||||
mongoEditTarget = mongoCommands.length === 1 && !mongoCommand.projection && queryResult.columns.includes("_id") ? { collection: mongoCommand.collection, idColumn: "_id" } : undefined;
|
mongoEditTarget = mongoCommands.length === 1 && !mongoCommand.projection && queryResult.columns.includes("_id") ? { collection: mongoCommand.collection, idColumn: "_id" } : undefined;
|
||||||
@@ -7072,7 +7092,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
}
|
}
|
||||||
case "version": {
|
case "version": {
|
||||||
queryExecutionLog("info", "mongo-version:start", { traceId, database: currentDatabase });
|
queryExecutionLog("info", "mongo-version:start", { traceId, database: currentDatabase });
|
||||||
const version = await api.mongoServerVersion(executionConnectionId, currentDatabase, executionId);
|
const version = await commandTiming.run(api.mongoServerVersion, executionConnectionId, currentDatabase, executionId);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoVersionToQueryResult(version, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoVersionToQueryResult(version, performance.now() - commandStartedAt))));
|
||||||
mongoEditTarget = undefined;
|
mongoEditTarget = undefined;
|
||||||
queryExecutionLog("info", "mongo-version:done", {
|
queryExecutionLog("info", "mongo-version:done", {
|
||||||
@@ -7085,7 +7105,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
}
|
}
|
||||||
case "showDatabases": {
|
case "showDatabases": {
|
||||||
queryExecutionLog("info", "mongo-show-databases:start", { traceId });
|
queryExecutionLog("info", "mongo-show-databases:start", { traceId });
|
||||||
const result = await api.mongoRunCommand(executionConnectionId, "admin", '{"listDatabases":1}', executionId);
|
const result = await commandTiming.run(api.mongoRunCommand, executionConnectionId, "admin", '{"listDatabases":1}', executionId);
|
||||||
const queryResult = mongoDatabasesToQueryResult(result.documents, performance.now() - commandStartedAt, agentProtocolQueryResultMaxRows(mongoResultMaxRows));
|
const queryResult = mongoDatabasesToQueryResult(result.documents, performance.now() - commandStartedAt, agentProtocolQueryResultMaxRows(mongoResultMaxRows));
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(queryResult)));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(queryResult)));
|
||||||
mongoEditTarget = undefined;
|
mongoEditTarget = undefined;
|
||||||
@@ -7098,7 +7118,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
}
|
}
|
||||||
case "countDocuments": {
|
case "countDocuments": {
|
||||||
queryExecutionLog("info", "mongo-count:start", { traceId, collection: mongoCommand.collection, database: currentDatabase });
|
queryExecutionLog("info", "mongo-count:start", { traceId, collection: mongoCommand.collection, database: currentDatabase });
|
||||||
const total = await api.mongoCountDocuments(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.mode, executionId);
|
const total = await commandTiming.run(api.mongoCountDocuments, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.mode, executionId);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoCountToQueryResult(total, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoCountToQueryResult(total, performance.now() - commandStartedAt))));
|
||||||
mongoEditTarget = undefined;
|
mongoEditTarget = undefined;
|
||||||
queryExecutionLog("info", "mongo-count:done", {
|
queryExecutionLog("info", "mongo-count:done", {
|
||||||
@@ -7112,7 +7132,8 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
}
|
}
|
||||||
case "findExplain": {
|
case "findExplain": {
|
||||||
queryExecutionLog("info", "mongo-explain:start", { traceId, collection: mongoCommand.collection, database: currentDatabase });
|
queryExecutionLog("info", "mongo-explain:start", { traceId, collection: mongoCommand.collection, database: currentDatabase });
|
||||||
const plan = await api.mongoExplainFind(
|
const plan = await commandTiming.run(
|
||||||
|
api.mongoExplainFind,
|
||||||
executionConnectionId,
|
executionConnectionId,
|
||||||
currentDatabase,
|
currentDatabase,
|
||||||
mongoCommand.collection,
|
mongoCommand.collection,
|
||||||
@@ -7139,7 +7160,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
}
|
}
|
||||||
queryExecutionLog("info", "mongo-aggregate:start", { traceId, collection: mongoCommand.collection, database: currentDatabase });
|
queryExecutionLog("info", "mongo-aggregate:start", { traceId, collection: mongoCommand.collection, database: currentDatabase });
|
||||||
const aggregateMaxRows = normalizeResultPageSize(pageLimit ?? options?.pagination?.limit ?? settingsStore.editorSettings.pageSize);
|
const aggregateMaxRows = normalizeResultPageSize(pageLimit ?? options?.pagination?.limit ?? settingsStore.editorSettings.pageSize);
|
||||||
const result = await api.mongoAggregateDocuments(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.pipeline, aggregateMaxRows, mongoCommand.options, executionId);
|
const result = await commandTiming.run(api.mongoAggregateDocuments, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.pipeline, aggregateMaxRows, mongoCommand.options, executionId);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoDocumentsToQueryResult(result.documents, performance.now() - commandStartedAt, result.total, result.extended_documents, result.total_is_exact !== false))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoDocumentsToQueryResult(result.documents, performance.now() - commandStartedAt, result.total, result.extended_documents, result.total_is_exact !== false))));
|
||||||
mongoEditTarget = undefined;
|
mongoEditTarget = undefined;
|
||||||
queryExecutionLog("info", "mongo-aggregate:done", {
|
queryExecutionLog("info", "mongo-aggregate:done", {
|
||||||
@@ -7154,7 +7175,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
}
|
}
|
||||||
case "distinct": {
|
case "distinct": {
|
||||||
queryExecutionLog("info", "mongo-distinct:start", { traceId, collection: mongoCommand.collection, database: currentDatabase, field: mongoCommand.field });
|
queryExecutionLog("info", "mongo-distinct:start", { traceId, collection: mongoCommand.collection, database: currentDatabase, field: mongoCommand.field });
|
||||||
const result = await api.mongoDistinct(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.field, mongoCommand.filter, executionId);
|
const result = await commandTiming.run(api.mongoDistinct, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.field, mongoCommand.filter, executionId);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoDistinctToQueryResult(mongoCommand.field, result.documents, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoDistinctToQueryResult(mongoCommand.field, result.documents, performance.now() - commandStartedAt))));
|
||||||
mongoEditTarget = undefined;
|
mongoEditTarget = undefined;
|
||||||
queryExecutionLog("info", "mongo-distinct:done", {
|
queryExecutionLog("info", "mongo-distinct:done", {
|
||||||
@@ -7169,7 +7190,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
}
|
}
|
||||||
case "getIndexes": {
|
case "getIndexes": {
|
||||||
queryExecutionLog("info", "mongo-indexes:start", { traceId, collection: mongoCommand.collection, database: currentDatabase });
|
queryExecutionLog("info", "mongo-indexes:start", { traceId, collection: mongoCommand.collection, database: currentDatabase });
|
||||||
const indexes = await api.listIndexes(executionConnectionId, currentDatabase, "", mongoCommand.collection);
|
const indexes = await commandTiming.run(api.listIndexes, executionConnectionId, currentDatabase, "", mongoCommand.collection);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoIndexesToQueryResult(indexes, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoIndexesToQueryResult(indexes, performance.now() - commandStartedAt))));
|
||||||
mongoEditTarget = undefined;
|
mongoEditTarget = undefined;
|
||||||
queryExecutionLog("info", "mongo-indexes:done", {
|
queryExecutionLog("info", "mongo-indexes:done", {
|
||||||
@@ -7188,7 +7209,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
metric: mongoCommand.metric,
|
metric: mongoCommand.metric,
|
||||||
database: currentDatabase,
|
database: currentDatabase,
|
||||||
});
|
});
|
||||||
const stats = await api.mongoCollectionStats(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.scale, executionId);
|
const stats = await commandTiming.run(api.mongoCollectionStats, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.scale, executionId);
|
||||||
// SAFETY: The backend returns collection statistics as a JSON object; the API type is broader than the converter's record-shaped input.
|
// SAFETY: The backend returns collection statistics as a JSON object; the API type is broader than the converter's record-shaped input.
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoCollectionStatsToQueryResult(mongoCommand.metric, stats as unknown as Record<string, unknown>, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoCollectionStatsToQueryResult(mongoCommand.metric, stats as unknown as Record<string, unknown>, performance.now() - commandStartedAt))));
|
||||||
mongoEditTarget = undefined;
|
mongoEditTarget = undefined;
|
||||||
@@ -7216,10 +7237,10 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
});
|
});
|
||||||
const result =
|
const result =
|
||||||
mongoCommand.kind === "findOneAndUpdate"
|
mongoCommand.kind === "findOneAndUpdate"
|
||||||
? await api.mongoFindOneAndUpdate(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.update, mongoCommand.options)
|
? await commandTiming.run(api.mongoFindOneAndUpdate, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.update, mongoCommand.options)
|
||||||
: mongoCommand.kind === "findOneAndReplace"
|
: mongoCommand.kind === "findOneAndReplace"
|
||||||
? await api.mongoFindOneAndReplace(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.replacement, mongoCommand.options)
|
? await commandTiming.run(api.mongoFindOneAndReplace, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.replacement, mongoCommand.options)
|
||||||
: await api.mongoFindOneAndDelete(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.options);
|
: await commandTiming.run(api.mongoFindOneAndDelete, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.options);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoDocumentsToQueryResult(result.documents, performance.now() - commandStartedAt, result.total, result.extended_documents, result.total_is_exact !== false))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoDocumentsToQueryResult(result.documents, performance.now() - commandStartedAt, result.total, result.extended_documents, result.total_is_exact !== false))));
|
||||||
mongoEditTarget = undefined;
|
mongoEditTarget = undefined;
|
||||||
queryExecutionLog("info", "mongo-find-and-modify:done", {
|
queryExecutionLog("info", "mongo-find-and-modify:done", {
|
||||||
@@ -7241,7 +7262,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
traceId,
|
traceId,
|
||||||
database: currentDatabase,
|
database: currentDatabase,
|
||||||
});
|
});
|
||||||
const result = await api.mongoRunCommand(executionConnectionId, currentDatabase, mongoCommand.commandJson, executionId);
|
const result = await commandTiming.run(api.mongoRunCommand, executionConnectionId, currentDatabase, mongoCommand.commandJson, executionId);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoDocumentsToQueryResult(result.documents, performance.now() - commandStartedAt, result.total, result.extended_documents, result.total_is_exact !== false))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoDocumentsToQueryResult(result.documents, performance.now() - commandStartedAt, result.total, result.extended_documents, result.total_is_exact !== false))));
|
||||||
mongoEditTarget = undefined;
|
mongoEditTarget = undefined;
|
||||||
queryExecutionLog("info", "mongo-run-command:done", {
|
queryExecutionLog("info", "mongo-run-command:done", {
|
||||||
@@ -7275,38 +7296,38 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
});
|
});
|
||||||
mongoEditTarget = undefined;
|
mongoEditTarget = undefined;
|
||||||
if (mongoCommand.kind === "insert") {
|
if (mongoCommand.kind === "insert") {
|
||||||
const result = await api.mongoInsertDocuments(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.docsJson);
|
const result = await commandTiming.run(api.mongoInsertDocuments, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.docsJson);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(result.affected_rows, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(result.affected_rows, performance.now() - commandStartedAt))));
|
||||||
} else if (mongoCommand.kind === "update") {
|
} else if (mongoCommand.kind === "update") {
|
||||||
const result = await api.mongoUpdateDocuments(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.update, mongoCommand.many, mongoCommand.options);
|
const result = await commandTiming.run(api.mongoUpdateDocuments, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.update, mongoCommand.many, mongoCommand.options);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(result.affected_rows, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(result.affected_rows, performance.now() - commandStartedAt))));
|
||||||
} else if (mongoCommand.kind === "bulkWrite") {
|
} else if (mongoCommand.kind === "bulkWrite") {
|
||||||
const result = await api.mongoBulkWrite(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.operations, mongoCommand.options);
|
const result = await commandTiming.run(api.mongoBulkWrite, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.operations, mongoCommand.options);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoBulkWriteToQueryResult(result, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoBulkWriteToQueryResult(result, performance.now() - commandStartedAt))));
|
||||||
} else if (mongoCommand.kind === "replace") {
|
} else if (mongoCommand.kind === "replace") {
|
||||||
const result = await api.mongoReplaceDocument(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.replacement, mongoCommand.options);
|
const result = await commandTiming.run(api.mongoReplaceDocument, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.replacement, mongoCommand.options);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(result.affected_rows, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(result.affected_rows, performance.now() - commandStartedAt))));
|
||||||
} else if (mongoCommand.kind === "createIndex") {
|
} else if (mongoCommand.kind === "createIndex") {
|
||||||
const result = await api.mongoCreateIndex(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.keys, mongoCommand.options);
|
const result = await commandTiming.run(api.mongoCreateIndex, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.keys, mongoCommand.options);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoCreateIndexToQueryResult(result.name, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoCreateIndexToQueryResult(result.name, performance.now() - commandStartedAt))));
|
||||||
} else if (mongoCommand.kind === "createUser") {
|
} else if (mongoCommand.kind === "createUser") {
|
||||||
const result = await api.mongoCreateUser(executionConnectionId, currentDatabase, mongoCommand.userJson, mongoCommand.writeConcernJson);
|
const result = await commandTiming.run(api.mongoCreateUser, executionConnectionId, currentDatabase, mongoCommand.userJson, mongoCommand.writeConcernJson);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(result.affected_rows, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(result.affected_rows, performance.now() - commandStartedAt))));
|
||||||
} else if (mongoCommand.kind === "dropIndex" || mongoCommand.kind === "dropIndexes") {
|
} else if (mongoCommand.kind === "dropIndex" || mongoCommand.kind === "dropIndexes") {
|
||||||
try {
|
try {
|
||||||
const result = await api.mongoDropIndexes(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.kind === "dropIndex" ? mongoCommand.index : mongoCommand.indexes, mongoCommand.kind === "dropIndex");
|
const result = await commandTiming.run(api.mongoDropIndexes, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.kind === "dropIndex" ? mongoCommand.index : mongoCommand.indexes, mongoCommand.kind === "dropIndex");
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoDroppedIndexesToQueryResult(result.dropped_names, performance.now() - commandStartedAt, result.failures))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoDroppedIndexesToQueryResult(result.dropped_names, performance.now() - commandStartedAt, result.failures))));
|
||||||
} finally {
|
} finally {
|
||||||
await refreshLoadedMongoIndexesAfterMutation(executionConnectionId, currentDatabase, mongoCommand.collection, traceId);
|
await refreshLoadedMongoIndexesAfterMutation(executionConnectionId, currentDatabase, mongoCommand.collection, traceId);
|
||||||
}
|
}
|
||||||
} else if (mongoCommand.kind === "renameCollection") {
|
} else if (mongoCommand.kind === "renameCollection") {
|
||||||
await api.mongoRenameCollection(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.newName);
|
await commandTiming.run(api.mongoRenameCollection, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.newName);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoScalarToQueryResult("renamed", `${mongoCommand.collection} -> ${mongoCommand.newName}`, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoScalarToQueryResult("renamed", `${mongoCommand.collection} -> ${mongoCommand.newName}`, performance.now() - commandStartedAt))));
|
||||||
} else if (mongoCommand.kind === "dropCollection") {
|
} else if (mongoCommand.kind === "dropCollection") {
|
||||||
await api.mongoDropCollection(executionConnectionId, currentDatabase, mongoCommand.collection);
|
await commandTiming.run(api.mongoDropCollection, executionConnectionId, currentDatabase, mongoCommand.collection);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(1, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(1, performance.now() - commandStartedAt))));
|
||||||
} else {
|
} else {
|
||||||
const result = await api.mongoDeleteDocuments(executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.many);
|
const result = await commandTiming.run(api.mongoDeleteDocuments, executionConnectionId, currentDatabase, mongoCommand.collection, mongoCommand.filter, mongoCommand.many);
|
||||||
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(result.affected_rows, performance.now() - commandStartedAt))));
|
allResults.push(markQueryResultRowsRaw(annotateMongoResult(mongoWriteToQueryResult(result.affected_rows, performance.now() - commandStartedAt))));
|
||||||
}
|
}
|
||||||
queryExecutionLog("info", "mongo-write:done", {
|
queryExecutionLog("info", "mongo-write:done", {
|
||||||
@@ -7420,15 +7441,16 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
});
|
});
|
||||||
const allResults: QueryResult[] = [];
|
const allResults: QueryResult[] = [];
|
||||||
const continueOnError = continueOnBatchError;
|
const continueOnError = continueOnBatchError;
|
||||||
for (const request of elasticsearchRequests) {
|
for (const [requestIndex, request] of elasticsearchRequests.entries()) {
|
||||||
|
const commandTiming = createQueryRequestTiming(requestIndex === 0 ? startedAt : performance.now());
|
||||||
const current = findExecutionTab(id);
|
const current = findExecutionTab(id);
|
||||||
if (current?.executionId !== executionId) break;
|
if (current?.executionId !== executionId) break;
|
||||||
const sourceRange = options?.sourceOffset === undefined ? undefined : { from: options.sourceOffset + request.from, to: options.sourceOffset + request.to };
|
const sourceRange = options?.sourceOffset === undefined ? undefined : { from: options.sourceOffset + request.from, to: options.sourceOffset + request.to };
|
||||||
try {
|
try {
|
||||||
const result = await api.executeQuery(executionConnectionId, executionDatabase, request.sql, undefined, executionId, {
|
const result = await commandTiming.run(api.executeQuery, executionConnectionId, executionDatabase, request.sql, undefined, executionId, {
|
||||||
timeoutSecs: queryTimeoutSecs,
|
timeoutSecs: queryTimeoutSecs,
|
||||||
});
|
});
|
||||||
allResults.push(markQueryResultRowsRaw(annotateQueryResultSource(result, request.sql, targetDatabase || conn?.database, effectiveDbType, sourceRange)));
|
allResults.push(commandTiming.finish(markQueryResultRowsRaw(annotateQueryResultSource(result, request.sql, targetDatabase || conn?.database, effectiveDbType, sourceRange))));
|
||||||
if (elasticsearchHttpErrorStatus(result) !== undefined && !continueOnError) break;
|
if (elasticsearchHttpErrorStatus(result) !== undefined && !continueOnError) break;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const latest = findExecutionTab(id);
|
const latest = findExecutionTab(id);
|
||||||
@@ -7613,11 +7635,15 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
clientSession: Boolean(executionClientSessionId),
|
clientSession: Boolean(executionClientSessionId),
|
||||||
});
|
});
|
||||||
executionDispatched = true;
|
executionDispatched = true;
|
||||||
if (effectiveDbType === "oceanbase-oracle" && tab.mode === "query") clientRequestStartedAt = performance.now();
|
if (tab.mode === "query") clientRequestStartedAt = performance.now();
|
||||||
if (useAgentResultSession && tab.mode === "query" && typeof pageOffset === "number" && pageOffset > 0 && !options?.pagination?.sessionId && !(tab.batchSqlExecution && tab.batchSqlExecution.total > 1)) {
|
if (useAgentResultSession && tab.mode === "query" && typeof pageOffset === "number" && pageOffset > 0 && !options?.pagination?.sessionId && !(tab.batchSqlExecution && tab.batchSqlExecution.total > 1)) {
|
||||||
return (async () => {
|
return (async () => {
|
||||||
let sessionId: string | undefined;
|
let sessionId: string | undefined;
|
||||||
let skipped = 0;
|
let skipped = 0;
|
||||||
|
let pageCount = 0;
|
||||||
|
let executionMs = 0;
|
||||||
|
let completeTimings = true;
|
||||||
|
const timings: Record<string, number> = {};
|
||||||
while (true) {
|
while (true) {
|
||||||
const pageResults = await api.executeMulti(executionConnectionId, executionDatabase, sqlToExecute, executionSchema, executionId, {
|
const pageResults = await api.executeMulti(executionConnectionId, executionDatabase, sqlToExecute, executionSchema, executionId, {
|
||||||
...executionOptions,
|
...executionOptions,
|
||||||
@@ -7625,10 +7651,17 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
});
|
});
|
||||||
const page = pageResults[0];
|
const page = pageResults[0];
|
||||||
if (!page) return pageResults;
|
if (!page) return pageResults;
|
||||||
|
pageCount += 1;
|
||||||
|
executionMs += page.execution_time_ms;
|
||||||
|
if (!page.query_timings_ms) completeTimings = false;
|
||||||
|
else for (const [key, value] of Object.entries(page.query_timings_ms)) timings[key] = (timings[key] ?? 0) + value;
|
||||||
|
// Offset jumps consume several cursor pages before publication.
|
||||||
|
// Keep their timings as well, without retaining skipped rows.
|
||||||
|
const timingSummary = { query_timings_ms: completeTimings ? { ...timings } : undefined, execution_time_ms: executionMs, timing_page_count: pageCount };
|
||||||
if (skipped + page.rows.length > pageOffset) {
|
if (skipped + page.rows.length > pageOffset) {
|
||||||
const start = pageOffset - skipped;
|
const start = pageOffset - skipped;
|
||||||
const limit = typeof pageLimit === "number" ? pageLimit : page.rows.length - start;
|
const limit = typeof pageLimit === "number" ? pageLimit : page.rows.length - start;
|
||||||
return [{ ...page, rows: page.rows.slice(start, start + limit) }];
|
return [{ ...page, ...timingSummary, rows: page.rows.slice(start, start + limit) }];
|
||||||
}
|
}
|
||||||
skipped += page.rows.length;
|
skipped += page.rows.length;
|
||||||
if (!page.has_more || !page.session_id) {
|
if (!page.has_more || !page.session_id) {
|
||||||
@@ -7637,7 +7670,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
// returning the short page would show the wrong rows.
|
// returning the short page would show the wrong rows.
|
||||||
throw new Error("Result session ended before the requested page offset");
|
throw new Error("Result session ended before the requested page offset");
|
||||||
}
|
}
|
||||||
return [{ ...page, rows: [] }];
|
return [{ ...page, ...timingSummary, rows: [] }];
|
||||||
}
|
}
|
||||||
sessionId = page.session_id;
|
sessionId = page.session_id;
|
||||||
}
|
}
|
||||||
@@ -7686,7 +7719,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
} else {
|
} else {
|
||||||
queryExecutionLog("info", "execute-in-txn:invoke", { traceId, txnSessionId: tab.txnSessionId, elapsed: elapsed() });
|
queryExecutionLog("info", "execute-in-txn:invoke", { traceId, txnSessionId: tab.txnSessionId, elapsed: elapsed() });
|
||||||
executionDispatched = true;
|
executionDispatched = true;
|
||||||
if (effectiveDbType === "oceanbase-oracle" && tab.mode === "query") clientRequestStartedAt = performance.now();
|
if (tab.mode === "query") clientRequestStartedAt = performance.now();
|
||||||
// Only an initial manual execution classifies the user SQL (sticky
|
// Only an initial manual execution classifies the user SQL (sticky
|
||||||
// proven-read-only dialects). A later cursor-page fetch must neither
|
// proven-read-only dialects). A later cursor-page fetch must neither
|
||||||
// set nor clear the sticky bit.
|
// set nor clear the sticky bit.
|
||||||
@@ -7741,8 +7774,11 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
// A single result has an unambiguous request boundary. This includes fetch and
|
// A single result has an unambiguous request boundary. This includes fetch and
|
||||||
// transport, but excludes SQL preparation and the grid's later render work.
|
// transport, but excludes SQL preparation and the grid's later render work.
|
||||||
if (clientRequestStartedAt !== undefined && responseResults.length === 1 && !responseResults[0]?.execution_error) {
|
if (clientRequestStartedAt !== undefined && responseResults.length === 1 && !responseResults[0]?.execution_error) {
|
||||||
responseResults[0]!.client_request_wait_ms = Math.max(0, Math.round(performance.now() - clientRequestStartedAt));
|
responseResults[0]!.client_request_wait_ms = Math.max(0, performance.now() - clientRequestStartedAt);
|
||||||
|
responseResults[0]!.client_prepare_ms = Math.max(0, clientRequestStartedAt - startedAt);
|
||||||
|
responseResults[0]!.timing_page_count ??= 1;
|
||||||
}
|
}
|
||||||
|
const resultProcessingStartedAt = performance.now();
|
||||||
const annotatedResults = annotateQueryResultSources(markQueryResultsRowsRaw(responseResults), queryBaseSql, sourceLabelDatabase, effectiveDbType, options?.sourceOffset, sqlStatementParameterOptions, sqlToExecute, options?.sourceOffset === undefined ? undefined : tab.sql);
|
const annotatedResults = annotateQueryResultSources(markQueryResultsRowsRaw(responseResults), queryBaseSql, sourceLabelDatabase, effectiveDbType, options?.sourceOffset, sqlStatementParameterOptions, sqlToExecute, options?.sourceOffset === undefined ? undefined : tab.sql);
|
||||||
const results = offsetBatchQueryResultIndexes(annotatedResults.results, batchResume?.startStatementIndex ?? 0);
|
const results = offsetBatchQueryResultIndexes(annotatedResults.results, batchResume?.startStatementIndex ?? 0);
|
||||||
if (paginationRowNumberColumn && results.length === 1) {
|
if (paginationRowNumberColumn && results.length === 1) {
|
||||||
@@ -7822,6 +7858,9 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
current.database = mysqlUseDatabase;
|
current.database = mysqlUseDatabase;
|
||||||
current.schema = undefined;
|
current.schema = undefined;
|
||||||
}
|
}
|
||||||
|
if (clientRequestStartedAt !== undefined && results.length === 1 && !results[0]?.execution_error) {
|
||||||
|
results[0]!.client_result_ms = Math.max(0, performance.now() - resultProcessingStartedAt);
|
||||||
|
}
|
||||||
const activeGroupIndex = current.activeResultIndex;
|
const activeGroupIndex = current.activeResultIndex;
|
||||||
const activeGroupResults = current.results;
|
const activeGroupResults = current.results;
|
||||||
const shouldAppendResult = !!options?.appendResult && !!current.result;
|
const shouldAppendResult = !!options?.appendResult && !!current.result;
|
||||||
|
|||||||
@@ -1272,8 +1272,13 @@ export interface QueryResult {
|
|||||||
execution_time_ms: number;
|
execution_time_ms: number;
|
||||||
/** OceanBase SQL Audit EXECUTE_TIME for a completed statement, in microseconds. */
|
/** OceanBase SQL Audit EXECUTE_TIME for a completed statement, in microseconds. */
|
||||||
server_execute_time_us?: number;
|
server_execute_time_us?: number;
|
||||||
/** Desktop wait from query request dispatch to the complete result payload; summed across appended pages. OceanBase Oracle query tabs only. */
|
/** Desktop wait from query request dispatch to the complete result payload; summed across appended pages. Completed query/command requests only. */
|
||||||
client_request_wait_ms?: number;
|
client_request_wait_ms?: number;
|
||||||
|
/** Measured phases; totals overlap. Missing phases were not measured. */
|
||||||
|
query_timings_ms?: Record<string, number>;
|
||||||
|
client_prepare_ms?: number;
|
||||||
|
client_result_ms?: number;
|
||||||
|
timing_page_count?: number;
|
||||||
/** Whether a backend-reported result total is exact. */
|
/** Whether a backend-reported result total is exact. */
|
||||||
total_is_exact?: boolean;
|
total_is_exact?: boolean;
|
||||||
truncated?: boolean;
|
truncated?: boolean;
|
||||||
|
|||||||
@@ -1077,6 +1077,7 @@ mod tests {
|
|||||||
affected_rows: 2,
|
affected_rows: 2,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -1153,6 +1154,7 @@ mod tests {
|
|||||||
affected_rows: 1,
|
affected_rows: 1,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -1922,6 +1922,7 @@ for line in sys.stdin:
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: 1,
|
execution_time_ms: 1,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -7410,6 +7410,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 1,
|
execution_time_ms: 1,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -716,6 +716,7 @@ async fn fetch_table_export_batch(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -10797,6 +10797,7 @@ CREATE TABLE "Other"."prefix""Source"."NAME" ("ID" INT);"#;
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -2175,6 +2175,7 @@ async fn do_execute_typed(
|
|||||||
}
|
}
|
||||||
let cancel_for_agent = cancel_token.clone();
|
let cancel_for_agent = cancel_token.clone();
|
||||||
let result = async move {
|
let result = async move {
|
||||||
|
let lock_started = std::time::Instant::now();
|
||||||
let mut client = match cancel_for_agent.as_ref() {
|
let mut client = match cancel_for_agent.as_ref() {
|
||||||
Some(token) => {
|
Some(token) => {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
@@ -2188,7 +2189,10 @@ async fn do_execute_typed(
|
|||||||
}
|
}
|
||||||
None => client.lock().await,
|
None => client.lock().await,
|
||||||
};
|
};
|
||||||
if let Some(session_id) = options.result_session_id.as_deref() {
|
let lock_ms = lock_started.elapsed().as_secs_f64() * 1000.0;
|
||||||
|
let response: Result<db::QueryResult, AgentCallError> = if let Some(session_id) =
|
||||||
|
options.result_session_id.as_deref()
|
||||||
|
{
|
||||||
let params = agent_fetch_query_page_params(session_id, options.page_size.unwrap_or(MAX_ROWS));
|
let params = agent_fetch_query_page_params(session_id, options.page_size.unwrap_or(MAX_ROWS));
|
||||||
client
|
client
|
||||||
.fetch_query_page_typed_with_timeout_and_cancel(params, rpc_timeout, cancel_for_agent.clone())
|
.fetch_query_page_typed_with_timeout_and_cancel(params, rpc_timeout, cancel_for_agent.clone())
|
||||||
@@ -2203,7 +2207,14 @@ async fn do_execute_typed(
|
|||||||
client
|
client
|
||||||
.execute_query_typed_with_timeout_and_cancel(params, rpc_timeout, cancel_for_agent.clone())
|
.execute_query_typed_with_timeout_and_cancel(params, rpc_timeout, cancel_for_agent.clone())
|
||||||
.await
|
.await
|
||||||
}
|
};
|
||||||
|
response.map(|mut result| {
|
||||||
|
// Older agents have no phase map. Do not imply complete telemetry.
|
||||||
|
if let Some(timings) = result.query_timings_ms.as_mut() {
|
||||||
|
timings.insert("core_lock".into(), lock_ms);
|
||||||
|
}
|
||||||
|
result
|
||||||
|
})
|
||||||
}
|
}
|
||||||
.await
|
.await
|
||||||
.map(|result| truncate_result_with_max_rows(result, max_rows));
|
.map(|result| truncate_result_with_max_rows(result, max_rows));
|
||||||
@@ -4208,6 +4219,7 @@ fn error_query_result(message: String) -> db::QueryResult {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4227,6 +4239,7 @@ fn empty_query_result(execution_time_ms: u128) -> db::QueryResult {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms,
|
execution_time_ms,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4574,6 +4587,7 @@ async fn execute_statements_inner(
|
|||||||
affected_rows: total_affected,
|
affected_rows: total_affected,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5188,6 +5202,7 @@ async fn exec_tx_pg_inner(
|
|||||||
affected_rows: total_affected,
|
affected_rows: total_affected,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5282,6 +5297,7 @@ async fn exec_tx_mysql_inner(
|
|||||||
affected_rows: total_affected,
|
affected_rows: total_affected,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5478,6 +5494,7 @@ async fn exec_tx_sqlite_inner(
|
|||||||
affected_rows: total_affected,
|
affected_rows: total_affected,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5611,6 +5628,7 @@ async fn exec_tx_explicit_inner(
|
|||||||
affected_rows: total_affected,
|
affected_rows: total_affected,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -6614,7 +6632,9 @@ async fn execute_manual_txn_agent_statement(
|
|||||||
execution_schema,
|
execution_schema,
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
|
let lock_started = std::time::Instant::now();
|
||||||
let mut locked = client.lock().await;
|
let mut locked = client.lock().await;
|
||||||
|
let lock_ms = lock_started.elapsed().as_secs_f64() * 1000.0;
|
||||||
let result = match request {
|
let result = match request {
|
||||||
ManualTxnAgentQueryRequest::Execute(params) => {
|
ManualTxnAgentQueryRequest::Execute(params) => {
|
||||||
locked.execute_query_typed_with_timeout::<db::QueryResult>(params, None).await
|
locked.execute_query_typed_with_timeout::<db::QueryResult>(params, None).await
|
||||||
@@ -6627,7 +6647,12 @@ async fn execute_manual_txn_agent_statement(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
result
|
result
|
||||||
.map(|result| truncate_result_with_max_rows(result, Some(row_limit.max(1))))
|
.map(|mut result| {
|
||||||
|
if let Some(timings) = result.query_timings_ms.as_mut() {
|
||||||
|
timings.insert("core_lock".into(), lock_ms);
|
||||||
|
}
|
||||||
|
truncate_result_with_max_rows(result, Some(row_limit.max(1)))
|
||||||
|
})
|
||||||
.map_err(|error| error.into_legacy_string())
|
.map_err(|error| error.into_legacy_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6719,6 +6744,7 @@ async fn execute_manual_txn_postgres_statement(
|
|||||||
affected_rows: affected,
|
affected_rows: affected,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -6754,6 +6780,7 @@ async fn execute_manual_txn_mysql_statement(
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -6786,6 +6813,7 @@ async fn execute_manual_txn_mysql_statement(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -6806,6 +6834,7 @@ async fn execute_manual_txn_mysql_statement(
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -6863,6 +6892,7 @@ pub async fn commit_manual_transaction(state: &AppState, txn_session_id: &str) -
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -6893,6 +6923,7 @@ pub async fn rollback_manual_transaction(state: &AppState, txn_session_id: &str)
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -9109,6 +9140,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 4,
|
execution_time_ms: 4,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -9384,6 +9416,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 1,
|
execution_time_ms: 1,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -10444,6 +10477,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -10470,6 +10504,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -11766,6 +11801,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -11804,6 +11840,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -11872,6 +11909,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -11912,6 +11950,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -11944,6 +11983,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -11983,6 +12023,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -12016,6 +12057,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -1383,6 +1383,7 @@ fn query_result(columns: Vec<String>, rows: Vec<Vec<serde_json::Value>>, affecte
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -3225,6 +3225,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4096,6 +4097,7 @@ done
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4124,6 +4126,7 @@ done
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4149,6 +4152,7 @@ done
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4178,6 +4182,7 @@ done
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4206,6 +4211,7 @@ done
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5177,6 +5183,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 1,
|
execution_time_ms: 1,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5226,6 +5233,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 1,
|
execution_time_ms: 1,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5431,6 +5439,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5450,6 +5459,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5487,6 +5497,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5682,6 +5693,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5788,6 +5800,7 @@ for line in sys.stdin:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -685,6 +685,7 @@ fn execute_change_transaction(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: started_at.elapsed().as_millis(),
|
execution_time_ms: started_at.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -590,6 +590,7 @@ fn limited_query_result(result: ChJsonResult, execution_time_ms: u128, max_rows:
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms,
|
execution_time_ms,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -848,6 +849,7 @@ pub async fn execute_query_with_max_rows(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -363,6 +363,7 @@ fn query_result(
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms,
|
execution_time_ms,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -572,6 +572,7 @@ fn document_query_result(result: DocumentQueryResult, started: Instant) -> Query
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: started.elapsed().as_millis(),
|
execution_time_ms: started.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -591,6 +592,7 @@ fn affected_query_result(affected_rows: u64, started: Instant) -> QueryResult {
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: started.elapsed().as_millis(),
|
execution_time_ms: started.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -2356,6 +2356,7 @@ fn parse_elasticsearch_response_with_sql_parser(
|
|||||||
affected_rows: row_count,
|
affected_rows: row_count,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -2383,6 +2384,7 @@ fn parse_elasticsearch_response_with_sql_parser(
|
|||||||
affected_rows: row_count,
|
affected_rows: row_count,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -2556,6 +2558,7 @@ fn raw_json_response_result(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -2624,6 +2627,7 @@ fn parse_elasticsearch_rest_response_with_sql_parser(
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -3134,6 +3138,7 @@ pub fn parse_tabular_sql_response(
|
|||||||
.unwrap_or(rows.len() as u64),
|
.unwrap_or(rows.len() as u64),
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: body.get("cursor").and_then(|cursor| cursor.as_str()).map(str::to_string),
|
session_id: body.get("cursor").and_then(|cursor| cursor.as_str()).map(str::to_string),
|
||||||
has_more: body.get("cursor").and_then(|cursor| cursor.as_str()).is_some(),
|
has_more: body.get("cursor").and_then(|cursor| cursor.as_str()).is_some(),
|
||||||
|
|||||||
@@ -367,6 +367,7 @@ fn build_query_result(rows: Vec<serde_json::Value>, start: Instant) -> QueryResu
|
|||||||
affected_rows: affected,
|
affected_rows: affected,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -515,6 +515,7 @@ pub async fn execute_query(client: &InfluxdbClient, database: &str, sql: &str) -
|
|||||||
rows,
|
rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -532,6 +533,7 @@ pub async fn execute_query(client: &InfluxdbClient, database: &str, sql: &str) -
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -732,6 +734,7 @@ fn parse_flux_csv(text: &str, start: Instant) -> Result<QueryResult, String> {
|
|||||||
rows,
|
rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -1910,6 +1910,7 @@ fn raw_response_result(status: u16, body: String, start: Instant, truncated: boo
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -4872,6 +4872,7 @@ async fn execute_result_set_with_text_protocol_on_conn(
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4916,6 +4917,7 @@ async fn execute_result_set_with_text_protocol_on_conn(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5010,6 +5012,7 @@ async fn execute_result_set_with_text_protocol_on_conn(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5140,6 +5143,7 @@ async fn execute_result_sets_with_text_protocol_on_conn(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5167,6 +5171,7 @@ async fn execute_result_sets_with_text_protocol_on_conn(
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5350,6 +5355,7 @@ async fn execute_result_set_with_prepared_protocol_on_conn(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5673,6 +5679,7 @@ pub async fn execute_transaction_statement_on_conn(
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: started_at.elapsed().as_millis(),
|
execution_time_ms: started_at.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5708,6 +5715,7 @@ pub async fn execute_transaction_statement_on_conn(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: started_at.elapsed().as_millis(),
|
execution_time_ms: started_at.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5829,6 +5837,7 @@ pub async fn execute_query_on_conn_with_limits_progress(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5867,6 +5876,7 @@ pub async fn execute_query_on_conn_with_limits_progress(
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5996,6 +6006,7 @@ pub async fn execute_non_result_batch_on_conn(
|
|||||||
affected_rows: result.affected_rows(),
|
affected_rows: result.affected_rows(),
|
||||||
execution_time_ms: elapsed_ms.saturating_sub(previous_elapsed_ms),
|
execution_time_ms: elapsed_ms.saturating_sub(previous_elapsed_ms),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -1961,6 +1961,7 @@ async fn execute_select_prepared(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -2057,6 +2058,7 @@ async fn execute_select_text(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -8001,6 +8003,7 @@ pub async fn execute_query_with_max_rows(
|
|||||||
affected_rows: affected,
|
affected_rows: affected,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -8828,6 +8831,7 @@ async fn execute_query_with_max_rows_inner(
|
|||||||
affected_rows: affected,
|
affected_rows: affected,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -14415,6 +14419,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -315,6 +315,7 @@ pub async fn execute_query_with_max_rows(
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -369,6 +370,7 @@ fn query_result_from_rqlite_result(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms,
|
execution_time_ms,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -989,6 +989,7 @@ fn solr_table_result(
|
|||||||
affected_rows: row_count,
|
affected_rows: row_count,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -1008,6 +1009,7 @@ fn solr_raw_json_response_result(status: u16, body_text: impl Into<String>, star
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -2950,6 +2950,7 @@ fn execute_query_blocking(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -2968,6 +2969,7 @@ fn execute_query_blocking(
|
|||||||
affected_rows: conn.changes(),
|
affected_rows: conn.changes(),
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ impl SqliteWorkerSession<'_> {
|
|||||||
affected_rows: affected_rows.unwrap_or(0),
|
affected_rows: affected_rows.unwrap_or(0),
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: truncated.unwrap_or(false),
|
truncated: truncated.unwrap_or(false),
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -757,6 +757,7 @@ fn server_messages_query_result(messages: Vec<String>, start: Instant) -> Option
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -831,6 +832,7 @@ async fn collect_first_result_limited(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -1751,6 +1753,7 @@ fn push_sqlserver_result_set(results: &mut Vec<QueryResult>, result: Option<SqlS
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: result.truncated,
|
truncated: result.truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -1810,6 +1813,7 @@ fn push_sqlserver_ordered_events(
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -3543,6 +3547,7 @@ async fn execute_query_with_max_rows_inner(
|
|||||||
affected_rows: result.rows_affected().iter().sum::<u64>(),
|
affected_rows: result.rows_affected().iter().sum::<u64>(),
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -3589,6 +3594,7 @@ pub async fn execute_batch_with_max_rows_metadata(
|
|||||||
affected_rows: result.rows_affected().iter().sum::<u64>(),
|
affected_rows: result.rows_affected().iter().sum::<u64>(),
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -3684,6 +3690,7 @@ pub async fn execute_simple_batch_with_max_rows_metadata(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4111,6 +4118,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 1,
|
execution_time_ms: 1,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4136,6 +4144,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 1,
|
execution_time_ms: 1,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4156,6 +4165,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 1,
|
execution_time_ms: 1,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5062,6 +5072,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -5622,6 +5633,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 1,
|
execution_time_ms: 1,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -364,6 +364,7 @@ pub async fn execute_query_with_max_rows(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -387,6 +388,7 @@ pub async fn execute_query_with_max_rows(
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -407,6 +409,7 @@ pub async fn execute_query_with_max_rows(
|
|||||||
affected_rows: affected,
|
affected_rows: affected,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -589,6 +592,7 @@ fn query_result_from_turso_result(
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms,
|
execution_time_ms,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated,
|
truncated,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -923,6 +923,7 @@ fn json_to_query_result(status: u16, body: Value, start: Instant) -> QueryResult
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -958,6 +959,7 @@ fn values_to_query_result(items: Vec<Value>, start: Instant) -> QueryResult {
|
|||||||
rows,
|
rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -355,6 +355,7 @@ fn series_result_to_query_result(series: Vec<SeriesResult>, start: Instant) -> Q
|
|||||||
rows,
|
rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
spatial_columns: vec![],
|
spatial_columns: vec![],
|
||||||
spatial_values: vec![],
|
spatial_values: vec![],
|
||||||
truncated: false,
|
truncated: false,
|
||||||
@@ -393,6 +394,7 @@ fn simple_result(rows: Vec<Vec<Value>>, value_type: &str, start: Instant) -> Que
|
|||||||
rows,
|
rows,
|
||||||
execution_time_ms: start.elapsed().as_millis(),
|
execution_time_ms: start.elapsed().as_millis(),
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
spatial_columns: vec![],
|
spatial_columns: vec![],
|
||||||
spatial_values: vec![],
|
spatial_values: vec![],
|
||||||
truncated: false,
|
truncated: false,
|
||||||
|
|||||||
@@ -2496,6 +2496,7 @@ fn query_result(columns: Vec<String>, rows: Vec<Vec<Value>>, affected_rows: u64)
|
|||||||
affected_rows,
|
affected_rows,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -3055,6 +3055,7 @@ fn empty_query_result() -> dbx_core::db::QueryResult {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4048,6 +4049,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -4374,6 +4376,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 1,
|
execution_time_ms: 1,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -6847,6 +6850,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -6879,6 +6883,7 @@ mod tests {
|
|||||||
affected_rows: 2,
|
affected_rows: 2,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
@@ -6912,6 +6917,7 @@ mod tests {
|
|||||||
affected_rows: 1,
|
affected_rows: 1,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -806,6 +806,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
//! Verify captured live Agent responses survive the desktop's typed JSON boundary.
|
||||||
|
//! Usage: cargo run -p dbx-types --example query_timing_roundtrip -- <live-results.json>
|
||||||
|
use dbx_types::types::QueryResult;
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let file = std::env::args().nth(1).ok_or("expected live-results.json")?;
|
||||||
|
let records: Vec<serde_json::Value> = serde_json::from_slice(&std::fs::read(file)?)?;
|
||||||
|
for record in &records {
|
||||||
|
let input = record["result"].clone();
|
||||||
|
let result: QueryResult = serde_json::from_value(input.clone())?;
|
||||||
|
let output = serde_json::to_value(result)?;
|
||||||
|
assert_eq!(output["query_timings_ms"], input["query_timings_ms"]);
|
||||||
|
assert_eq!(output["server_execute_time_us"], input["server_execute_time_us"]);
|
||||||
|
assert_eq!(output["rows"], input["rows"]);
|
||||||
|
}
|
||||||
|
println!("PASS: {} live responses preserve timings and rows", records.len());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -482,6 +482,9 @@ pub struct QueryResult {
|
|||||||
/// completed statement cannot be correlated to one audit row.
|
/// completed statement cannot be correlated to one audit row.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub server_execute_time_us: Option<u64>,
|
pub server_execute_time_us: Option<u64>,
|
||||||
|
/// Optional measured query phases in milliseconds; absent on older agents.
|
||||||
|
#[serde(default)]
|
||||||
|
pub query_timings_ms: Option<std::collections::BTreeMap<String, f64>>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub truncated: bool,
|
pub truncated: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -523,6 +526,7 @@ impl Serialize for QueryResult {
|
|||||||
+ usize::from(!self.spatial_values.is_empty())
|
+ usize::from(!self.spatial_values.is_empty())
|
||||||
+ usize::from(self.elasticsearch_raw_body.is_some())
|
+ usize::from(self.elasticsearch_raw_body.is_some())
|
||||||
+ usize::from(self.server_execute_time_us.is_some())
|
+ usize::from(self.server_execute_time_us.is_some())
|
||||||
|
+ usize::from(self.query_timings_ms.is_some())
|
||||||
+ usize::from(!self.messages.is_empty());
|
+ usize::from(!self.messages.is_empty());
|
||||||
let mut state = serializer.serialize_struct("QueryResult", field_count)?;
|
let mut state = serializer.serialize_struct("QueryResult", field_count)?;
|
||||||
state.serialize_field("columns", &self.columns)?;
|
state.serialize_field("columns", &self.columns)?;
|
||||||
@@ -540,6 +544,9 @@ impl Serialize for QueryResult {
|
|||||||
if let Some(server_execute_time_us) = &self.server_execute_time_us {
|
if let Some(server_execute_time_us) = &self.server_execute_time_us {
|
||||||
state.serialize_field("server_execute_time_us", server_execute_time_us)?;
|
state.serialize_field("server_execute_time_us", server_execute_time_us)?;
|
||||||
}
|
}
|
||||||
|
if let Some(timings) = &self.query_timings_ms {
|
||||||
|
state.serialize_field("query_timings_ms", timings)?;
|
||||||
|
}
|
||||||
state.serialize_field("truncated", &self.truncated)?;
|
state.serialize_field("truncated", &self.truncated)?;
|
||||||
state.serialize_field("session_id", &self.session_id)?;
|
state.serialize_field("session_id", &self.session_id)?;
|
||||||
state.serialize_field("has_more", &self.has_more)?;
|
state.serialize_field("has_more", &self.has_more)?;
|
||||||
@@ -1252,6 +1259,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -1401,6 +1401,7 @@ mod tests {
|
|||||||
affected_rows: 0,
|
affected_rows: 0,
|
||||||
execution_time_ms: 0,
|
execution_time_ms: 0,
|
||||||
server_execute_time_us: None,
|
server_execute_time_us: None,
|
||||||
|
query_timings_ms: None,
|
||||||
truncated: false,
|
truncated: false,
|
||||||
session_id: None,
|
session_id: None,
|
||||||
has_more: false,
|
has_more: false,
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# PR 提交与 CI 核查
|
||||||
|
|
||||||
|
## 提交前
|
||||||
|
|
||||||
|
1. 确认实际工作目录、分支和远端。执行 `git status --short`、`git remote -v`、`git fetch origin main`,用 `git diff origin/main...HEAD` 检查本 PR 范围;本地未提交改动还要单独检查。工作区有改动时不要直接拉取覆盖。
|
||||||
|
2. 按 `.github/workflows/ci.yml` 和其他相关 workflow 选择检查。单元/组件测试、类型检查、格式、lint、生成文件、多语言完整性是不同检查,不能互相替代。重放到新基线后检查上游是否影响已验证路径。
|
||||||
|
3. 前端至少核对 CI 使用的格式与 lint 命令,以及当前变更相关测试和类型检查。Rust、Agent、发布文件按实际影响范围执行对应检查,不为无关路径增加发布关卡。
|
||||||
|
4. 新增简中词条时,先检查 `.github/scripts/i18n-autofill.mjs` 的 `TARGET_LOCALES`。补齐其要求的语言并保持 `{count}` 等占位符;不要把“英文可回退”当作自动翻译 CI 会成功的保证。
|
||||||
|
|
||||||
|
### 多语言的本地检查
|
||||||
|
|
||||||
|
在仓库根目录执行:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
node .github/scripts/i18n-autofill.mjs --dry-run --base-ref origin/main
|
||||||
|
```
|
||||||
|
|
||||||
|
该脚本只检查相对基线新增的简中键,不负责历史缺口或已有文案修改的同步。当前要求 en、es、it、ja、ko、pt-BR、ru、zh-TW;以脚本实际配置为准。
|
||||||
|
|
||||||
|
注意:`--dry-run` 只保证不写文件,有缺口且配置 API key 时仍会请求翻译服务。离线预检应在未配置 `DEEPSEEK_API_KEY` 且未开启 `I18N_MOCK_TRANSLATIONS` 的环境执行。PowerShell 可临时清空这两个进程环境变量,检查后恢复原值,不打印密钥。
|
||||||
|
|
||||||
|
通过标准是每种目标语言都输出 `all new keys already present`,最后输出 `No locale files needed changes`;没有新增键时则输出 `No new ... i18n keys`。缺失 API key 的错误说明仍有翻译缺口,应补齐后再提交。`--mock-translations` 仅用于复现/诊断,不能作为翻译完整性通过依据,更不能将 mock 文案写入提交。
|
||||||
|
|
||||||
|
## 推送与远端核查
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git push -u fork <branch>
|
||||||
|
gh pr checks <number> --repo t8y2/dbx
|
||||||
|
gh pr view <number> --repo t8y2/dbx --json headRefOid,state,mergeable,statusCheckRollup
|
||||||
|
gh run view <run-id> --repo t8y2/dbx --log-failed
|
||||||
|
```
|
||||||
|
|
||||||
|
- push 成功只代表远端分支收到提交。PR 已创建、无合并冲突、CI 通过、已合并和已发布是不同状态。
|
||||||
|
- 创建或更新 PR 后查看对应提交 SHA 的检查结果。排队/运行中写明待完成,不能将本地测试通过写成远端全绿。
|
||||||
|
- 失败时保存任务名、run/job 链接、提交 SHA 和首个实际错误。先判断是代码、格式、翻译缺口、权限、在线服务还是 runner 环境,不能只根据红叉推测。
|
||||||
|
- 修复本分支可解决的问题,运行对应检查再正常提交推送。不要靠不断 rerun 掩盖确定性缺口,也不要为了绿灯跳过检查或改无关 workflow。
|
||||||
|
- 后续机器人提交会改变 SHA,应先 fetch 核实再更新,避免覆盖机器人的改动。最终报告列出最新提交通过、失败和仍在运行的检查。
|
||||||
|
- GitHub CLI 的 `repo`/`workflow` 授权问题与代码 CI 失败分开处理;只检查 scope,不输出 token。
|
||||||
|
|
||||||
|
## #10231 的实际遗漏
|
||||||
|
|
||||||
|
2026-09-24,提交 `8ab182140` 新增 22 个耗时词条,仅补齐简中、繁中和英文。I18n Autofill 尝试自动补齐其他语言,在日语阶段收到空响应:
|
||||||
|
|
||||||
|
```text
|
||||||
|
DeepSeek API returned no translation content for ja
|
||||||
|
Process completed with exit code 1
|
||||||
|
```
|
||||||
|
|
||||||
|
[失败任务](https://github.com/t8y2/dbx/actions/runs/35973804399/job/107549411291)。这是翻译服务失败叠加提交前遗漏多语言检查;不是从该日志得出的数据库逻辑失败。修复直接补齐 es、it、ja、ko、pt-BR、ru 的 132 条翻译,使本 PR 不再需要在线补译。本地 dry-run 已确认所有目标语言完整,无文件需要修改。
|
||||||
|
|
||||||
|
此前“234 项前端测试、405 项 Java 测试通过”只证明这些测试的覆盖范围。它们没有覆盖在线补译。此后交付必须同时报告远端 CI 状态,不以测试数量代替检查覆盖。
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
@@ -0,0 +1,37 @@
|
|||||||
|
# Query timing details across databases
|
||||||
|
|
||||||
|
The query result status bar displays request wait as a number, for example `45ms`. Hover or keyboard focus opens a numbered three-column table. Notes stay in parentheses beside the stage. Escape closes the tooltip.
|
||||||
|
|
||||||
|
## Collected stages
|
||||||
|
|
||||||
|
- All SQL query tabs, including manual transactions, measure request preparation, backend request wait, result processing and the latest grid update locally. This elapsed request wait includes backend/database processing and transport; it is not database CPU or execution-plan time.
|
||||||
|
- Java JDBC agents additionally report measured pool acquisition, session preparation, schema selection, statement preparation, execution, metadata, fetch and pool return stages. Only reported internal phases are displayed. Core lock and calculated remainders appear when their inputs exist.
|
||||||
|
- MongoDB, Redis and Elasticsearch command results use the same common stages. Sequential backend calls within one command accumulate their wait without counting result conversion twice. Local commands without a backend request and continuous Redis MONITOR do not invent a completed-request duration.
|
||||||
|
- A single SQL batch returning multiple results has no independent client request span per result; unavailable values remain unavailable instead of assigning the whole batch duration to each result.
|
||||||
|
- Pagination accumulates completed request waits and phase maps, including pages consumed during offset jumps. Grid update timing describes the latest update. Result cache serialization preserves the optional timing fields.
|
||||||
|
- The backend total, when available with detailed Agent telemetry, overlaps the listed stages. Other wait is a calculated remainder, not measured network time. Missing values are never replaced by zero.
|
||||||
|
- Normal OceanBase queries no longer run LAST_TRACE_ID or SQL audit lookups for timing. No additional diagnostic SQL is introduced for other databases.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Verification on 2026-09-24
|
||||||
|
|
||||||
|
Environment: Windows, Node with repository dependencies, JDK 21. Tests and regression expectations were prepared before their corresponding implementation. Identified risks included missing/invalid telemetry, double counting, errors, pagination/cache loss, command conversion counted as wait, and regressions to query behavior.
|
||||||
|
|
||||||
|
From the repository root:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
node node_modules/vitest/vitest.mjs run apps/desktop/src/components/grid/__tests__/QueryTimingDetails.spec.ts apps/desktop/src/components/grid/__tests__/DataGridSurfaces.spec.ts apps/desktop/src/lib/__tests__/queryRequestTiming.spec.ts apps/desktop/src/lib/__tests__/tabs/tabResultCache.spec.ts apps/desktop/src/stores/__tests__/queryStore.multiStatementError.spec.ts apps/desktop/src/stores/__tests__/queryStore.mongoExecutionSummary.spec.ts apps/desktop/src/stores/__tests__/queryStore.spatialMetadata.spec.ts apps/desktop/src/stores/__tests__/queryStore.hiddenPrimaryKey.spec.ts apps/desktop/src/stores/__tests__/queryStore.provenReadOnlyStickyState.spec.ts apps/desktop/src/composables/__tests__/useResultViewUpdateTiming.spec.ts
|
||||||
|
node node_modules/vue-tsc/bin/vue-tsc.js --noEmit --project apps/desktop/tsconfig.json
|
||||||
|
agents/gradlew.bat -p agents :common:test :oceanbase-oracle:test :oceanbase-oracle:shadowJar :db2:test :dameng:test --console=plain
|
||||||
|
```
|
||||||
|
|
||||||
|
234 frontend tests passed. After the final phase-filter adjustment, the three component checks passed again. 405 Java checks passed: common 218, OceanBase 43, DB2 14, Dameng 130. The common pool/cursor test uses embedded H2 through actual multi-session JSON-RPC and confirms nonnegative acquisition, execution, fetch and release measurements while preserving cursor behavior. Driver tests are not evidence of connectivity to external DB2 or Dameng services.
|
||||||
|
|
||||||
|
Browser verification mounted the production component, styles, locale and cache codec. The captured JDBC response displayed `26ms` and 12 applicable rows; the native/HTTP layout example displayed `45ms` and four common rows. Keyboard focus opened both tables, values were right-aligned, and Escape closed the popup. The native/HTTP example is synthetic and does not prove live MongoDB, Redis or Elasticsearch execution.
|
||||||
|
|
||||||
|
Earlier OceanBase validation, before this cross-database extension, exercised seven read-only JSON-RPC requests against OceanBase Oracle 4.2.5.7 with Connector/J 2.4.18: two 27-table UNION counts, three cursor pages, a capped result and an empty query. It verified rows, phase bounds, cursor lifecycle and absence of trace/audit/server-plan telemetry. This extension does not repeat that external database run.
|
||||||
|
|
||||||
|
The prior Rust core check passed for the timing protocol; this extension does not change Rust. Full native desktop Core/store/grid execution and real external services for every supported database remain unverified. No package has been rebuilt for this extension and the PR remains paused.
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
Reference in new issue
Block a user