Db2

 View Only

Calling Visual Explain as a Microservice

By Peter KOHLMANN posted Thu November 21, 2019 03:41 PM

  
Most people think of microservices as only interacting through REST. However it is possible to use parts of the console user interface as a microservice as well. Many of the functions in the Db2 Data Management Console are available as single web pages if you know how to construct the right URL. 

You can navigate to the part of the User Interface you want to share and select the share button:Screen_Shot_2019-11-21_at_2_48_00_PM.pngThis will provide a URL that you can copy and share with your team. Only users with valid IDs in the Console can access the URL.

But you can go one step further. By constructing a URL that includes the name of the database connection you are working with and the SQL you want to analyze you can embed a visual explain tool an any website, browser application or python notebook.

Let's build that URL one step at a time. 

First you need to include the address of the Db2 Data Management Console server, for example:
https://9.30.1.194:11081/​

Then you need to direct the request to the console service:
https://9.30.1.194:11081/console/​

Then you add a clause that strips off everything else from the user interface and just leaves the Visual Explain interface:
https://9.30.1.194:11081/console/?mode=compact​

Then you add the request to create a visual explain of the statement access plan:
https://9.30.1.194:11081/console/?mode=compact#sql/explain/create/​


Then you add the SQL Statement you want to analyze:

https://9/30/1/194:11081/console/?mode=compact#sql/explain/create/​select * from syscat.tables


And finally you specify the database connection cataloged in the console that you want to direct the request to:

https://9.30.1.194:11081/console/?mode=compact#sql/explain/create/​select * from syscat.tables?profile=DATABASE


This will generate a self contained, fully interactive, visual explain of your statement that you can include in a web page, application or Python Notebook. 
Screen_Shot_2019-11-21_at_3_02_53_PM.png
There is also an example in my Python examples on github.com that you might want to check out.
Screen_Shot_2019-11-21_at_3_29_55_PM.png
Let me know what you think and how you might use this in your own organization.


#Db2
0 comments
17 views

Permalink