| Lesson 7 |
Understanding domain indexing |
| Objective |
Describe the Oracle feature of domain indexes. |
Domain Indexes in Oracle 23ai
Oracle’s standard index types (such as B-tree and bitmap) work well when a SQL predicate can be evaluated using built-in comparison logic. However, modern applications often search domain-specific data: text documents, geospatial objects, JSON documents, images, or other data types that require specialized operators and search logic.
A domain index is Oracle’s extensible indexing mechanism that lets an application plug custom indexing and search behavior into the SQL engine. In practice, most DBAs and developers encounter domain indexes through Oracle-supplied implementations such as Oracle Text and Oracle Spatial, but the framework also supports user-defined “cartridges” for specialized domains.
What Makes a Domain Index Different?
A domain index differs from a conventional index in two important ways:
-
Operator-driven access: The index is designed to accelerate predicates that use specialized operators (for example, text search,
spatial relationships, or domain-specific comparison functions).
-
Indextype implementation: The indexing logic is encapsulated in an indextype, which defines how the index is created,
maintained, and scanned. Oracle calls into the indextype implementation when SQL requires the domain index.
Conceptually, an indextype provides the “contract” between Oracle SQL and the domain index implementation: create/build routines, maintenance routines for DML, and scan routines to return matching ROWIDs (or their equivalent) for the query.
Common Oracle Domain Index Examples
Domain indexing is commonly used for:
- Text search (Oracle Text): full-text search, linguistic matching, fuzzy search, and document relevance ranking.
- Spatial search (Oracle Spatial / Spatial and Graph): “within distance,” “intersects,” “contains,” and other geometric operators.
- Specialized application domains: any custom search problem where “equality” and “range” comparisons are not sufficient.
Oracle 23ai continues to support these extensibility patterns while also expanding “built-in” indexing options for newer workloads (for example,
JSON-centric and AI-driven applications). The key idea remains: when the predicate requires specialized semantics, a domain index can avoid
expensive full scans and repeated evaluation of complex operators.
Example: Creating a Domain Index (Oracle Text)
The following example shows a domain index created using Oracle Text. The index uses an Oracle-supplied indextype:
CREATE INDEX my_text_idx
ON documents(doc_content)
INDEXTYPE IS CTXSYS.CONTEXT;
Once created, queries that use Oracle Text operators can leverage the domain index to rapidly locate matching documents without scanning the
entire table.
How Domain Indexing Works at Runtime
When a SQL statement includes a predicate that can use a domain index, Oracle’s SQL engine invokes the indextype implementation to perform
the index scan. The domain index implementation returns candidate row identifiers, and Oracle applies any remaining filters as needed.
This integration is what makes domain indexes valuable: you can keep the SQL interface familiar while delegating complex search logic to a
purpose-built indexing engine.
Indextypes and Domain Indexes
A domain index is created from an
indextype. An indextype is a schema object that encapsulates:
- Index definition routines (how the index is created and structured)
- Index maintenance routines (how DML changes are reflected in the index)
- Index scan routines (how matching rows are found for domain operators)
Domain indexes can store their internal structures in Oracle tables (commonly as index-organized or regular tables) and, depending on the
implementation, may also reference external storage formats. The exact structure is driven by the domain and the indextype implementation.
System-Managed vs. User-Managed Domain Indexes
Modern Oracle releases favor system-managed domain indexes, where Oracle performs more of the maintenance and orchestration work
on behalf of the domain index implementation. This reduces custom code burden and generally improves scalability, especially when partitioning is
involved. From an operational standpoint, the benefit is that domain indexes behave more like first-class index citizens: maintenance operations
integrate more cleanly with Oracle’s storage and partitioning features.
As a best practice, if you are building a new domain index solution today, use the system-managed approach and follow the supported indextype
APIs for extensible indexing.
When Should You Consider Domain Indexes?
Domain indexes are a strong fit when:
- Your queries require specialized operators that are expensive to evaluate row-by-row.
- Your data type does not map cleanly to standard relational comparison semantics.
- You need scalable search over large volumes of text, spatial objects, or domain-specific content.
In the next lesson, you will learn how Oracle supports online index maintenance operations to reduce downtime during index management tasks.
