Oracle® Text Application Developer's Guide 10g Release 2 (10.2) Part Number B14217-01 |
|
|
View PDF |
This chapter discusses how to improve your query and indexing performance. The following topics are covered:
Query optimization with statistics uses the collected statistics on the tables and indexes in a query to select an execution plan that can process the query in the most efficient manner. As a general rule, Oracle recommends that you collect statistics on your base table if you are interested in improving your query performance.
The optimizer attempts to choose the best execution plan based on the following parameters:
The selectivity on the CONTAINS
predicate
The selectivity of other predicates in the query
The CPU and I/O costs of processing the CONTAINS
predicates
Note: Importing and exporting of statistics on domain indexes, including Oracle Text indexes, is not supported with theDBMS_STATS package. For more information on importing and exporting statistics, see the PL/SQL Packages and Types Reference guide. |
The following sections describe how to use statistics with the extensible query optimizer. Optimizing with statistics enables a more accurate estimation of the selectivity and costs of the CONTAINS
predicate and thus a better execution plan.
By default, Oracle Text uses the cost-based optimizer to determine the best execution plan for a query. To allow the optimizer to better estimate costs, you can calculate the statistics on the table you query. To do so, issue the following statement:
ANALYZE TABLE <table_name> COMPUTE STATISTICS;
Alternatively, you can estimate the statistics on a sample of the table as follows:
ANALYZE TABLE <table_name> ESTIMATE STATISTICS 1000 ROWS;
or
ANALYZE TABLE <table_name> ESTIMATE STATISTICS 50 PERCENT;
You can also collect statistics in parallel with the DBMS_STATS.GATHER_TABLE_STATS
procedure.
begin
DBMS_STATS.GATHER_TABLE_STATS('owner', 'table_name', estimate_percent=>50, block_sample=>TRUE, degree=>4) ;
end ;
These statements collect statistics on all the objects associated with table_name including the table columns and any indexes (b-tree, bitmap, or Text domain) associated with the table.
To re-collect the statistics on a table, you can issue the ANALYZE
command as many times as necessary or use the DBMS_STATS
package
By collecting statistics on the Text domain index, the Oracle Database cost-based optimizer is able to do the following:
estimate the selectivity of the CONTAINS
predicate
estimate the I/O and CPU costs of using the Text index, that is, the cost of processing the CONTAINS
predicate using the domain index
estimate the I/O and CPU costs of each invocation of CONTAINS
Knowing the selectivity of a CONTAINS
predicate is useful for queries that contain more than one predicate, such as in structured queries. This way the cost-based optimizer can better decide whether to use the domain index to evaluate CONTAINS
or to apply the CONTAINS
predicate as a post filter.
See Also:
|
Consider the following structured query:
select score(1) from tab where contains(txt, 'freedom', 1) > 0 and author = 'King' and year > 1960;
Assume the author
column is of type VARCHAR2
and the year
column is of type NUMBER
. Assume that there is a b-tree index on the author
column.
Also assume that the structured author
predicate is highly selective with respect to the CONTAINS
predicate and the year predicate. That is, the structured predicate (author = 'King'
) returns a much smaller number of rows with respect to the year
and CONTAINS
predicates individually, say 5 rows returned versus 1000 and 1500 rows respectively.
In this situation, Oracle Text can execute this query more efficiently by first doing a b-tree index range scan on the structured predicate (author = 'King'
), followed by a table access by rowid, and then applying the other two predicates to the rows returned from the b-tree table access.
Note: When statistics are not collected for a Text index, the cost-based optimizer assumes low selectivity and index costs for theCONTAINS predicate. |
After synchronizing your index, you can re-collect statistics on a single index to update the cost estimates.
If your base table has been re-analyzed before the synchronization, it is sufficient to analyze the index after the synchronization without re-analyzing the entire table.
To do so, you can issue any of the following statements:
ANALYZE INDEX <index_name> COMPUTE STATISTICS; or ANALYZE INDEX <index_name> ESTIMATE STATISTICS SAMPLE 1000 ROWS; or ANALYZE INDEX <index_name> ESTIMATE STATISTICS SAMPLE 50 PERCENT;
By default, Oracle Text optimizes queries for throughput. This results in queries returning all rows in shortest time possible.
However, in many cases, especially in a Web application scenario, queries must be optimized for response time, when you are only interested in obtaining the first few hits of a potentially large hitlist in the shortest time possible.
The following sections describe some ways to optimize CONTAINS
queries for response time:
Improved Response Time with FIRST_ROWS(n) for ORDER BY Queries
Improved Response Time using Local Partitioned CONTEXT Index
Improved Response Time with Local Partitioned Index for Order by Score
There are other factors that can influence query response time such as:
Collection of table statistics
Memory allocation
Sorting
Presence of LOB columns in your base table
Partitioning
Parallelism
The number term expansions in your query
When you need the first rows of an ORDER BY
query, Oracle recommends that you use this new fully cost-based hint in place of FIRST_ROWS
.
Note: As this hint is cost-based, Oracle recommends that you collect statistics on your tables before you use this hint. See "Collecting Statistics" in this chapter. |
You use the FIRST_ROWS(n) in cases where you want the first n number of rows in the shortest possible time. For example, consider the following PL/SQL block that uses a cursor to retrieve the first 10 hits of a query and uses the FIRST_ROWS(n)
hint to optimize the response time:
declare cursor c is select /* FIRST_ROWS(10) */ article_id from articles_tab where contains(article, 'Omophagia')>0 order "by pub_date desc; begin
for i in c loop insert into t_s values(i.pk, i.col); exit when c%rowcount > 11; end loop;
end; /
The cursor c is a SELECT
statement that returns the rowids that contain the word omophagia in sorted order. The code loops through the cursor to extract the first 10 rows. These rows are stored in the temporary table t_s
.
With the FIRST_ROWS
hint, Oracle Text instructs the Text index to return rowids in score-sorted order, if possible.
Without the hint, Oracle Text sorts the rowids after the Text index has returned all the rows in unsorted order that satisfy the CONTAINS
predicate. Retrieving the entire result set as such takes time.
Since only the first 10 hits are needed in this query, using the hint results in better performance.
Note: Use theFIRST_ROWS(n) hint when you need only the first few hits of a query. When you need the entire result set, do not use this hint as it might result in poor performance. |
You can also optimize for response time using the related FIRST_ROWS
hint. Like FIRST_ROWS(n)
, when queries are optimized for response time, Oracle Text returns the first rows in the shortest time possible.
For example, you can use this hint as follows
select /*+ FIRST_ROWS */ pk, score(1), col from ctx_tab where contains(txt_col, 'test', 1) > 0 order by score(1) desc;
However, this hint is only rule-based. This means that Oracle Text always chooses the index which satisfies the ORDER BY
clause. This might result in sub-optimal performance for queries in which the CONTAINS
clause is very selective. In these cases, Oracle recommends that you use the FIRST_ROWS(n)
hint, which is fully cost-based.
Partitioning your data and creating local partitioned indexes can improve your query performance. On a partitioned table, each partition has its own set of index tables. Effectively, there are multiple indexes, but the results from each are combined as necessary to produce the final result set.
You create the CONTEXT
index using the LOCAL
keyword:
CREATE INDEX index_name ON table_name (column_name) INDEXTYPE IS ctxsys.context PARAMETERS ('...') LOCAL
With partitioned tables and indexes, you can improve performance of the following types of queries:
This is a query that restricts the search to a particular range of values on a column that is also the partition key. For example, consider a query on a date range:
SELECT storyid FROM storytab WHERE CONTAINS(story, 'oliver')>0 and pub_date BETWEEN '1-OCT-93' AND '1-NOV-93';
If the date range is quite restrictive, it is very likely that the query can be satisfied by only looking in a single partition.
This is a query that requires only the first n hits and the ORDER BY
clause names the partition key. Consider an ORDER BY
query on a price column to fetch the first 20 hits such as:
SELECT * FROM (
SELECT itemid FROM item_tab WHERE CONTAINS(item_desc, 'cd player') >0 ORDER BY price) WHERE ROWNUM < 20;
In this example, with the table partitioned by price, the query might only need to get hits from the first partition to satisfy the query.
Using the FIRST_ROWS
hint on a local partitioned index might result in poor performance, especially when you order by score. This is because all hits to the query across all partitions must be obtained before the results can be sorted.
You can work around this by using an inline view when you use the FIRST_ROWS
hint. Specifically, you can use the FIRST_ROWS
hint to improve query performance on a local partitioned index under the following conditions:
The text query itself including the order by SCORE
() clause is expressed as an in-line view.
The text query inside the in-line view contains the FIRST_ROWS
or DOMAIN_INDEX_SORT
hint.
The query on the in-line view has ROWNUM
predicate limiting number of rows to fetch from the view.
For example, if you have the following text query and local text index created on a partitioned table doc_tab:
select doc_id, score(1) from doc_tab where contains(doc, 'oracle', 1)>0 order by score(1) desc;
and you are only interested in fetching top 20 rows, you can rewrite the query to
select * from (select /*+ FIRST_ROWS */ doc_id, score(1) from doc_tab where contains(doc, 'oracle', 1)>0 order by score(1) desc) where rownum < 21;
See Also:
|
Optimizing a query for throughput returns all hits in the shortest time possible. This is the default behavior.
The following sections describe how you can explicitly optimize for throughput.
By default, queries are optimized for throughput under the CHOOSE
and ALL_ROWS
modes. When queries are optimized for throughput, Oracle Text returns all rows in the shortest time possible.
In FIRST_ROWS
mode, the Oracle Database optimizer optimizes for fast response time by having the Text domain index return score-sorted rows, if possible. This is the default behavior when you use the FIRST_ROWS
hint.
If you want to optimize for better throughput under FIRST_ROWS
, you can use the DOMAIN_INDEX_NO_SORT
hint. Better throughput means you are interested in getting all the rows to a query in the shortest time.
The following example achieves better throughput by not using the Text domain index to return score-sorted rows. Instead, Oracle Text sorts the rows after all the rows that satisfy the CONTAINS
predicate are retrieved from the index:
select /*+ FIRST_ROWS DOMAIN_INDEX_NO_SORT */ pk, score(1), col from ctx_tab where contains(txt_col, 'test', 1) > 0 order by score(1) desc;
See Also: Oracle Database Performance Tuning Guide for more information about the query optimizer and using hints such asFIRST_ROWS and CHOOSE |
Oracle Text includes a tracing facility that enables you to identify bottlenecks in indexing and querying.
Oracle Text provides a set of predefined traces. Each trace is identified by a unique number. There is also a symbol in CTX_OUTPUT
for this number.
Each trace measures a specific numeric quantity—for instance, the number of $I
rows selected during text queries.
Traces are cumulative counters, so usage is as follows:
The user enables a trace.
The user performs one or more operations. Oracle Text measures activities and accumulates the results in the trace.
The user retrieves the trace value, which is the total value across all operations done in step 2.
The user resets the trace to 0.
The user starts over at Step 2.
So, for instance, if in step 2 the user runs two queries, and query 1 selects 15 rows from $I
, and query 2 selects 17 rows from $I
, then in step 3 the value of the trace would be 32 (15 + 17).
Traces are associated with a session—they can measure operations that take place within a single session, and, conversely, cannot make measurements across sessions.
During parallel sync or optimize, the trace profile will be copied to the slave sessions if and only if tracing is currently enabled. Each slave will accumulate its own traces and implicitly write all trace values to the slave logfile before termination.
For more information on tracing, see the Oracle Text Reference.
Oracle Text supports parallel query on a local CONTEXT
index. That is, based on the parallel degree of the index and various system attributes, Oracle Text determines number of parallel query slaves to be spawned to process the index. Each parallel query slave will process one or more index partitions. This is the default query behavior for local indexes created in parallel.
In general, parallel queries are good for DSS or analytical systems with large data collection, multiple CPUs, and low number of concurrent users.
However, for heavily loaded systems with high number of concurrent users, parallel query can result in degrading your overall query throughput. In addition, typical top N text queries with order by partition key column, such as
select * from ( select story_id from stories_tab where contains(...)>0 order by publication_date desc) where rownum <= 10;
will generally perform worse with a parallel query.
You can disable parallel querying after a parallel index operation with ALTER INDEX
command as follows
Alter index <text index name> NOPARALLEL; Alter index <text index name> PARALLEL 1;
You can also enable or increase the parallel degree by doing
Alter index <text index name> paralllel < parallel degree >;
Issuing a query with more than one predicate can cause a blocking operation in the execution plan. For example, consider the following mixed query:
select docid from mytab where contains(text, 'oracle', 1) > 0 AND colA > 5 AND colB > 1 AND colC > 3;
Assume that all predicates are unselective and colA, colB, and colC have bitmap indexes. The Oracle Database cost-based optimizer chooses the following execution plan:
TABLE ACCESS BY ROWIDS BITMAP CONVERSION TO ROWIDS BITMAP AND BITMAP INDEX COLA_BMX BITMAP INDEX COLB_BMX BITMAP INDEX COLC_BMX BITMAP CONVERSION FROM ROWIDS SORT ORDER BY DOMAIN INDEX MYINDEX
Since the BITMAP
AND
is a blocking operation, Oracle Text must temporarily save the rowid and score pairs returned from the Oracle Text domain index before executing the BITMAP
AND
operation.
Oracle Text attempts to save these rowid and score pairs in memory. However, when the size of the result set containing these rowid and score pairs exceeds the SORT_AREA_SIZE
initialization parameter, Oracle Text spills these results to temporary segments on disk.
Since saving results to disk causes extra overhead, you can improve performance by increasing the SORT_AREA_SIZE
parameter using ALTER
SESSION
as follows:
alter session set SORT_AREA_SIZE = <new memory size in bytes>;
For example, to set the buffer to approximately 8 megabytes, you can issue:
alter session set SORT_AREA_SIZE = 8300000;
See Also: Oracle Database Performance Tuning Guide and Oracle Database Reference for more information onSORT_AREA_SIZE |
This section answers some of the frequently asked questions about query performance.
Answer: There are generally two measures of query performance:
Response time, the time to get an answer to an individual query, and
Throughput, the number of queries that can be run in any time period; for example, queries each second).
These two are related, but are not the same. In a heavily loaded system, you normally want maximum throughput, whereas in a relatively lightly loaded system, you probably want minimum response time. Also, some applications require a query to deliver all its hits to the user, whereas others might only require the first 20 hits from an ordered set. It is important to distinguish between these two scenarios.
Answer: The fastest type of query will meet the following conditions:
Single CONTAINS
clause
No other conditions in the WHERE
clause
No ORDER BY
clause at all
Only the first page of results is returned (for example, the first 10 or 20 hits).
Answer: Yes. Collecting statistics on your tables enables Oracle Text to do cost-based analysis. This helps Oracle Text choose the most efficient execution plan for your queries.
Answer: The speed at which the text index can deliver ROWIDs is not affected by the actual size of the data. Text query speed will be related to the number of rows that must be fetched from the index table, number of hits requested, number of hits produced by the query, and the presence or absence of sorting.
Answer: The format of the documents (plain ascii text, HTML or Microsoft Word) should make no difference to query speed. The documents are filtered to plain text at indexing time, not query time.
The cleanliness of the data will make a difference. Spell-checked and sub-edited text for publication tends to have a much smaller total vocabulary (and therefore size of the index table) than informal text such as e-mails, which will contain many spelling errors and abbreviations. For a given index memory setting, the extra text takes up more memory, which can lead to more fragmented rows than in the cleaner text, which can adversely affect query response time.
Answer: There are two ways the kernel can query the text index. In the first and most common case, the kernel asks the text index for all the rowids that satisfy a particular text search. These rowids are returned in batches. In the second, the kernel passes individual rowids to the text index, and asks whether that particular rowid satisfies a certain text criterion.
The second is known as a functional lookup, and is most commonly done where there is a very selective structured clause, so that only a few rowids must be checked against the text index. An example of a search where a functional lookup may be used:
SELECT ID, SCORE(1), TEXT FROM MYTABLE
WHERE START_DATE = '21 Oct 1992' <- highly selective AND CONTAINS (TEXT, 'commonword') > 0 <- unselective
Functional invocation is also used for text query ordered by structured column (for example date, price) and text query is unselective.
Answer: All queries look at the index token table. Its name has the form DR$indexname$I
. This contains the list of tokens (column TOKEN_TEXT
) and the information about the row and word positions where the token occurs (column TOKEN_INFO
).
The row information is stored as internal DOCID values. These must be translated into external ROWID values. The table used for this depends on the type of lookup: For functional lookups, the $K
table, DR$indexname$K
, is used. This is a simple Index Organized Table (IOT) which contains a row for each DOCID/ROWID pair.
For indexed lookups, the $R
table, DR$indexname$R
, is used. This holds the complete list of ROWIDs in a BLOB column.
Hence we can easily find out whether a functional or indexed lookup is being used by examining a SQL trace, and looking for the $K or $R tables.
Note: These internal index tables are subject to change from release to release. Oracle recommends that you do not directly access these tables in your application. |
Answer: Yes, it certainly does.
If there is no sorting, then Oracle Text can return results as it finds them, which is quicker in the common case where the application needs to display only a page of results at a time.
Answer: Sorting by relevance (SCORE(n)
) can be extremely quick if the FIRST_ROWS(n)
hint is used. In this case, Oracle Text performs a high speed internal sort when fetching from the text index tables.
An example of such a query:
SELECT /*+ FIRST_ROWS(10) */ ID, SCORE(1), TEXT FROM MYTABLE WHERE CONTAINS (TEXT, 'searchterm', 1) > 0 ORDER BY SCORE(1) DESC;
Note that for this to work efficiently, there must be no other criteria in the WHERE
clause other than a single CONTAINS
.
Answer: For querying, you want to strive for a large system global area (SGA). You can set these parameters related to SGA in your Oracle Database initialization file. You can also set these parameters dynamically.
The SORT_AREA_SIZE
parameter controls the memory available for sorting for ORDER BY
queries. You should increase the size of this parameter if you frequently order by structured columns.
See Also:
|
Answer: Yes. Typically, a SELECT
statement selects more than one column from your base table. Since Oracle Text fetches columns to memory, it is more efficient to store wide base table columns such as LOBs out of line, especially when these columns are rarely updated but frequently selected.
When LOBs are stored out of line, only the LOB locators need to be fetched to memory during querying. Out of line storage reduces the effective size of the base table making it easier for Oracle Text to cache the entire table to memory. This reduces the cost of selecting columns from the base table, and hence speeds up text queries.
In addition, having smaller base tables cached in memory enables more index table data to be cached during querying, which improves performance.
Answer: The fastest type of query is one where there is only a single CONTAINS
clause, and no other conditions in the WHERE
clause.
Consider the following multiple CONTAINS
query:
SELECT title, isbn FROM booklist WHERE CONTAINS (title, 'horse') > 0 AND CONTAINS (abstract, 'racing') > 0
We can obtain the same result with section searching and the WITHIN
operator as follows:
SELECT title, isbn FROM booklist WHERE CONTAINS (alltext, 'horse WITHIN title AND racing WITHIN abstract')>0
This will be a much faster query. In order to use a query like this, we must copy all the data into a single text column for indexing, with section tags around each column's data. This can be done with PL/SQL procedures before indexing, or by making use of the USER_DATASTORE
datastore during indexing to synthesize structured columns with the text column into one document.
Answer: Each distinct word used in a query will require at least one row to be fetched from the index table. It is therefore best to keep the number of expansions down as much as possible.
You should not use expansions such as wild cards, thesaurus, stemming and fuzzy matching unless they are necessary to the task. In general, a few expansions (say up to 20) is OK, but you should try to avoid more than 100 or so expansions in a query. The query feedback mechanism can be used to determine the number of expansions for any particular query expression.
In addition for wildcard and stem queries, you can remove the cost of term expansion from query time to index time by creating prefix, substring or stem indexes. Query performance increases at the cost of longer indexing time and added disk space.
Prefix and substring indexes can improve wildcard performance. You enable prefix and substring indexing with the BASIC_WORDLIST
preference. The following example sets the wordlist preference for prefix and substring indexing. For prefix indexing, it specifies that Oracle Text create token prefixes between 3 and 4 characters long:
begin
ctx_ddl.create_preference('mywordlist', 'BASIC_WORDLIST'); ctx_ddl.set_attribute('mywordlist','PREFIX_INDEX','TRUE'); ctx_ddl.set_attribute('mywordlist','PREFIX_MIN_LENGTH', '3'); ctx_ddl.set_attribute('mywordlist','PREFIX_MAX_LENGTH', '4'); ctx_ddl.set_attribute('mywordlist','SUBSTRING_INDEX', 'YES');
end
You enable stem indexing with the BASIC_LEXER
preference:
begin
ctx_ddl.create_preference('mylex', 'BASIC_LEXER'); ctx_ddl.set_attribute ( 'mylex', 'index_stems', 'ENGLISH');
end;
Answer: You can create local partitioned CONTEXT
indexes on partitioned tables. This means that on a partitioned table, each partition has its own set of index tables. Effectively, there are multiple indexes, but the results from each are combined as necessary to produce the final result set.
The index is created using the LOCAL
keyword:
CREATE INDEX index_name ON table_name (column_name) INDEXTYPE IS ctxsys.context PARAMETERS ('...') LOCAL
With partitioned tables and local indexes, you can improve performance of the following types of CONTAINS
queries:
Range Search on Partition Key Column
This is a query that restricts the search to a particular range of values on a column that is also the partition key.
This is a query that requires only the first n hits and the ORDER BY
clause names the partition key
Answer: Depends. Even though parallel querying is the default behavior for indexes created in parallel, it usually results in degrading overall query throughput on heavily loaded systems.
In general, parallel queries are good for DSS or analytical systems with large data collections, multiple CPUs, and low number of concurrent users.
Answer: Indexing theme information with a CONTEXT
index takes longer and also increases the size of your index. However, theme indexes enable ABOUT
queries to be more precise by using the knowledge base, if available. If your application uses ABOUT
queries heavily, it might be worthwhile to create a theme component to the index, despite the extra indexing time and extra storage space required.
Answer: CTXCAT
indexes work best when text is in small chunks, maybe a few lines maximum, and searches need to restrict or sort the result set according to certain structured criteria, usually numbers or dates.
For example, consider an on-line auction site. Each item for sale has a short description, a current bid price, and dates for the start and end of the auction. A user might want to see all the records with antique cabinet in the description, with a current bid price less than $500. Since he's particularly interested in newly posted items, he wants the results sorted by auction start time.
Such a search is not always efficient with a CONTAINS
structured query on a CONTEXT
index, where the response time can vary significantly depending on the structured and CONTAINS
clauses. This is because the intersection of structured and CONTAINS
clauses or the ordering of text query is computed during query time.
By including structured information such as price and date within the CTXCAT
index, query response time is always in an optimal range regardless of search criteria. This is because the interaction between text and structured query is pre-computed during indexing. Consequently query response time is optimum.
Answer: There are differences in the time and space needed to create the index. CTXCAT
indexes take a bit longer to create and use considerably more disk space than CONTEXT
indexes. If you are tight on disk space, you should consider carefully whether CTXCAT
indexes are appropriate for you.
With respect to query operators, you can now use the richer CONTEXT
grammar in CATSEARCH
queries with query templates. The older restriction of a single CATSEARCH
query grammar no longer holds.
Answer: The optimizer hint INDEX(table column)
can be used in the usual way to drive the query with a text or b-tree index.
You can also use the NO_INDEX(table column)
hint to disable a specific index.
Additionally, the FIRST_ROWS(n)
hint has a special meaning for text queries and should be used when you need the first n hits to a query. Use of the FIRST_ROWS
hint in conjunction with ORDER BY SCORE(n) DESC
tells Oracle Text to accept a sorted set from the text index, and not to do a further sort.
This section answers some of the frequently asked questions about indexing performance.
Answer: Indexing text is a resource-intensive process. Obviously, the speed of indexing will depend on the power of the hardware involved.
As a benchmark, with an average document size of 5K, Oracle Text can index approximately 200 documents each second with the following hardware and parallel configuration:
4x400Mhz Sun Sparc CPUs
4 gig of RAM
EMC symmetrix (24 disks striped)
Parallel degree of 5 with 5 partitions
Index memory of 600MB for each index process
XML news documents that averaged 5K in size
USER_DATASTORE
Other factors such as your document format, location of your data, and the calls to user-defined datastores, filters, and lexers can have an impact on your indexing speed.
Answer: You can set your index memory with the system parameters DEFAULT_INDEX_MEMORY
and MAX_INDEX_MEMORY
. You can also set your index memory at run time with the CREATE INDEX
memory
parameter in the parameter string.
You should aim to set the DEFAULT_INDEX_MEMORY
value as high as possible, without causing paging.
You can also improve Indexing performance by increasing the SORT_AREA_SIZE
system parameter.
Experience has shown that using a large index memory setting, even into hundreds of megabytes, will improve the speed of indexing and reduce the fragmentation of the final indexes. However, if set too high, then the memory paging that occurs will cripple indexing speed.
With parallel indexing, each stream requires its own index memory. When dealing with very large tables, you can tune your database system global area (SGA) differently for indexing and retrieval. For querying, you are hoping to get as much information cached in the system global area's (SGA) block buffer cache as possible. So you should be allocating a large amount of memory to the block buffer cache. But this will not make any difference to indexing, so you would be better off reducing the size of the SGA to make more room for a large index memory settings during indexing.
You set the size of SGA in your Oracle Database initialization file.
See Also:
|
Answer: The overhead, the amount of space needed for the index tables, varies between about 50% of the original text volume and 200%. Generally, the larger the total amount of text, the smaller the overhead, but many small records will use more overhead than fewer large records. Also, clean data (such as published text) will require less overhead than dirty data such as emails or discussion notes, since the dirty data is likely to include many unique words from mis-spellings and abbreviations.
A text-only index is smaller than a combined text and theme index. A prefix and substring index makes the index significantly larger.
Answer: You can expect much lower storage overhead for formatted documents such as Microsoft Word files since such documents tend to be very large compared to the actual text held in them. So 1GB of Word documents might only require 50MB of index space, whereas 1GB of plain text might require 500MB, since there is ten times as much plain text in the latter set.
Indexing time is less clear-cut. Although the reduction in the amount of text to be indexed will have an obvious effect, you must balance this out against the cost of filtering the documents with the AUTO_FILTER
filter or other user-defined filters.
Answer: Parallel indexing can improve index performance when you have a large amount of data, and have multiple CPUs.
You use the PARALLEL
keyword when creating the index:
CREATE INDEX index_name ON table_name (column_name) INDEXTYPE IS ctxsys.context PARAMETERS ('...') PARALLEL 3;
This will create the index with up to three separate indexing processes depending on your resources.
Parallel indexing can also be used to create local partitioned indexes on partitioned tables. However, indexing performance only improves when you have multiple CPUs.
Note: UsingPARALLEL to create a local partitioned index enables parallel queries. (Creating a non-partitioned index in parallel does not turn on parallel query processing.)
Parallel querying degrades query throughput especially on heavily loaded systems. Because of this, Oracle recommends that you disable parallel querying after parallel indexing. To do so, use |
Answer: When you have multiple CPUs, you can improve indexing performance by creating a local index in parallel. There are two ways to index in parallel:
You can create a local partitioned index in parallel in two ways:
Use the PARALLEL
clause with the LOCAL
clause in CREATE INDEX.
In this case, the maximum parallel degree is limited to the number of partitions you have.
Create an unusable index first, then run the DBMS_PCLXUTIL.BUILD_PART_INDEX
utility. This method can result in a higher degree of parallelism, especially if you have more CPUs than partitions.
The following is an example for the second method. In this example, the base table has three partitions. We create a local partitioned unusable index first, the run the DBMS_PCLUTIL.BUILD_PART_INDEX
, which builds the 3 partitions in parallel (inter-partition parallelism). Also inside each partition, index creation is done in parallel (intra-partition parallelism) with a parallel degree of 2.
create index tdrbip02bx on tdrbip02b(text) indextype is ctxsys.context local (partition tdrbip02bx1, partition tdrbip02bx2, partition tdrbip02bx3) unusable; exec dbms_pclxutil.build_part_index(3,2,'TDRBIP02B','TDRBIP02BX',TRUE);
Answer: You can use the CTX_OUTPUT.START_LOG
procedure to log output from the indexing process. Filename will normally be written to $ORACLE_HOME/ctx/log
, but you can change the directory using the LOG_DIRECTORY
parameter in CTX_ADM.SET_PARAMETER
.
This section answers some of the frequently asked questions about updating your index and related performance issues.
Answer: The less often you run reindexing with CTX_DLL.SYNC_INDEX
, the less fragmented your indexes will be, and the less you will need to optimize them.
However, this means that your data will become progressively more out of date, which may be unacceptable for your users.
Many systems are OK with overnight indexing. This means data that is less than a day old is not searchable. Other systems use hourly, ten minute, or five minute updates.
See Also:
|
Answer: The best way is to time some queries, run index optimization, then time the same queries (restarting the database to clear the SGA each time, of course). If the queries speed up significantly, then optimization was worthwhile. If they don't, you can wait longer next time.
You can also use CTX_REPORT.INDEX_STATS
to analyze index fragmentation.
See Also:
|