Category: Auto Indexing Wrap-Up

Character Strings-Datatypes

There are four basic character string types in Oracle, namely, CHAR, VARCHAR2, NCHAR, and NVARCHAR2. All of the strings are stored in the same format in Oracle. On the database block, they will have a leading length field of 1–3 bytes followed by the data; when they are NULL, they will be represented as a Read More

NLS Overview-Datatypes-2

Notice how in the 7-bit session I received the letter “a” three times with no diacritical marks. However, the DUMP function is showing me that in the database there are, in fact, three separate distinct characters, not just the letter “a.” The data in the database hasn’t changed—just the values this client received. If this Read More

Automatic Indexing in Action-Indexes

Now that you have some background with the automatic indexing feature, let’s enable it and see how it works:$ sqlplus system/foo@PDB1SQL> exec dbms_auto_index.configure(‘AUTO_INDEX_MODE’,’IMPLEMENT’); PL/SQL procedure successfully completed. Next, I’ll create a table to test with:$ sqlplus eoda/foo@PDB1SQL> create table d (d varchar2(30));Table created. Now I’ll insert some random number data into this table:SQL> insert into Read More

Managing Automatic Indexing-Indexes

Automatic indexing is managed via the internal DBMS_AUTO_INDEX PL/SQL package. The default mode of automatic indexing is REPORT ONLY. In this mode, automatic indexing is on, but any indexes it creates are invisible (meaning the indexes won’t be used by the optimizer). You can enable/disable indexing at the root container level or at the pluggable Read More

Automatic Indexing-Indexes

Starting with version 19c, the Oracle database ships with an automatic indexing feature. This allows you to delegate some index management features to the database. This feature creates, rebuilds, and drops indexes based on the workload of your application. Indexes that are managed by this feature are known as auto indexes. Here are the main Read More

Why Isn’t My Index Getting Used?-Indexes-2

Case 4We have indexed a character column. This column contains only numeric data. We query using the following syntax:SQL> select * from t where indexed_column = 5 Note that the number 5 in the query is the constant number 5 (not a character string). The index on INDEXED_COLUMN is not used. This is because the Read More

Should Foreign Keys Be Indexed?-Indexes

The question of whether or not foreign keys should be indexed comes up frequently. We touched on this subject in Chapter 6 when discussing deadlocks. There, I pointed out that unindexed foreign keys are the biggest single cause of deadlocks that I encounter, due to the fact that an update to a parent table’s primary Read More

Virtual Column Solution-Indexes

The idea here is to first create a virtual column applying a SQL function on the extended column that returns a value less than 6398 bytes. Then that virtual column can be indexed, and this provides a mechanism for better performance when issuing queries against extended columns. An example will demonstrate this. First, create a Read More

Invisible Indexes-Indexes

You have the option of making an index invisible to the optimizer. The index is only invisible in the sense that the optimizer won’t use the index when creating an execution plan. You can either create an index as invisible or alter an existing index to be invisible. Here, we create a table, load it Read More

Implementing Selective Uniqueness-Indexes

Another useful technique with function-based indexes is to use them to enforce certain types of complex constraints. For example, suppose you have a table with versioned information, such as a projects table. Projects have one of two statuses: either ACTIVE or INACTIVE. You need to enforce a rule such that “Active projects must have a Read More

1 2