Dec 13, 2013

How to Visualize Vertica Query Plan

Vertica uses EXPLAIN command to return the query plan execution strategy to standard output.

Syntax
EXPLAIN { SELECT... | INSERT... | UPDATE...}

Returns
A compact representation of the query plan, laid out hierarchically.

Let's have an example here.
1. Prepare a table
This is preparation work, and if you know a table you can select please skip this step.

1. CREATE SCHEMA SAI;
2. CREATE TABLE T1(c INT);
3. INSERT INTO T1 VALUES(3);
4. INSERT INTO T1 VALUES(4);
5. INSERT INTO T1 VALUES(5);
2. In Vertica console, or a third party tool like DBVisualizer, execute
EXPLAIN SELECT * FROM SAI.T1;
You will get the output like below


3. Install GraphViz and launch GVEdit
For how to install GraphViz and launch GVEdit, please check another POST of mine.
http://sai1983.blogspot.com/2013/12/how-to-install-graphviz-and-launch.html

4. Use GVEdit
a. Copy the code in highlighted in step 2, the codes start from digraph G and all contents in {}
b. click the new icon of GVEdit and paste the content

c. click the right most "Run" button

If you think this article is useful, please click the ads on this page to help. Thank you very much.

No comments: