This section contains the following topics that will help you understand the graphics in VST diagrams:
Viewing the Diagram Legend
Click the Diagram Legend Toggle button as shown in the diagram below to see a description of the icons and relationship lines used in VST diagrams.
The color of the index entries in the Collect and Create Indexes table is interpreted as follows:
|Index is used in the query.|
|Index is usable but not used by the current execution path.|
|This index is missing. SQL Query Tuner recommends that you create this index.|
|This index exists on the table but not usable in this query as it is written.|
Joins are represented with connecting lines between nodes. You can move tables in the diagram by clicking and dragging them to the desired location. The position of the connecting lines is automatically adjusted. The following describes when a particular type of connecting line is used and the default positioning of the line.
|Connecting Lines||When Used|
|One-to-One join relationships are graphed horizontally using blue lines. For more information, see One-to-One Join.|
|One-to-Many join relationships are graphed with the many table above the one table. For more information, see One-to-Many Join.|
|Cartesian Join shows the table highlighted in red with no connectors to indicate that it is joined in via a Cartesian join. For more information, see Cartesian Join.|
|Many-to-Many Join relationships are connected by a red line and the relative location is not restricted. For more information, see Many-to-Many Join.|
|Indirect Relationship. For more information, see Indirect Relationship.|
|Outer Join. For more information, see Outer Join.|
|Unique. For more information, see Unique.|
Not Exists and Not in relationship lines connect the subquery to the table being queried.
Notice that when you click this relationship line, the SQL text creating the relationship is also selected. For more information, see Not In or Not Exists Join.
Exists and In relationship lines connect the subquery to the table being queried.
Notice that when you click this relationship line, the SQL text creating the relationship is also selected. For more information, see In or Exists Join.
If two tables are joined on their primary key, then graphically, these would be laid out side-by- side, with a one-to-one connector:
This is the default positioning of a one-to-many relationship, where INVESTMENT_TYPE is the master table and INVESTMENT is the details table.
The following is an example of a query that consists of only many-to-one joins, which is more typical:
ct.client_id = c.client_id AND
ct.investment_id = i.investment_id AND
i.investment_type_id = it.investment_type_id and
A Cartesian join is described in the following example where the query is missing join criteria on the table INVESTMENT:
A.BROKER_ID BROKER_ID, A.BROKER_LAST_NAME
YEARS_WITH_FIRM, C.OFFICE_NAME OFFICE_NAME,
SUM (B.BROKER_COMMISSION) TOTAL_COMMISSIONS
A.BROKER_ID = B.BROKER_ID AND
A.OFFICE_LOCATION_ID = C.OFFICE_LOCATION_ID
Graphically, this looks like:
INVESTMENT is highlighted in red with no connectors to indicate that it is joined in via a Cartesian join.
Possible missing join conditions are displayed in the Overview tab under Generated Cases in the transformations area. DB Optimize recommends that you create these joins.
Transformations are highlighted in yellow.
Implied Cartesian Join
If there are different details for a master without other criteria then a Cartesian-type join is created:
The result set of BROKER to CLIENT will be multiplied by the result set of INVESTMENT to CLIENT.
If there is no unique index at either end of a join then it can be assumed that in some or all cases the join is many-to-many; there are no constraints preventing a many-to-many join. For example, examine the following query:
client_transaction ct, client c
There is no unique index on either of the fields being joined so the optimizer assumes this is a many-to-many join and the relationship is displayed graphically as:
If one of the fields is unique, then the index should be declared as such to help the optimizer.
Indirect relationships are produced by the following SQL, where BIG_STATEMENT2 is a Materialized View.
CS.ZIP > '75062' AND MR.RENTALID = RI.RENTALID
AND RI.ITEMNUMBER = OE.BIG_STATEMENT2.ITEMNUMBER
AND MR.CUSTOMERID = CS.CUSTOMERID;
The following diagram produced by the SQL above shows that an indirect relationship exists between the RENTALITEM(RI) tables inside and outside the materialized view, BIG_STATEMENT2. An indirect relationship also exists between MOVIERENTAL (MR) inside BIG_STATEMENT2 and MOVIERENTAL(MR) inside the RENT_VIEW1 view.
In or Exists Join
The following SQL contains a nest IN subquery (shown in bold text) that is graphically represented with the Subquery summary icon and the IN join.
cs.customerid, cs.firstname, cs.lastname,
mr.rentalid, mr.duedate, mr.totalcharge, ri.itemnumber
c1.customerid, c1.firstname, c1.lastname, c1.phone
EXISTS (SELECT NULL) cs, (FROM MOVIES.customer c2
c1.customerid <>c2.customerid AND c1.lastname=c2.lastname AND c1.phone BETWEEN 0 AND 9999569900)
customerid, rentalid, duedate, totalcharge, rentaldate
totalcharge > 10
mr, MOVIES.rentalitem ri
LENGTH (cs.lastname) = 10
AND 1 < cs.customerid
AND ROUND (ri.rentalid) > 10
AND TRUNC (ri.itemnumber) > 1
AND mr.totalcharge > (SELECT AVG (totalcharge)
TOTALCHARGE >= 40)
NOT IN (SELECT mc.moviecopyid FROM MOVIES.moviecopy mc
mc.copyformat = 'vhs'
AND mc.copycondition = 'new'
AND mc.movieid IN (SELECT mt.movieid FROM MOVIES.movietitle mt
mt.year < 1990
AND mt.rating IN ('pg','r')
AND mt.categoryid IN (SELECT mc.categoryid
mc.rentalprice=(SELECT MAX (rentalprice)
The bold SQL predicate in the statement below defines the outer join between customer and movierental.
from MOVIES.customercs, MOVIES.movierentalmr
length (cs.lastname) = 8 and cs.zip > 75062 and 1 < cs.customerid + 2 and cs.phone between 9625569900 and 9999569900 and mr.rentalid = (select max (ri.rentalid)
from MOVIES.rentalitem ri, MOVIES.moviecopy mc
ri.itemnumber > 1 and mc.moviecopyid = 700) and mr.customerid(+)=cs.customerid;
The following screen shot illustrates how the outer join is displayed in the VST diagram.
The subquery below illustrates a unique relationship between two primary keys.
...select max(rentalprice) from MOVIES.moviecategory where categoryid = mc.categoryid...
Not In or Not Exists Join
The following SQL contains a NOT IN subquery (shown in bold below) that is graphically represented with the Subquery summary icon and the NOT IN join.
CS.ZIP > '75062'
AND MR.RENTALID NOT IN (SELECT MAX ( MOVIES.BIG_STATEMENT5.CUSTOMERID)
Graphically, this statement would look like this:
Viewing Object SQL
Hover over the name of an object to view the object SQL as shown in the diagram below.
Refreshing Tuning Statements
At times you may see an error on the Overview page, which when you mouse over it, indicates that the tuning statements are out of sync and need to be refreshed. This can happen, for example, if you tune a statement, then delete it, and insert another SQL query for tuning.
To refresh the tuning statements
In the Tuning Statements area of the Overview tab, right-click the tuning statement and select Refresh Tuning Statements.
Refreshing the VST Diagram
There are two refresh options available: Refresh and Refresh All. Click the Refresh list as shown below to gain access to these options.
- Refresh: Regenerates the Analysis tab including the VST diagram. Any changes made on the tab are reflected in the diagram.
- Full Refresh: Re-caches all objects used in (or related to) the query, then regenerates the Analysis tab including the VST diagram. This option is typically used when the underlying objects have been recently changed.