Using Visual Explain

To run Visual Explain, first open a connection to a database:

Click on the arrow of the combo box that is on the right side of the Visual Explain window in the Tool Bar. A list of the databases you configured in the Section called Configuring a Connection to a Database appears.

Select a database to connect to.

Depending on whether you configured the database connection to include a password and whether or not Save Database Passwords is enabled (discussed in the Section called Configuring Visual Explain's Operation), you may need to enter the database password in a pop-up window.

After this is done, if the connection is successful, the database's connection name appears in the Tool Bar.

Running and Storing SQL Commands

With a connection to a database open, type SQL commands, separated by semicolons, into the SQL Entry Area.

To run SQL commands, click on the blue "Explain" icon (or from the Statement menu, select Explain). Only the first SQL statement is explained.

To explain a statement other than the first, just highlight the command that you want to run and click on the blue "Explain" icon.

To store SQL commands for future use, click on the "save" icon. You are prompted for a filename.

To run SQL command files, click on the "open" icon. To run those commands, click on the blue "Explain" icon (or from the Statement menu, select Explain).

The output from the EXPLAIN command is displayed in the Visual Explain output window.

NoteOther Output Options
 

You can view a text version of the contents of the Visual Explain output window by clicking on Window -> Show EXPLAIN Output (or Window -> Show EXPLAIN VERBOSE Output). You can save a text version of the contents of this window by right-clicking on it, and entering a file name when prompted.

You can see an overview of the contents of the Visual Explain output window by clicking on Window -> Show Plan Overview.

An Example: Analyzing the regression Database

  1. To begin, EXPLAIN the following statement:
    SELECT * FROM hobbies_r;

    Visual Explain displays the "Scan" icon above the caption "Seq Scan on hobbies_r".

  2. Click on the "Scan" icon; the window now shows:

  3. Next, select a distinct entry from one of the tables:

    SELECT DISTINCT (name) FROM hobbies_r;

    The Visual Explain display now contains the unique and sort icons as well.

  4. Next, run the following command:

    SELECT name, count (*) FROM hobbies_r group BY name;

    Visual Explain now displays the group and aggregate icons instead of sort all unique.

  5. Run a command that lists all people, hobbies, and their equipment:

    SELECT h.person, e.name FROM hobbies_r h, equipment_r e 
    WHERE h.name=e.name;

    Visual Explain displays a hash, a hash join, and some sequence scans.

  6. Finally, run the SQL command:

    SELECT h.person, h.name FROM hobbies_r h WHERE (SELECT count(*) 
       FROM equipment_r e WHERE h.name=e.name) >= 2;

    Visual Explain display now contans a subplan.

Understanding the Visual Explain Output

The table that follows describes the Visual Explain icons.

Manipulating the Visual Explain Display

You can rotate the display by clicking on the "orientation" buttons (or from the View menu, select Orientation -> direction). You can zoom in or out by clicking on the "zoom" buttons (or from the View menu, select Zoom In or Zoom Out, or by choosing a value from the xx% drop-down list).

Depending on the amount of information in the plan and the size of the icons used in the display, you may not be able to view the entire plan at one time. To move the viewing area to another part of the plan, first open the Plan Overview window. The blue rectangle shows the current view in the main panel. To move the view to another area, click in that area in the Plan Overview. (Note that grayed areas are not accessible.)