4.4. Tutorial

An excellent way to understand the functionality of a tool is through a tutorial. The following section is a tutorial on how to use Visual Explain.

It is assumed that during the installation of PostgreSQL - Red Hat Edition, the post-installer was run. This created the postgres userid and created a database cluster in /var/lib/pgsql/data. It is also assumed that Visual Explain was started by the superuser postgres.

Visual Explain uses JDBC to communicate with the PostgreSQL server and requires the use of TCP/IP. The following tutorial assumes that TCP/IP has been enabled and that the trust host-based authentication will allow connections from all locations. If you are unsure as to how to modify your PostgreSQL installation, refer to Section 6.4.3 Modifying Database Cluster Configuration Files for details on how to modify these values.

Topics covered in this tutorial are:

4.4.1. Configuring a Connection

After you start Visual Explain (as described in Section 4.2 Starting Visual Explain), the next task is to configure a connenction to a database.

To add a database to the tool, from the Menu Bar choose Edit => Databases.

Figure 4-7. Accessing the Edit Database Connections Dialog

The Edit Database Connections dialog appears.

Figure 4-8. The Edit Database Connections Dialog

In the Edit Database Connections dialog, select New, which brings up the New Database dialog. Note that this does not create a new database, just a new connection configuration for an existing database. The Nickname entered in this dialog will be displayed on the Toolbar. The example uses a nickname of tutorial, connects to the local host's regression database on port 5432, and uses userid postgres.

Figure 4-9. The New Database Dialog

Select OK to add this configuration to the list of possible database choices in the Edit Database Connections dialog.

Figure 4-10. The Updated Edit Database Connections Dialog

Select OK to close the Edit Database Connections dialog.

4.4.2. Connecting to a Database

After configuring a connection, the next task is to connect Visual Explain to the configured database.

On the top at the far right of the Toolbar, the Database combo-box contains a list of configured databases.

Figure 4-11. Valid Configured Database Connections

Select tutorial and you will be connected to the regression database on the local host. Notice the Status Bar has been updated with the connection information.

4.4.3. Entering a Query

Now that you are connected to the regression database, you are able to submit queries through Visual Explain. In the SQL Entry Area type:

select * from b_star;

and select the Explain/Explain Analyze icon on the Toolbar. The resultant EXPLAIN tree is now displayed graphically in the View Pane.

Figure 4-12. Simple Select Rendering

Notice that selecting different nodes in the resultant tree causes the Detail Pane to update with information specific to the highlighted node.