Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, idou.

Asked: May 24, 2018 - 1:43 pm UTC

Last updated: May 28, 2018 - 4:13 am UTC

Version: oracle experss

Viewed 1000+ times

You Asked

hello
Is it possible to combine b-tree indices with Full-Text indices in oracle 11(express)?

Merci

and Connor said...

I'm checking with the optimizer Product Manager, but I think the b-tree-to-bitmap conversion might not be possible in XE, and hence combining indexes (where one is a text index) might be difficult.

Enterprise edition output (only the last execution plan really of relevance here)
==========================
SQL> create table t ( x int, y int, z varchar2(500));

Table created.

SQL>
SQL> insert into t
  2  with txt as (
  3    select 'the quick brown fox jumps over the lazy dog' tx from dual union all
  4    select 'now is the time for all good men to come to the aid of the party' from dual union all
  5    select 'twinkle twinkle little star how i wonder what you are' from dual )
  6  select
  7    rownum,
  8    mod(rownum,100),
  9    tx
10  from txt
11  connect by level <= 12;

797160 rows created.

SQL>
SQL> create index ix1 on t ( y ) ;

Index created.

SQL> create index ix2 on t ( z)
  2    indextype is ctxsys.context;

Index created.

SQL>
SQL> exec dbms_stats.gather_table_stats('','T');

PL/SQL procedure successfully completed.

SQL>
SQL> set autotrace traceonly explain
SQL> select * from t
  2  where contains(z,'star') > 0 ;

Execution Plan
----------------------------------------------------------
Plan hash value: 656667679

------------------------------------------------------------------------------------
| Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |      |   249K|    14M| 46425   (1)| 00:00:02 |
|   1 |  TABLE ACCESS BY INDEX ROWID| T    |   249K|    14M| 46425   (1)| 00:00:02 |
|*  2 |   DOMAIN INDEX              | IX2  |       |       | 41629   (0)| 00:00:02 |
------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("CTXSYS"."CONTAINS"("Z",'star')>0)

SQL>
SQL> select *
  2  from t
  3  where y = 75;

Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |  7972 |   482K|  2058   (1)| 00:00:01 |
|*  1 |  TABLE ACCESS FULL| T    |  7972 |   482K|  2058   (1)| 00:00:01 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("Y"=75)

SQL>
SQL> select /*+ index_combine(t ix1 ix2) */ *
  2  from t
  3  where contains(z,'star') > 0
  4  and y = 75;

Execution Plan
----------------------------------------------------------
Plan hash value: 1493823157

--------------------------------------------------------------------------------------------
| Id  | Operation                           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                    |      |  2496 |   151K| 42106   (1)| 00:00:02 |
|   1 |  TABLE ACCESS BY INDEX ROWID BATCHED| T    |  2496 |   151K| 42106   (1)| 00:00:02 |
|   2 |   BITMAP CONVERSION TO ROWIDS       |      |       |       |            |          |
|   3 |    BITMAP AND                       |      |       |       |            |          |
|   4 |     BITMAP CONVERSION FROM ROWIDS   |      |       |       |            |          |
|*  5 |      INDEX RANGE SCAN               | IX1  |       |       |    18   (0)| 00:00:01 |
|   6 |     BITMAP CONVERSION FROM ROWIDS   |      |       |       |            |          |
|   7 |      SORT ORDER BY                  |      |       |       |            |          |
|*  8 |       DOMAIN INDEX                  | IX2  |       |       | 41629   (0)| 00:00:02 |
--------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   5 - access("Y"=75)
   8 - access("CTXSYS"."CONTAINS"("Z",'star')>0)


Express Edition output
=======================

SQL> create table t ( x int, y int, z varchar2(500));

Table created.

SQL>
SQL> insert into t
  2  with txt as (
  3    select 'the quick brown fox jumps over the lazy dog' tx from dual union all
  4    select 'now is the time for all good men to come to the aid of the party' from dual union all
  5    select 'twinkle twinkle little star how i wonder what you are' from dual )
  6  select
  7    rownum,
  8    mod(rownum,100),
  9    tx
10  from txt
11  connect by level <= 12;

797160 rows created.

SQL>
SQL> create index ix1 on t ( y ) ;

Index created.

SQL> create index ix2 on t ( z)
  2    indextype is ctxsys.context;

Index created.

SQL>
SQL> exec dbms_stats.gather_table_stats('','T');

PL/SQL procedure successfully completed.

SQL>
SQL> set autotrace traceonly explain
SQL> select * from t
  2  where contains(z,'star') > 0 ;

Execution Plan
----------------------------------------------------------
Plan hash value: 656667679

------------------------------------------------------------------------------------
| Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |      |   249K|    14M| 46425   (1)| 00:00:02 |
|   1 |  TABLE ACCESS BY INDEX ROWID| T    |   249K|    14M| 46425   (1)| 00:00:02 |
|*  2 |   DOMAIN INDEX              | IX2  |       |       | 41629   (0)| 00:00:02 |
------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("CTXSYS"."CONTAINS"("Z",'star')>0)

SQL>
SQL> select *
  2  from t
  3  where y = 75;

Execution Plan
----------------------------------------------------------
Plan hash value: 1601196873

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |  7972 |   482K|  2058   (1)| 00:00:01 |
|*  1 |  TABLE ACCESS FULL| T    |  7972 |   482K|  2058   (1)| 00:00:01 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("Y"=75)

SQL>
SQL> select /*+ index_combine(t ix1 ix2) */ *
  2  from t
  3  where contains(z,'star') > 0
  4  and y = 75;

Execution Plan
----------------------------------------------------------
Plan hash value: 656667679

------------------------------------------------------------------------------------
| Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |      |  2496 |   151K| 46425   (1)| 00:00:02 |
|*  1 |  TABLE ACCESS BY INDEX ROWID| T    |  2496 |   151K| 46425   (1)| 00:00:02 |
|*  2 |   DOMAIN INDEX              | IX2  |       |       | 41629   (0)| 00:00:02 |
------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter("Y"=75)
   2 - access("CTXSYS"."CONTAINS"("Z",'star')>0)


Is this answer out of date? If it is, please let us know via a Comment

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database