Skip to main content

Aspects of Implementing and Maintaining Indexes

There are various aspects of implementing and maintaining indexes. The table below summarizes some to the guidelines and techniques for creating indexes.


Guideline Reasoning
Create as many indexes as you need, but try to keep the number to a minimum. Add indexes judiciously. Test first to determine quantifiable performance gains. Indexes increase performance, but also consume disk space and processing resources. Don’t add indexes unnecessarily.
The required performance of queries you execute against a table should form the basis of your indexing strategy. Indexing columns used in SQL queries will help performance the most.
Consider using the SQL Tuning Advisor or the SQL Access Advisor for indexing recommendations. These tools provide recommendations and a second set of "eyes" on your indexing decisions.
Create primary key constraints for all tables. This will automatically create a B-tree index (if the columns in the primary key aren’t already indexed).
Create unique key constraints where appropriate. This will automatically create a B-tree index (if the columns in the unique key aren’t already indexed).
Create indexes on foreign key columns. Foreign key columns are usually included in the WHERE clause when joining tables and thus improve performance of SQL SELECT statements. Creating a B-tree index on foreign key columns also reduces locking issues when updating and inserting into child tables.
Carefully select and test indexes on small tables (small being fewer than a few thousand rows). Even on small tables, indexes can sometimes perform better than full-table scans.
Use the correct type of index. Correct index usage maximizes performance. See Table 8-1 for more details.
Use the basic B-tree index type if you don’t have a verifiable performance gain from using a different index type. B-tree indexes are suitable for most applications in which you have high-cardinality column values.
Consider using bitmap indexes in data warehouse environments. These indexes are ideal for low-cardinality columns in which the values aren’t updated often. Bitmap indexes work well on foreign key columns on star schema fact tables in which you often run queries that use AND and OR join conditions.
Consider using a separate tablespace for indexes (i.e., separate from tables). Table and index data may have different storage or backup and recovery requirements, or both. Using separate tablespaces lets you manage indexes separately from tables.
Let the index inherit its storage properties from the tablespace. This makes it easier to manage and maintain index storage.
Use consistent naming standards. This makes maintenance and troubleshooting easier.
Don’t rebuild indexes unless you have a solid reason to do so. Rebuilding indexes is generally unnecessary unless an index is corrupt or unusable or you want to move an index to different tablespace.
Monitor your indexes, and drop those that aren’t used. Doing this frees up physical space and improves the performance of DML statements.
Before dropping an index, consider marking it unusable or invisible. This allows you to better determine if there are anyperformance issues before you drop the index. These options let you rebuild or reenable the index without requiring the DDL creation statement.

These recommendations are intended to help you correctly use indexes as you create and manage indexes in your database environment. 

Comments

Popular posts from this blog

Oracle Database 19c Step by Step Installation On Oracle Linux 7.6

This post describes the installation of Oracle Database 19c 64-bit on Oracle Linux 7.6  x86-64 bit. The Linux server needs a minimum of 3G swap and secure Linux set to permissive. An example of this type of Linux installation can be seen here . Download Software Download the Oracle software from oracle edelivery . Oracle Installation Prerequisites Automatic Setup Use the "oracle-database-preinstall-19c" package to perform all your prerequisite setup. # yum install -y oracle-database-preinstall-19c If you are using RHEL7 or CentOS7, you can pick up the PRM from the OL7 repository and install it. It will pull the dependencies from your normal repositories. # yum install -y https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm Hosts File Set a fully qualified name for the server in the "/etc/hosts" file. < IP-address > < fully-qualified-machine-name > < machin...

How to Delete Old Trace & Dump files with ADRCI

The ADRCI command interpreter has multiple features:- Create a package with incident or problem information for Oracle Support Analyze diagnostic data within the Automatic Diagnostic Repository (ADR) Run health checks In this post, we'll be concentrating on deleting the old diagnostic files with ADRCI. Set your environment and run the ADRCI utility: $ adrci Use the following command to list the ADR homes: adrci> show home ADR Homes: diag/rdbms/db11g/DB11G diag/tnslsnr/sol10/listener Choose the ADR home from the list above: adrci> set home diag/rdbms/db11g/DB11G Check the current retention policy: adrci> show control Check the following columns in the output: LONGP_POLICY:- It is set to 365 days by default. It is responsible for Incidents and Health Monitor warnings. SHORTP_POLICY:- It is set to 30 days by default. It manages the trace and core dump files. Use the following commands to change the retention policy: Specify the time in hours: 10 Days = 240 ...

Oracle Database 12C Error Codes, Solutions and Suggestions from ORA-19700 to ORA-20000

Oracle 12C Error Codes, Solutions and Suggestions from ORA 19700 to ORA 20000 ORA-19700: device type exceeds maximum length of string Cause:  The device type indicated is invalid. Action:  Supply a correct device type and retry the allocation. ORA-19701: device name exceeds maximum length of  string Cause:  The device name indicated is invalid. Action:  Supply a correct device name and retry the allocation. ORA-19702: device parameter exceeds maximum length of  string ORA-19703: device command string exceeds maximum length of  string Cause:  The device command string exceeds maximum length. Action:  Correct the command and retry the operation. ORA-19704: file name exceeds maximum length of  string Cause:  The specified file name, which was a parameter to a copy, backup, or restore operation, exceeds the maximum file name length for this operating system. Action:  Retry the operation with a s...