<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Vertica Documentation – Viewing query plans</title>
    <link>/en/admin/managing-queries/query-plans/viewing-query-plans/</link>
    <description>Recent content in Viewing query plans on Vertica Documentation</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/admin/managing-queries/query-plans/viewing-query-plans/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Admin: EXPLAIN-Generated query plans</title>
      <link>/en/admin/managing-queries/query-plans/viewing-query-plans/explain-generated-query-plans/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/managing-queries/query-plans/viewing-query-plans/explain-generated-query-plans/</guid>
      <description>
        
        
        &lt;p&gt;&lt;a href=&#34;../../../../../en/sql-reference/statements/explain/&#34;&gt;EXPLAIN&lt;/a&gt; returns the optimizer&#39;s query plan for executing a specified query. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt; QUERY PLAN DESCRIPTION:
 ------------------------------

 EXPLAIN SELECT customer_name, customer_state FROM customer_dimension WHERE customer_state IN (&amp;#39;MA&amp;#39;,&amp;#39;NH&amp;#39;) AND customer_gender=&amp;#39;Male&amp;#39; ORDER BY customer_name LIMIT 10;

 Access Path:
 +-SELECT  LIMIT 10 [Cost: 365, Rows: 10] (PATH ID: 0)
 |  Output Only: 10 tuples
 |  Execute on: Query Initiator
 | +---&amp;gt; SORT [TOPK] [Cost: 365, Rows: 544] (PATH ID: 1)
 | |      Order: customer_dimension.customer_name ASC
 | |      Output Only: 10 tuples
 | |      Execute on: Query Initiator
 | | +---&amp;gt; STORAGE ACCESS for customer_dimension [Cost: 326, Rows: 544] (PATH ID: 2)
 | | |      Projection: public.customer_dimension_DBD_1_rep_VMartDesign_node0001
 | | |      Materialize: customer_dimension.customer_state, customer_dimension.customer_name
 | | |      Filter: (customer_dimension.customer_gender = &amp;#39;Male&amp;#39;)
 | | |      Filter: (customer_dimension.customer_state = ANY (ARRAY[&amp;#39;MA&amp;#39;, &amp;#39;NH&amp;#39;]))
 | | |      Execute on: Query Initiator
 | | |      Runtime Filter: (SIP1(TopK): customer_dimension.customer_name)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can use &lt;code&gt;EXPLAIN&lt;/code&gt; to evaluate choices that the optimizer makes with respect to a given query. If you think query performance is less than optimal, run it through the Database Designer. For more information, see &lt;a href=&#34;../../../../../en/admin/configuring-db/creating-db-design/general-design-settings/#Incremen&#34;&gt;Incremental Design&lt;/a&gt; and &lt;a href=&#34;../../../../../en/admin/managing-db/managing-workloads/workload-best-practices/reducing-query-run-time/&#34;&gt;Reducing query run time&lt;/a&gt;.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: JSON-Formatted query plans</title>
      <link>/en/admin/managing-queries/query-plans/viewing-query-plans/json-formatted-query-plans/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/managing-queries/query-plans/viewing-query-plans/json-formatted-query-plans/</guid>
      <description>
        
        
        &lt;p&gt;&lt;code&gt;EXPLAIN JSON&lt;/code&gt; returns a query plan in JSON format. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; EXPLAIN JSON SELECT customer_name, customer_state FROM customer_dimension
     WHERE customer_state IN (&amp;#39;MA&amp;#39;,&amp;#39;NH&amp;#39;) AND customer_gender=&amp;#39;Male&amp;#39; ORDER BY customer_name LIMIT 10;
 ------------------------------
{
     &amp;#34;PARAMETERS&amp;#34; : {
         &amp;#34;QUERY_STRING&amp;#34; : &amp;#34;EXPLAIN JSON SELECT customer_name, customer_state FROM customer_dimension \n
         WHERE customer_state IN (&amp;#39;MA&amp;#39;,&amp;#39;NH&amp;#39;) AND customer_gender=&amp;#39;Male&amp;#39; ORDER BY customer_name LIMIT 10;&amp;#34;
     },
     &amp;#34;PLAN&amp;#34; : {
         &amp;#34;PATH_ID&amp;#34; : 0,
         &amp;#34;PATH_NAME&amp;#34; : &amp;#34;SELECT&amp;#34;,
         &amp;#34;EXTRA&amp;#34; : &amp;#34; LIMIT 10&amp;#34;,
         &amp;#34;COST&amp;#34; : 2114.000000,
         &amp;#34;ROWS&amp;#34; : 10.000000,
         &amp;#34;COST_STATUS&amp;#34; : &amp;#34;NO_STATISTICS&amp;#34;,
         &amp;#34;TUPLE_LIMIT&amp;#34; : 10,
         &amp;#34;EXECUTE_NODE&amp;#34; : &amp;#34;Query Initiator&amp;#34;,
         &amp;#34;INPUT&amp;#34; : {
             &amp;#34;PATH_ID&amp;#34; : 1,
             &amp;#34;PATH_NAME&amp;#34; : &amp;#34;SORT&amp;#34;,
             &amp;#34;EXTRA&amp;#34; : &amp;#34;[TOPK]&amp;#34;,
             &amp;#34;COST&amp;#34; : 2114.000000,
             &amp;#34;ROWS&amp;#34; : 49998.000000,
             &amp;#34;COST_STATUS&amp;#34; : &amp;#34;NO_STATISTICS&amp;#34;,
             &amp;#34;ORDER&amp;#34; : [&amp;#34;customer_dimension.customer_name&amp;#34;, &amp;#34;customer_dimension.customer_state&amp;#34;],
             &amp;#34;TUPLE_LIMIT&amp;#34; : 10,
             &amp;#34;EXECUTE_NODE&amp;#34; : &amp;#34;All Nodes&amp;#34;,
             &amp;#34;INPUT&amp;#34; : {
                 &amp;#34;PATH_ID&amp;#34; : 2,
                 &amp;#34;PATH_NAME&amp;#34; : &amp;#34;STORAGE ACCESS&amp;#34;,
                 &amp;#34;EXTRA&amp;#34; : &amp;#34;for customer_dimension&amp;#34;,
                 &amp;#34;COST&amp;#34; : 252.000000,
                 &amp;#34;ROWS&amp;#34; : 49998.000000,
                 &amp;#34;COST_STATUS&amp;#34; : &amp;#34;NO_STATISTICS&amp;#34;,
                 &amp;#34;TABLE&amp;#34; : &amp;#34;public.customer_dimension&amp;#34;,
                 &amp;#34;PROJECTION&amp;#34; : &amp;#34;public.customer_dimension_b0&amp;#34;,
                 &amp;#34;MATERIALIZE&amp;#34; : [&amp;#34;customer_dimension.customer_name&amp;#34;, &amp;#34;customer_dimension.customer_state&amp;#34;],
                 &amp;#34;FILTER&amp;#34; : [&amp;#34;(customer_dimension.customer_state = ANY (ARRAY[&amp;#39;MA&amp;#39;, &amp;#39;NH&amp;#39;]))&amp;#34;, &amp;#34;(customer_dimension.customer_gender = &amp;#39;Male&amp;#39;)&amp;#34;],
                 &amp;#34;EXECUTE_NODE&amp;#34; : &amp;#34;All Nodes&amp;#34;
          &amp;#34;SIP&amp;#34; : &amp;#34;Runtime Filter: (SIP1(TopK): customer_dimension.customer_name)&amp;#34;

             }
         }
     }
 }
(40 rows)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Admin: Verbose query plans</title>
      <link>/en/admin/managing-queries/query-plans/viewing-query-plans/verbose-query-plans/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/managing-queries/query-plans/viewing-query-plans/verbose-query-plans/</guid>
      <description>
        
        
        &lt;p&gt;You can qualify &lt;code&gt;EXPLAIN&lt;/code&gt; with the &lt;code&gt;VERBOSE&lt;/code&gt; option. This option, valid for default and &lt;a href=&#34;../../../../../en/admin/managing-queries/query-plans/viewing-query-plans/json-formatted-query-plans/&#34;&gt;JSON&lt;/a&gt; output, increases the amount of detail in the rendered query plan&lt;/p&gt;
&lt;p&gt;For example, the following &lt;code&gt;EXPLAIN&lt;/code&gt; statement specifies to produce verbose output. Added information is set off in bold:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; EXPLAIN VERBOSE SELECT customer_name, customer_state FROM customer_dimension
     WHERE customer_state IN (&amp;#39;MA&amp;#39;,&amp;#39;NH&amp;#39;) AND customer_gender=&amp;#39;Male&amp;#39; ORDER BY customer_name LIMIT 10;

QUERY PLAN DESCRIPTION:
 ------------------------------

 Opt Vertica Options
 --------------------
 PLAN_OUTPUT_SUPER_VERBOSE

 EXPLAIN VERBOSE SELECT customer_name, customer_state FROM customer_dimension
 WHERE customer_state IN (&amp;#39;MA&amp;#39;,&amp;#39;NH&amp;#39;) AND customer_gender=&amp;#39;Male&amp;#39;
 ORDER BY customer_name LIMIT 10;

Access Path:
+-SELECT  LIMIT 10 [&lt;span class=&#34;code-input&#34;&gt;Cost: 756.000000, Rows: 10.000000 Disk(B): 0.000000 CPU(B): 0.000000 Memory(B): 0.000000 Netwrk(B): 0.000000 Parallelism: 1.000000] [OutRowSz (B): 274&lt;/span&gt;](PATH ID: 0)
|  Output Only: 10 tuples
|  Execute on: Query Initiator
|  Sort Key: (customer_dimension.customer_name)
|  LDISTRIB_UNSEGMENTED
| +---&amp;gt; SORT [TOPK] [Cost: 756.000000, Rows: 9998.000000 Disk(B): 0.000000 CPU(B): 34274697.123457 Memory(B): 2739452.000000 Netwrk(B): 0.000000 Parallelism: 4.000000 (NO STATISTICS)] [OutRowSz (B): 274] (PATH ID: 1)
| |      Order: customer_dimension.customer_name ASC
| |      Output Only: 10 tuples
| |      Execute on: Query Initiator
| |      &lt;span class=&#34;code-input&#34;&gt;Sort Key: (customer_dimension.customer_name)&lt;/span&gt;
| |      &lt;span class=&#34;code-input&#34;&gt;LDISTRIB_UNSEGMENTED&lt;/span&gt;
| | +---&amp;gt; STORAGE ACCESS for customer_dimension [&lt;span class=&#34;code-input&#34;&gt;Cost: 513.000000, Rows: 9998.000000 Disk(B): 0.000000 CPU(B): 0.000000 Memory(B): 0.000000 Netwrk(B): 0.000000 Parallelism: 4.000000 (NO STATISTICS)] [OutRowSz (B): 274&lt;/span&gt;] (PATH ID: 2)
| | |      &lt;span class=&#34;code-input&#34;&gt;Column Cost Aspects: [ Disk(B): 7371817.156569 CPU(B): 4914708.578284 Memory(B): 2659466.004399 Netwrk(B): 0.000000 Parallelism: 4.000000 ]&lt;/span&gt;
| | |      Projection: public.customer_dimension_P1
| | |      Materialize: customer_dimension.customer_state, customer_dimension.customer_name
| | |      Filter: (customer_dimension.customer_gender = &amp;#39;Male&amp;#39;)&lt;span class=&#34;code-input&#34;&gt;/* sel=0.999800 ndv= 500 */&lt;/span&gt;
| | |      Filter: (customer_dimension.customer_state = ANY (ARRAY[&amp;#39;MA&amp;#39;, &amp;#39;NH&amp;#39;]))&lt;span class=&#34;code-input&#34;&gt;/* sel=0.999800 ndv= 500 */&lt;/span&gt;
| | |      Execute on: All Nodes
| | |      Runtime Filter: (SIP1(TopK): customer_dimension.customer_name)
| | |      &lt;span class=&#34;code-input&#34;&gt;Sort Key: (customer_dimension.household_id, customer_dimension.customer_key, customer_dimension.store_membership_card, customer_dimension.customer_type, customer_dimension.customer_region, customer_dimension.title, customer_dimension.number_of_children)&lt;/span&gt;
| | |      &lt;span class=&#34;code-input&#34;&gt;LDISTRIB_SEGMENTED&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
    <item>
      <title>Admin: Local query plans</title>
      <link>/en/admin/managing-queries/query-plans/viewing-query-plans/local-query-plans/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/managing-queries/query-plans/viewing-query-plans/local-query-plans/</guid>
      <description>
        
        
        &lt;p&gt;&lt;code&gt;EXPLAIN LOCAL&lt;/code&gt; (on a multi-node database) shows the local query plans assigned to each node, which together comprise the total (global) query plan. If you omit this option, Vertica shows only the global query plan. Local query plans are shown only in DOT language source, which can be rendered in &lt;a href=&#34;http://graphviz.org/&#34;&gt;Graphviz&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For example, the following &lt;code&gt;EXPLAIN&lt;/code&gt; statement includes the &lt;code&gt;LOCAL&lt;/code&gt; option:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; EXPLAIN LOCAL SELECT store_name, store_city, store_state
   FROM store.store_dimension ORDER BY store_state ASC, store_city ASC;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The output includes GraphViz source, which describes the local query plans assigned to each node. For example, output for this statement on a three-node database includes a GraphViz description of the following query plan for one node (&lt;code&gt;v_vmart_node0003&lt;/code&gt;):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt; -----------------------------------------------
 PLAN: v_vmart_node0003 (GraphViz Format)
 -----------------------------------------------
 digraph G {
 graph [rankdir=BT, label = &amp;#34;v_vmart_node0003\n&amp;#34;, labelloc=t, labeljust=l ordering=out]
 0[label = &amp;#34;NewEENode \nOutBlk=[UncTuple(3)]&amp;#34;, color = &amp;#34;green&amp;#34;, shape = &amp;#34;box&amp;#34;];
 1[label = &amp;#34;Send\nSend to: v_vmart_node0001\nNet id: 1000\nMerge\n\nUnc: Char(2)\nUnc: Varchar(64)\nUnc: Varchar(64)&amp;#34;, color = &amp;#34;green&amp;#34;, shape = &amp;#34;box&amp;#34;];
 2[label = &amp;#34;Sort: (keys = A,A,N)\nUnc: Char(2)\nUnc: Varchar(64)\nUnc: Varchar(64)&amp;#34;, color = &amp;#34;green&amp;#34;, shape = &amp;#34;box&amp;#34;];
 3[label = &amp;#34;ExprEval: \n  store_dimension.store_state\n  store_dimension.store_city\n  store_dimension.store_name\nUnc: Char(2)\nUnc: Varchar(64)\nUnc: Varchar(64)
&amp;#34;, color = &amp;#34;green&amp;#34;, shape = &amp;#34;box&amp;#34;];
 4[label = &amp;#34;StorageUnionStep: store_dimension_p_b0\nUnc: Varchar(64)\nUnc: Varchar(64)\nUnc: Char(2)&amp;#34;, color = &amp;#34;purple&amp;#34;, shape = &amp;#34;box&amp;#34;];
 5[label = &amp;#34;ScanStep: store_dimension_p_b0\nstore_key (not emitted)\nstore_name\nstore_city\nstore_state\nUnc: Varchar(64)\nUnc: Varchar(64)\nUnc: Char(2)&amp;#34;, color
= &amp;#34;brown&amp;#34;, shape = &amp;#34;box&amp;#34;];
 1-&amp;gt;0 [label = &amp;#34;0&amp;#34;,color = &amp;#34;blue&amp;#34;];
 2-&amp;gt;1 [label = &amp;#34;0&amp;#34;,color = &amp;#34;blue&amp;#34;];
 3-&amp;gt;2 [label = &amp;#34;0&amp;#34;,color = &amp;#34;blue&amp;#34;];
 4-&amp;gt;3 [label = &amp;#34;0&amp;#34;,color = &amp;#34;blue&amp;#34;];
 5-&amp;gt;4 [label = &amp;#34;0&amp;#34;,color = &amp;#34;blue&amp;#34;];
 }
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;GraphViz renders this output as follows:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;../../../../../images/query-plans/explain-local-graph-viz-output.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;

      </description>
    </item>
    
  </channel>
</rss>
