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 Indexesuseful when all of the columns are likely to be included in the WHERE clause offrequently executed <strong>SQL</strong> statements.For concatenated indexes, you should define the columns used in the index carefullyso that the column with the fewest duplicate values is named first, the column withnext fewest duplicate values is second, and so on. Columns with many duplicatevalues or many rows with NULL values should not be included or should be thelast-named columns in the index definition.4.3.3 Guidelines for Creating IndexesYou can create indexes on columns to speed up queries. Indexes provide faster accessto data for operations that return a small portion of a table's rows.In general, you should create an index on a column in any of the following situations:■■The column is queried frequently.A referential integrity constraint exists on the column.■ A UNIQUE key integrity constraint exists on the column.You can create an index on any column; however, if the column is not used in any ofthese situations, creating an index on the column does not increase performance andthe index takes up resources unnecessarily.Although the database creates an index for you on a column with an integrityconstraint, explicitly creating an index on such a column is recommended.4.3.3.1 Index the Correct Tables and ColumnsUse the following guidelines for determining when to create an index:■■■Create an index if you frequently want to retrieve less than about 15% of the rowsin a large table. This threshold percentage varies greatly, however, according to therelative speed of a table scan and how clustered the row data is about the indexkey. The faster the table scan, the lower the percentage; the more clustered the rowdata, the higher the percentage.Index columns that are used for joins to improve join performance.Primary and unique keys automatically have indexes, but you might want tocreate an index on a foreign key. See "Foreign Key" on page 4-6 for moreinformation.■ Small tables do not require indexes; if a query is taking too long, then the tablemight have grown from small to large.Some columns are strong candidates for indexing. Columns with one or more of thefollowing characteristics are good candidates for indexing:■■■Values are unique in the column, or there are few duplicates.There is a wide range of values (good for regular indexes).The column contains many nulls, but queries often select all rows having a value.In this case, a comparison that matches all the non-null values, such as:WHERE COL_X >= -9.99 *power(10,125)is preferable toWHERE COL_X IS NOT NULL4-8 <strong>SQL</strong> <strong>Developer</strong> Online Help

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

Saved successfully!

Ooh no, something went wrong!