@ExplainView

Documentation

VoltDB Home » Documentation » Using VoltDB

@ExplainView

@ExplainView — Returns the execution plans for the components of the specified view.

Synopsis

@ExplainView String view-name

Description

The @ExplainView system procedure returns the execution plans for certain components of the specified view. Execution plans describe how VoltDB expects to calculate the component values as the referenced tables or streams are updated. The plans include what indexes are used, the order the tables are joined, and so on. Execution plans are useful for identifying performance issues in the design of the view statement. See the chapter on execution plans in the VoltDB Guide to Performance and Customization for information on how to interpret the plans.

For views, execution plans are listed for the calculation of MIN() and MAX() functions and multi-table joins only. For simple views — that is, views on a single table with aggregate functions other than MIN() or MAX() — the system procedure returns no rows.

Return Values

Returns one VoltTable with one row for each component of the view.

NameDatatypeDescription
TASKVARCHARThe function or join statement
EXECUTION_PLANVARCHARThe execution plan as text.

Examples

The following example uses @ExplainView to evaluate the execution plans associated with a view that joins two tables.

try {
    VoltTable[] results = client.callProcedure("@ExplainView",
       "stats_by_city_and_state" ).getResults();
    results[0].resetRowPosition();
    while (results[0].advanceRow()) {
         System.out.printf("Task: %d\nPlan:\n%d",
         results[0].getString(0),results[0].getString(1));
    }
}
catch (Exception e) {
    e.printStackTrace();
}

In the sqlcmd utility, the "explainview" command is a shortcut for "exec @ExplainView". So the following two commands are equivalent:

$ sqlcmd
1> exec @ExplainView 'stats_by_city_and_state';
2> explainview stats_by_city_and_state;