Skip to content

Commit 2d69600

Browse files
oleg-vlskalex-plekhanov
authored andcommitted
IGNITE-22557 Add system view for SQL query plans history - Fixes #11425.
Signed-off-by: Aleksey Plekhanov <plehanov.alex@gmail.com>
1 parent e04be8b commit 2d69600

File tree

21 files changed

+1413
-92
lines changed

21 files changed

+1413
-92
lines changed

docs/_docs/monitoring-metrics/system-views.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,21 @@ This view exposes information about currently running SQL queries.
519519
|LAST_START_TIME | date | Last execution date
520520
|===
521521

522+
== SQL_PLANS_HISTORY
523+
524+
This view displays a list of plans of previously executed SQL queries.
525+
526+
[{table_opts}]
527+
|===
528+
|NAME | TYPE | DESCRIPTION
529+
|SCHEMA_NAME | string | Schema name
530+
|SQL | string | Query text
531+
|PLAN | string | SQL plan text
532+
|LOCAL | boolean | True if local only
533+
|ENGINE | string | SQL engine
534+
|LAST_START_TIME | date | Last execution date
535+
|===
536+
522537
== SCHEMAS
523538

524539
This view exposes information about SQL schemas.

modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/exec/ExecutionServiceImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,14 @@ private ListFieldsQueryCursor<?> mapAndExecutePlan(
710710
);
711711
}
712712

713+
ctx.query().runningQueryManager().planHistoryTracker().addPlan(
714+
plan.textPlan(),
715+
qry.sql(),
716+
qry.context().schemaName(),
717+
qry.context().isLocal(),
718+
CalciteQueryEngineConfiguration.ENGINE_NAME
719+
);
720+
713721
QueryProperties qryProps = qry.context().unwrap(QueryProperties.class);
714722

715723
Function<Object, Object> fieldConverter = (qryProps == null || qryProps.keepBinary()) ? null :

0 commit comments

Comments
 (0)