Query history displays detailed information related to Presto queries running or executed in watsonx.data. You can also search and filter queries and customize the display columns. On the Query history page, you can click on a query to view the details of the SQL statement, copy it, and view the results of the EXPLAIN which shows execution plan.
Here shows a concrete example of Query history using watsonx.data 2.2.0.
To Japanese Readers : This is the translated article of watsonx.data Query History on Qiita.
Query history
Go to "Query history" from the web console of watsonx.data.

"Query history" is displayed and it shows Query ID, Query , State, etc.

One of the unique feature in watsonx.data is its multi-engine architecture where more than one engines can be registered in a single cluster. In Query history , queries to multiple Presto engines are listed.
1. Query Search
Here is an example of searching for queries that includes "CANADA". When CANADA is typed in search area, the query which contains "and n_name = 'CANADA'" is listed.

2. Filter
Click "Filter" icon. Candidates for the filter parameters such as query state, engine name, user, and sources are displayed.

Here , when you check user02, only the queries executed by user02 are displayed.

3. Customizing Columns
You can customize the columns you want to display by clicking on the column icon. Here I check on "Analysis time".

Then, "Analysis time" column is added.

4. Export to CSV
Using "Export to CSV" , you can export and save the displayed results in a CSV file (encoded by utf-8).

Next is an example of downloaded CSV file. Because I filtered to display only "user02" and "Export to CSV" on Query history, CSV file has queries executed by "user02".
Viewing the execution plans in Query history
In Query history, you can easily display SQL queries and execution plans (EXPLAIN results).
Note: In order to display the execution plan in Query history, you need to use a fully qualified name (in the form of catalog.schema.table) for the table name.
1. Click on the three vertical dots ellipsis to the right of the query you want to see more options.

"View execution plans" and "Open in query workspace" are displayed.
2. Select View execution plans .
The query information is displayed.
You will find the table name expressed using fully qualified name "iceberg_data"."sf1_no_part".parts in the form of catalog.schema.table.

-
Logical execution plan shows the result of EXPLAIN SQL statement.
-
Distributed execution plan shows the result of EXPLAIN (TYPE DISTRIBUTED) statement. 
-
Explain analyze shows the result of EXPLAIN ANALYZE statement. When you click "Explain analyze" tab , it executes "EXPLAIN ANALYZE" and show the distributed execution plan of the statement along with the cost of each operation.
Environment
- OCP Version : 4.16
- CP4D 5.2.0 (watsonx.data 2.2.0)
- About Presto engines configured
- P01(Presto Java) Type : Presto (Java) v0.286 / Size : Starter
- PCpp (Presto(C++)) Type : Presto (C++) v0.286 / Size : Starter
#watsonx.data
#PrestoEngine