12.07.2015 Views

Oracle SQL Developer

Oracle SQL Developer

Oracle SQL Developer

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Managing IndexesThis is because the first uses an index on COL_X (assuming that COL_X is anumeric column).Columns with the following characteristics are less suitable for indexing:■ There are many nulls in the column and you do not search on the non-null values.The size of a single index entry cannot exceed roughly one-half (minus someoverhead) of the available space in the data block. Consult with the databaseadministrator for assistance in determining the space required by an index.4.3.3.2 Limit the Number of Indexes for Each TableThe more indexes, the more overhead is incurred as the table is altered. When rows areinserted or deleted, all indexes on the table must be updated. When a column isupdated, all indexes on the column must be updated.You must weigh the performance benefit of indexes for queries against theperformance overhead of updates. For example, if a table is primarily read-only, youmight use more indexes; but, if a table is heavily updated, you might use fewerindexes.4.3.3.3 Choose the Order of Columns in Composite IndexesAlthough you can specify columns in any order in the CREATE INDEX command, theorder of columns in the CREATE INDEX statement can affect query performance. Ingeneral, you should put the column expected to be used most often first in the index.You can create a composite index (using several columns), and the same index can beused for queries that reference all of these columns, or just some of them.For example, assume the columns of the vendor_parts table are as follows:vendor_id part_no unit_cost1010 10-440 0.271010 10-457 5.101012 08-300 1.191012 10-440 0.251012 10-441 0.391012 10-457 4.961220 08-300 1.331292 10-457 5.29Assume that there are five vendors, and each vendor has about 1000 parts. Supposethat the vendor_parts table is commonly queried by <strong>SQL</strong> statements such as thefollowing:SELECT * FROM vendor_partsWHERE part_no = 457 AND vendor_id = 1012;To increase the performance of such queries, you might create a composite indexputting the most selective column first; that is, the column with the most values:CREATE INDEX ind_vendor_id ON vendor_parts (part_no, vendor_id);Composite indexes speed up queries that use the leading portion of the index. So inthis example, queries with WHERE clauses using only the part_no column also note aperformance gain. Because there are only five distinct values, placing a separate indexon vendor_id would serve no purpose.Database Objects: Usage Information 4-9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!