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...

RESOLVING SHUTDOWN IMMEDIATE HANG SITUATIONS

Many times Oracle DBA's are often faced with situation where shutting down the instance with shutdown immediate seems to take infinite time and gives an impression that the session in hung. In most of the cases this is not a hang. Hang can be defined as a scenario when few sessions/processes are waiting on some action and in turn blocking other session/processes to complete their tasks. Now the original sessions could be waiting because of resource issues or Oracle Bugs. Shutdown immediate can take long time to complete (appear to be hung) because of three reasons: Uncommitted transactions are being rolled back. SMON is cleaning temp segments or performing delayed block clean-outs. Processes still continue to be connected to the database and do not terminate. 1. Uncommitted transactions are being rolled back: This is the case when the message 'Waiting for smon  to disable tx recovery' is posted in the alert log after we issue shutdown immediate. There ...

Step by Step Installation of Oracle Database 12c on Solaris 10

In this article we will look at Installing Oracle 12C database on Solaris x86 64bit version. This article assumes that you already had Solaris 10 installed on Virtualbox. Preparing System for Installation The first step toward Oracle installation is to perform the pre-installation tasks. Configuring hosts file The first step is to properly name your host machine. The hostname should properly be provided with IP address for installation to continue. Ideally, your /etc/hosts file should look something like this. 192.168.34.47   sol10.cm 127.0.0.1 localhost Kernel Parameters The default installation of Solaris 10 is normally good enough for oracle database installation. You just have to configure one parameter. Use the command below to set the required kernel parameters. Remember that you will have to use the root login to run the commands. # projadd  -K "project.max-shm-memory=(privileged,4G,deny)" user.oracle To confirm that parameter has be...