DOMINO AND DB2
Indexes optimize two operations in IBM® DB2 Universal Database™ Enterprise Server Edition: table scans and sorts. To understand how indexes optimize table scans, assume you have this SQL statement:
Option Two -- Using two indexes, one with From and one with #modified also avoids accessing rows. The indexes also optimize other queries where the column From or #modified is used in the WHERE clause without the other column.
The following SQL statement generates a sort unless you have an index without all four columns in it, in the order in which they appear in the clause ORDER BY.
For more information about SQL (DB2 monitor) snapshots, see the topic Generating a database monitor snapshot.
In general, you may want to use an index if you generate an SQL (DB2 monitor) snapshot and the snapshot data shows that you have a slow running query and one or both of the following values is high:
For information about access plans, see the topic Using SQL Assist to create an SQL statement.
Using an index to automatically order columns
Use indexing to automatically order columns. In an index, column-name identifies a column that is to be part of the index key.
1. Open the DB2 Control Center.
2. Click All Databases, and then locate the initial DB2 database you created. If you did not change the default database name, the name is DOMINO.
3. Open the database, and then click Tables.
4. Select the table whose columns you are indexing, and then right click the mouse.
5. Choose Create Index. The Create Index dialog box appears.
7. (Optional) The Include columns list box is activated when you select the Unique check box. Use the Include columns list box to select additional columns to be included in the index, but not as part of the unique index key.
Note For information about the fields on the Create Index dialog box, see the DB2 Information Center at http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/core/db2idxA.htm.
8. When complete, click OK.
See also