Skip to content

Commit

Permalink
IGNITE-22557 Add system view for SQL query plans history - Fixes #11425.
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksey Plekhanov <[email protected]>
  • Loading branch information
oleg-vlsk authored and alex-plekhanov committed Dec 23, 2024
1 parent e04be8b commit 2d69600
Show file tree
Hide file tree
Showing 21 changed files with 1,413 additions and 92 deletions.
15 changes: 15 additions & 0 deletions docs/_docs/monitoring-metrics/system-views.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,21 @@ This view exposes information about currently running SQL queries.
|LAST_START_TIME | date | Last execution date
|===

== SQL_PLANS_HISTORY

This view displays a list of plans of previously executed SQL queries.

[{table_opts}]
|===
|NAME | TYPE | DESCRIPTION
|SCHEMA_NAME | string | Schema name
|SQL | string | Query text
|PLAN | string | SQL plan text
|LOCAL | boolean | True if local only
|ENGINE | string | SQL engine
|LAST_START_TIME | date | Last execution date
|===

== SCHEMAS

This view exposes information about SQL schemas.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,14 @@ private ListFieldsQueryCursor<?> mapAndExecutePlan(
);
}

ctx.query().runningQueryManager().planHistoryTracker().addPlan(
plan.textPlan(),
qry.sql(),
qry.context().schemaName(),
qry.context().isLocal(),
CalciteQueryEngineConfiguration.ENGINE_NAME
);

QueryProperties qryProps = qry.context().unwrap(QueryProperties.class);

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

0 comments on commit 2d69600

Please sign in to comment.