Help with Oracle Text

Hello all,
Can someone point me in the right direction as to how to actually use this feature of Oracle? I've got a series of tables in my database that contain > 1 VARCHAR2 columns and one CLOB column. I need to be able to issue a query similar to this: select * FROM TABLE WHERE CONTAINS(*, 'Search Text') > 0. I want to be able to search all of the indexed columns in the table for the same text. If it finds the text in any of the columns, then return the row. I haven't yet been able to find any defacto document that shows me how to do this. It's been REALLY frustrating.
Thanks.

First of all, Text doesn't support a "contains(*,query)" syntax.
I don't know how familiar are you with the features so I'll recommend looking at the code samples:
http://otn.oracle.com/products/text/x/Samples/index.html
An then into the different datastore types to see which one will fit your requirements.

Similar Messages

  • Need help with Oracle Text

    Hello,
    I have the following table:
    create table table1(col1 clob)
    In columns COL1 I store some XML with the following structure:
    <ROW>
    <NAME>....</NAME>
    <COL1><VAL>...</VAL><VAL>....</VAL></COL1>
    <COL2>....</COL2>
    </ROW>
    So I compare two indexes:
    1. Simple index:
    create index myindex on table1(col1)
    indextype is ctxsys.context
    parameters ('datastore ctxsys.default_datastore
    filter ctxsys.null_filter
    section group ctxsys.auto_section_group')
    2. Another index with stop sections, I think it will allow to increase performance and decrease index's size as I will index only NAME tag.
    begin
         ctx_ddl.create_section_group('xmldatagroup', 'AUTO_SECTION_GROUP');
         ctx_ddl.add_stop_section('xmldatagroup', 'VAL');
         ctx_ddl.add_stop_section('xmldatagroup', 'COL1');
         ctx_ddl.add_stop_section('xmldatagroup', 'COL2');
    end;
    create index myindex on table1(col1)
    indextype is ctxsys.context
    parameters ('datastore ctxsys.default_datastore
    filter ctxsys.null_filter
    section group xmldatagroup')
    But when I compared these indexes I found that sizes are the same and the token's table DR$MYINDEX$I for the second index contains tokens from tags from stop sections however in documentation I see:
    Stop sections, empty tags, processing instructions, and comments are not indexed.
    Is anybody know what's wrong with my code or stop section is just logical declaration for using on the query's execution step?

    I'm not sure why your stop sections aren't working, but if you know the layout of the document I would recoomend using explcitly-defined field sections rather than auto_section_group.
    This will be a lot more efficient for querying.
    It will still index the data outside of the <NAME> section, though as part of the "default" section. If you don't want to index that, you could use a user_datastore to remove all the stuff apart from what you want to index.
    - Roger

  • Help with Oracle text using CTX_DOC.SNIPPET

    I used to find the code as follows:
         SELECT ROWIDS,ID,NGAYTAO,NGAYXUATBAN,CHUYENMUC,FULLPATH,NGONNGU,NOIDUNG,TIEUDE
                                       ,(SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_MOTA_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' ||
                                        (SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_NOIDUNG_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' ||
                                        (SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_TTHC1_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' ||
                                        (SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_TTHC2_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' ||
                                        (SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_TTHC3_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' ||
                                        (SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_TTHC4_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' MOTA
                                        FROM SEARCH_DNICT
                                        WHERE (CONTAINS(SEARCH_DNICT.TIEUDE,:tukhoa,1)>0
                                        OR CONTAINS(SEARCH_DNICT.MOTA,:tukhoa,2)>0
                                        OR CONTAINS(SEARCH_DNICT.NOIDUNG,:tukhoa,3)>0
                                        OR CONTAINS(SEARCH_DNICT.TTHC1,:tukhoa,4)>0
                                        OR CONTAINS(SEARCH_DNICT.TTHC2,:tukhoa,5)>0
                                        OR CONTAINS(SEARCH_DNICT.TTHC3,:tukhoa,6)>0
                                        OR CONTAINS(SEARCH_DNICT.TTHC4,:tukhoa,7)>0)- when I following query return 50 documents it takes 10.969 seconds load just for one use. Now my database is not only very little data
    - I find if such search is too slow, I have studied but have not found a way to accelerate your returns faster results like?
    - I want to improve performance query is how?
    - I hope people will help me solve
    Thanks every body!

    Hi,
    what is the plan for this query? I think it is maybe a full scan on the table and it uses not even the indexes. Is it possible to rewrite the query to use union?
    SELECT ROWIDS,ID,NGAYTAO,NGAYXUATBAN,CHUYENMUC,FULLPATH,NGONNGU,NOIDUNG,TIEUDE ,
    (SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_MOTA_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' ||
    (SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_NOIDUNG_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' ||
    (SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_TTHC1_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' ||
    (SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_TTHC2_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' ||
    (SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_TTHC3_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' ||
    (SELECT CTX_DOC.SNIPPET('SEARCH_DNICT_TTHC4_IDX',ROWIDS,:tukhoa) FROM DUAL) || '..' MOTA
    FROM
      SELECT ROWIDS,ID,NGAYTAO,NGAYXUATBAN,CHUYENMUC,FULLPATH,NGONNGU,NOIDUNG,TIEUDE
      FROM SEARCH_DNICT
      WHERE CONTAINS(SEARCH_DNICT.TIEUDE,:tukhoa,1)>0
      UNION
      SELECT ROWIDS,ID,NGAYTAO,NGAYXUATBAN,CHUYENMUC,FULLPATH,NGONNGU,NOIDUNG,TIEUDE
      FROM SEARCH_DNICT
      WHERE CONTAINS(SEARCH_DNICT.MOTA,:tukhoa,2)>0
      UNION
      SELECT ROWIDS,ID,NGAYTAO,NGAYXUATBAN,CHUYENMUC,FULLPATH,NGONNGU,NOIDUNG,TIEUDE
      FROM SEARCH_DNICT
      WHERE CONTAINS(SEARCH_DNICT.NOIDUNG,:tukhoa,3)>0
      UNION
      SELECT ROWIDS,ID,NGAYTAO,NGAYXUATBAN,CHUYENMUC,FULLPATH,NGONNGU,NOIDUNG,TIEUDE
      FROM SEARCH_DNICT
      WHERE CONTAINS(SEARCH_DNICT.TTHC1,:tukhoa,4)>0
      UNION
      SELECT ROWIDS,ID,NGAYTAO,NGAYXUATBAN,CHUYENMUC,FULLPATH,NGONNGU,NOIDUNG,TIEUDE
      FROM SEARCH_DNICT
      WHERE CONTAINS(SEARCH_DNICT.TTHC2,:tukhoa,5)>0
      UNION
      SELECT ROWIDS,ID,NGAYTAO,NGAYXUATBAN,CHUYENMUC,FULLPATH,NGONNGU,NOIDUNG,TIEUDE
      FROM SEARCH_DNICT
      WHERE CONTAINS(SEARCH_DNICT.TTHC3,:tukhoa,6)>0
      UNION
      SELECT ROWIDS,ID,NGAYTAO,NGAYXUATBAN,CHUYENMUC,FULLPATH,NGONNGU,NOIDUNG,TIEUDE
      FROM SEARCH_DNICT
      WHERE CONTAINS(SEARCH_DNICT.TTHC4,:tukhoa,7)>0
    ) If above doesn't help, then maybe a combined index on the fields will help. Examples are given in this forum if you search for multi colum index.
    Herald ten Dam
    http://htendam.wordpress.com

  • Problem with oracle text indexes during import

    We have a 9.2.0.6 database using oracle text features on a server with windows 2000 5.00.2195 SP4.
    We need to export its data ( user ARIANE only ) and then import the result into another 9.2.0.6 database.
    The import never comes to an end.
    The only way to make it work is to use the "indexes=n" clause.
    Then ( without the indexes ), we tried to create manually the oracle text indexes.
    We get this error :
    CREATE INDEX ARIANE.DOSTEXTE_DTTEXTE_CTXIDX ON ARIANE.DOSTEXTE (DTTEXTE)
    INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('lexer ariane_lexer stoplist ctxsys.default_stoplist storage ariane_storage');
    ORA-29855: erreur d'exécution de la routine ODCIINDEXCREATE
    ORA-20000: Erreur Oracle Text :
    DRG-10700: préférence inexistante : ariane_lexer
    ORA-06512: à "CTXSYS.DRUE", ligne 157
    ORA-06512: à "CTXSYS.TEXTINDEXMETHODS", ligne 219
    We then tried to uninstall Oracle text and install it ( My Oracle Support [ID 275689.1] ). The index creation above still fails.
    We also checked our Text installation and setup through My Oracle Support FAQ ( ID 153264.1 ) and everything seems ok.
    Do we have to create some ARIANE* lexer preferences through specific pl/sql ( ctx_report* ? ) before importing anything from the ARIANE user ?
    What do we need to do exactly when exporting data with oracle text features from one database to another given we used to restore the database through a copy of the entire windows files ?
    Is there a specific order to follow to succeed an import ?
    Thank you for your help.
    Jean-michel, Nemours, FRANCE

    Hi
    index preferences are not exported, ie ariane_lexer + ariane_storage, only the Text index metada, thus the DRG-10700 from index DDL on target/import DB.
    I recommend to use ctx_report.create_index_script on source/export DB, see Doc ID 189819.1 for details, export with indexes=N and then create text indexes manually after data import.
    -Edwin

  • Using psp with oracle text.

    we are design a simple document management application using psp with oracle text.
    we can query on index and finding the record and display the result on browser page.
    but we can't take document link on the same browser page. So we can't take document itself.
    We are using Oracle database release 1 text
    Thanks for your help.

    Sorry. The correct one is http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/text.920/a96517/acase.htm#620714

  • I need help with my text tone and I have ring tone. no text tone for the 4s.

    I need help with my text tone. I have ring tone no text tone. I have a 4s.

        Hi Sarar2333!  Let's get your text tones working again!
    Here's a link with instructions how to enable and change your alert sounds for your text/notification settings on your iPhone 4S: http://vz.to/1stiF8a.  You can ensure text tones are enabled by selecting a tone in the "Text Tone" setting.  Let me know how that works out for you.  Thanks!
    AnthonyTa_VZW
    Follow us on Twitter @VZWSupport

  • Help with oracle 11g pivot operator

    i need some help with oracle 11g pivot operator. is it possible to use multiple columns in the FOR clause and then compare it against multiple set of values.
    here is the sql to create some sample data
    create table pivot_data ( country_code number , dept number, job varchar2(20), sal number );
    insert into pivot_data values (1,30 , 'SALESMAN', 5000);
    insert into pivot_data values (1,301, 'SALESMAN', 5500);
    insert into pivot_data values (1,30 , 'MANAGER', 10000);     
    insert into pivot_data values (1,301, 'MANAGER', 10500);
    insert into pivot_data values (1,30 , 'CLERK', 4000);
    insert into pivot_data values (1,302, 'CLERK',4500);
    insert into pivot_data values (2,30 , 'SALESMAN', 6000);
    insert into pivot_data values (2,301, 'SALESMAN', 6500);
    insert into pivot_data values (2,30 , 'MANAGER', 11000);     
    insert into pivot_data values (2,301, 'MANAGER', 11500);
    insert into pivot_data values (2,30 , 'CLERK', 3000);
    insert into pivot_data values (2,302, 'CLERK',3500);
    using case when I can write something like this and get the output i want
    select country_code
    ,avg(case when (( dept = 30 and job = 'SALESMAN' ) or ( dept = 301 and job = 'SALESMAN' ) ) then sal end ) as d30_sls
    ,avg(case when (( dept = 30 and job = 'MANAGER' ) or ( dept = 301 and job = 'MANAGER' ) ) then sal end ) as d30_mgr
    ,avg(case when (( dept = 30 and job = 'CLERK' ) or ( dept = 302 and job = 'CLERK' ) ) then sal end ) as d30_clrk
    from pivot_data group by country_code;
    output
    country_code          D30_SLS               D30_MGR               D30_CLRK
    1      5250      10250      4250
    2      6250      11250      3250
    what I tried with pivot is like this I get what I want if I have only one ( dept,job) for one alias name. I want to call (30 , 'SALESMAN') or (301 , 'SALESMAN') AS d30_sls. any help how can I do this
    SELECT *
    FROM pivot_data
    PIVOT (SUM(sal) AS sum
    FOR (dept,job) IN ( (30 , 'SALESMAN') AS d30_sls,
              (30 , 'MANAGER') AS d30_mgr,               
    (30 , 'CLERK') AS d30_clk
    this is a simple example .... my real life scenario is compliated with more fields and more combinations .... So something like using substr(dept,1,2) won't work in my real case .
    any suggestions get the result similar to what i get in the case when example is really appreciated.

    Hi,
    Sorry, I don't think there's any way to get exactly what you requested. The values you give in the PIVOT ... IN clause are exact values, not alternatives.
    You could do something like this to map all alternatives to a common value:
    WITH     got_dept_grp     AS
         SELECT     country_code, job, sal
         ,     CASE
                  WHEN  job IN ('SALESMAN', 'MANAGER') AND dept = 301 THEN 30
                  WHEN  job IN ('CLERK')               AND dept = 302 THEN 30
                                                                     ELSE dept
              END     AS dept_grp
         FROM     pivot_data
    SELECT     *
    FROM     got_dept_grp
    PIVOT     (     AVG (sal)
         FOR     (job, dept_grp)
         IN     ( ('SALESMAN', 30)
              , ('MANAGER' , 30)
              , ('CLERK'   , 30)
    ;In your sample data (and perhaps in your real data), it's about as easy to explicitly define the pivoted groups individually, like this:
    WITH     got_pivot_key     AS
         SELECT     country_code, sal
         ,     CASE
                  WHEN  job = 'SALESMAN' AND dept IN (30, 301) THEN 'd30_sls'
                  WHEN  job = 'MANAGER'  AND dept IN (30, 301) THEN 'd30_mgr'
                  WHEN  job = 'CLERK'    AND dept IN (30, 302) THEN 'd30_clrk'
              END     AS pivot_key
         FROM    pivot_data
    SELECT     *
    FROM     got_pivot_key
    PIVOT     (     AVG (sal)
         FOR     pivot_key
         IN     ( 'd30_sls'
              , 'd30_mgr'
              , 'd30_clrk'
    ;Thanks for posting the CREATE TABLE and INSERT statements; that really helps!

  • I need help with oracle

    Hi,
    I need some help... if someone can help its great.
    I need to make a statement in Oracle SQL that read data from a file and insert in a Oracle Database ... if someone can show me the syntax of it i appreciate..
    Thanks

    Okay, I see you followed the advice in that other thread and started a new post for you question. Congratulations. Your next lesson in forum etiquette is to give your posts a more relevant subject. Pretty much everybody who posts here needs help with oracle; if they need help with cooking catfish they've come to the wrong place.
    It that other thread I suggested using SQL*Loader or External Tables might be a more suitable solution. Find out more.
    Cheers, APC

  • How to get exact match when working with Oracle Text?

    Hi,
    I'm running Oracle9i Database R2.
    I would like to know how do I get exact match when working with Oracle Text.
    DROP TABLE T_TEST_1;
    CREATE TABLE T_TEST_1 (text VARCHAR2(30));
    INSERT INTO T_TEST_1 VALUES('Management');
    INSERT INTO T_TEST_1 VALUES('Busines Management Practice');
    INSERT INTO T_TEST_1 VALUES('Human Resource Management');
    COMMIT;
    DROP INDEX T_TEST_1;
    CREATE INDEX T_TEST_1_IDX ON T_TEST_1(text) INDEXTYPE IS CTXSYS.CONTEXT;
    SELECT * FROM T_TEST_1 WHERE CONTAINS(text, 'Management')>0;
    The above query will return 3 rows. How do I make Oracle Text to return me only the first row - which is exact match because sometimes my users need to look for exact match term.
    Please advise.
    Regards,
    Jap.

    But I would like to utilize the Oracle Text index. Don't know your db version, but if you slightly redefine your index you can achieve this (at least on my 11g instance) :
    SQL> create table t_test_1 (text varchar2(30))
      2  /
    Table created.
    SQL> insert into t_test_1 values ('Management')
      2  /
    1 row created.
    SQL> insert into t_test_1 values ('Busines Management Practice')
      2  /
    1 row created.
    SQL> insert into t_test_1 values ('Human Resource Management')
      2  /
    1 row created.
    SQL>
    SQL> create index t_test_1_idx on t_test_1(text) indextype is ctxsys.context filter by text
      2  /
    Index created.
    SQL> set autotrace on explain
    SQL>
    SQL> select text, score (1)
      2    from t_test_1
      3   where contains (text, 'Management and sdata(text="Management")', 1) > 0
      4  /
    TEXT                             SCORE(1)
    Management                              3
    Execution Plan
    Plan hash value: 4163886076
    | Id  | Operation                   | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |              |     1 |    29 |     4   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| T_TEST_1     |     1 |    29 |     4   (0)| 00:00:01 |
    |*  2 |   DOMAIN INDEX              | T_TEST_1_IDX |       |       |     4   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("CTXSYS"."CONTAINS"("TEXT",'Management and
                  sdata(text="Management")',1)>0)
    Note
       - dynamic sampling used for this statementJust read that you indeed mentioned your db version in your first post.
    Not sure though if above method is already available in 9i ...
    Message was edited by:
    michaels

  • Huge Databases to be indexed with Oracle Text?

    Is there anybody with experience with Oracle Databases with several TB and an fulltext index with Oracle Text? Are there any success stories by oracle?

    Oracle Text, data load by partitation, async refresh index.
    Hi Gurus,
    Here I got a question,
    Serniro:
    A table with 2 partitions, text index created.
    When I load data into 1st partition, performance good.
    Sync partion text index, performance good.
    Then I load data into 2nd partition, it's so slow.
    My question is,
    How to disable/offline 2nd partition text index?
    Sync it after I loaded 2nd partition data.

  • Help needed with oracle text special character search

    Hi all
    Using oracle 11g sql developer 4.0
    I am facing this challenge where Oracle text when it comes to searching text that contains special character.
    This what I have done so far with help of http://www.orafaq.com/forum/t/162229/
      CREATE TABLE "SOS"."COMPANY"
       ( "COMPANY_ID" NUMBER(10,0) NOT NULL ENABLE,
      "COMPANY_NAME" VARCHAR2(50 BYTE),
      "ADDRESS1" VARCHAR2(50 BYTE),
      "ADDRESS2" VARCHAR2(10 BYTE),
      "CITY" VARCHAR2(40 BYTE),
      "STATE" VARCHAR2(20 BYTE),
      "ZIP" NUMBER(5,0)
       ) SEGMENT CREATION IMMEDIATE
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "USERS" ;
    Insert into COMPANY (COMPANY_ID,COMPANY_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP) values (1,'LSG SOLUTIONS LLC',null,null,null,null,null);
    Insert into COMPANY (COMPANY_ID,COMPANY_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP) values (2,'LOVE''S TRAVEL',null,null,null,null,null);
    Insert into COMPANY (COMPANY_ID,COMPANY_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP) values (3,'DEVON ENERGY',null,null,null,null,null);
    Insert into COMPANY (COMPANY_ID,COMPANY_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP) values (4,'SONIC INC',null,null,null,null,null);
    Insert into COMPANY (COMPANY_ID,COMPANY_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP) values (5,'MSCI',null,null,null,null,null);
    Insert into COMPANY (COMPANY_ID,COMPANY_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP) values (6,'ERNEST AND YOUNG',null,null,null,null,null);
    Insert into COMPANY (COMPANY_ID,COMPANY_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP) values (7,'JOHN DEER',null,null,null,null,null);
    Insert into COMPANY (COMPANY_ID,COMPANY_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP) values (8,'Properties@Oklahoma, LLC',null,null,null,null,null);
    Insert into COMPANY (COMPANY_ID,COMPANY_NAME,ADDRESS1,ADDRESS2,CITY,STATE,ZIP) values (9,'D.D.T  L.L.C.',null,null,null,null,null);
       BEGIN
    CTX_DDL.CREATE_PREFERENCE ('your_lexer', 'BASIC_LEXER');
         CTX_DDL.SET_ATTRIBUTE ('your_lexer', 'SKIPJOINS', '.,@-'''); -- to skip . , @ - ' symbols
        END;
      CREATE INDEX my_index2 ON COMPANY(COMPANY_NAME)
         INDEXTYPE IS CTXSYS.CONTEXT PARALLEL
       PARAMETERS ('LEXER your_lexer');   
    SELECT
    company_name
    FROM company
    WHERE CATSEARCH(company.COMPANY_NAME, 'LLC','') > 0
    ORDER BY company.COMPANY_ID;
    output
    company_name
    1 LSG SOLUTIONS LLC
    2 Properties@Oklahoma, LLC
    only return 2 row but should return 3

    I just noticed that I forgot to use an empty stoplist, so I have added that to the revised example below.  Otherwise, it uses a default stoplist that would not index common single-letter words like A and I.
    1. Whtat is Just search on single character 'L'? It give me error.
    Since it uses the NEAR operator, searching for just one letter causes incomplete syntax, asking it to search for L near a missing second value.  So, I have added additional code to allow for just one letter.
    2. How do I do auto refresh on this index on datastore?
    If I add "sync        (on commit)" it does not refresh the previously set token.
    Sync(on commit) does synchronize so that the data is immediately searchable.  You have to either optimize or rebuild or drop and recreate the index to condense the rows in the domain index table.
    3.lastly explanation of
    <seq>NEAR((' || letters_func (:search_string) || '),1,TRUE)</seq>
                      <seq>NEAR((' || letters_func (:search_string) || '),100,TRUE)</seq>
                    <seq>NEAR((' || letters_func (:search_string) || '),100,FALSE)</seq>
    why 100 true and 100 false
    100 is just a default value that I used for the second parameter of near, indicating how close the letters need to be to each other.  True and False are values for the third parameter of near, indicating whether or not the letters must be in the same order or not.  So, it returns the results in the order of first those that are very close to one another and in the same order, then those that may be further away but in the same order, then those that may be further away and in any order.
    SCOTT@orcl12c> CREATE TABLE company_near
      2    (company_id    NUMBER(10,0) NOT NULL ENABLE,
      3      company_name  VARCHAR2(50 BYTE))
      4  /
    Table created.
    SCOTT@orcl12c> SET DEFINE OFF
    SCOTT@orcl12c> BEGIN
      2  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (1,'LSG SOLUTIONS LLC');
      3  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (2,'LOVE''S TRAVEL');
      4  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (3,'DEVON ENERGY');
      5  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (4,'SONIC INC');
      6  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (5,'MSCI');
      7  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (6,'ERNEST AND YOUNG');
      8  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (7,'JOHN DEER');
      9  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (8,'Properties@Oklahoma, LLC');
    10  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (9,'D.D.T  L.L.C.');
    11  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (10,'LSG COMPANY, LLC');
    12  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (11,'LSG STAFFING, LLC');
    13  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (12,'L & S GROUP LLC');
    14  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (13,'L S & G, INC.');
    15  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (14,'L.S.G. PROPERTIES, L.L.C.');
    16  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (15,'LSGS PROPERTIES, LLC');
    17  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (16,'LSQ INVESTORS, L.L.C');
    18  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (17,'LHP SHERMAN/GRAYSON, LLC');
    19  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (18,'Walmart');
    20  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (19,'Wal mart');
    21  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (20,'LSG Property Investments, L.L.C.');
    22  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (21,'1224 S GALVESTON AVE, LLC');
    23  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (22,'1527 S GARY AVE, LLC');
    24  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (23,'FIFTEENTH STREET GRILL');
    25  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (24,'Massa Lobortis LLP');
    26  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (25,'Risus A Inc.');
    27  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (26,'Dollar $ store');
    28  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (27,'L.O.V.E., INC. ');
    29  Insert into COMPANY_NEAR (COMPANY_ID,COMPANY_NAME) values (28,'J-MART LLC ');
    30  END;
    31  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> CREATE OR REPLACE FUNCTION letters_func
      2    (p_string IN VARCHAR2)
      3    RETURN        VARCHAR2
      4  AS
      5    v_string     VARCHAR2(4000);
      6  BEGIN
      7    FOR i IN 1 .. LENGTH (p_string)
      8    LOOP
      9       IF REGEXP_LIKE (SUBSTR (p_string, i, 1), '[A-Z]', 'i')
    10       THEN
    11         v_string := v_string || SUBSTR (p_string, i, 1) || ',';
    12       END IF;
    13    END LOOP;
    14    v_string := RTRIM (v_string, ',');
    15    RETURN v_string;
    16  END letters_func;
    17  /
    Function created.
    SCOTT@orcl12c> BEGIN
      2    CTX_DDL.CREATE_PREFERENCE ('letters_datastore', 'MULTI_COLUMN_DATASTORE');
      3    CTX_DDL.SET_ATTRIBUTE
      4       ('letters_datastore',
      5        'COLUMNS',
      6        'letters_func (company_name) company_name');
      7    CTX_DDL.SET_ATTRIBUTE ('letters_datastore', 'DELIMITER', 'NEWLINE');
      8  END;
      9  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> CREATE INDEX letters_index ON company_near (company_name)
      2  INDEXTYPE IS CTXSYS.CONTEXT
      3  PARAMETERS
      4    ('DATASTORE  letters_datastore
      5       STOPLIST   CTXSYS.EMPTY_STOPLIST
      6       SYNC        (ON COMMIT)')
      7  /
    Index created.
    SCOTT@orcl12c> SELECT COUNT(*) FROM dr$letters_index$i
      2  /
      COUNT(*)
            24
    1 row selected.
    SCOTT@orcl12c> VARIABLE search_string VARCHAR2(100)
    SCOTT@orcl12c> EXEC :search_string := 'LSG'
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> SELECT SCORE(1), company_id, company_name
      2  FROM   company_near
      3  WHERE  CONTAINS
      4            (company_name,
      5             '<query>
      6            <textquery>
      7              <progression>
      8                <seq>'       || :search_string            || '</seq>
      9                <seq>NEAR((' || letters_func (:search_string) || '),1,TRUE)</seq>
    10                <seq>NEAR((' || letters_func (:search_string) || '),100,TRUE)</seq>
    11                <seq>NEAR((' || letters_func (:search_string) || '),100,FALSE)</seq>
    12              </progression>
    13            </textquery>
    14             </query>',
    15             1) > 0
    16  ORDER  BY SCORE(1) DESC
    17  /
      SCORE(1) COMPANY_ID COMPANY_NAME
            56          1 LSG SOLUTIONS LLC
            56         10 LSG COMPANY, LLC
            56         11 LSG STAFFING, LLC
            56         12 L & S GROUP LLC
            56         13 L S & G, INC.
            56         14 L.S.G. PROPERTIES, L.L.C.
            56         20 LSG Property Investments, L.L.C.
            56         15 LSGS PROPERTIES, LLC
            31         17 LHP SHERMAN/GRAYSON, LLC
             8         21 1224 S GALVESTON AVE, LLC
             4         22 1527 S GARY AVE, LLC
             4         23 FIFTEENTH STREET GRILL
    12 rows selected.
    SCOTT@orcl12c> EXEC :search_string := 'L'
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> /
      SCORE(1) COMPANY_ID COMPANY_NAME
            78          1 LSG SOLUTIONS LLC
            77          8 Properties@Oklahoma, LLC
            77          9 D.D.T  L.L.C.
            77         10 LSG COMPANY, LLC
            77         11 LSG STAFFING, LLC
            77         12 L & S GROUP LLC
            77         28 J-MART LLC
            77          2 LOVE'S TRAVEL
            77         26 Dollar $ store
            77         24 Massa Lobortis LLP
            77         23 FIFTEENTH STREET GRILL
            77         14 L.S.G. PROPERTIES, L.L.C.
            77         15 LSGS PROPERTIES, LLC
            77         16 LSQ INVESTORS, L.L.C
            77         17 LHP SHERMAN/GRAYSON, LLC
            77         20 LSG Property Investments, L.L.C.
            77         21 1224 S GALVESTON AVE, LLC
            77         22 1527 S GARY AVE, LLC
            76         19 Wal mart
            76         18 Walmart
            76         27 L.O.V.E., INC.
            76         13 L S & G, INC.
    22 rows selected.
    SCOTT@orcl12c> INSERT INTO company_near (company_id, company_name) VALUES (30, 'Laris Gordman llc.'  )
      2  /
    1 row created.
    SCOTT@orcl12c> COMMIT
      2  /
    Commit complete.
    SCOTT@orcl12c> SELECT COUNT(*) FROM dr$letters_index$i
      2  /
      COUNT(*)
            35
    1 row selected.
    SCOTT@orcl12c> EXEC :search_string := 'Laris Gordman llc.'
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> SELECT SCORE(1), company_id, company_name
      2  FROM   company_near
      3  WHERE  CONTAINS
      4            (company_name,
      5             '<query>
      6            <textquery>
      7              <progression>
      8                <seq>NEAR((' || letters_func (:search_string) || '),1,TRUE)</seq>
      9                <seq>NEAR((' || letters_func (:search_string) || '),100,TRUE)</seq>
    10                <seq>NEAR((' || letters_func (:search_string) || '),100,FALSE)</seq>
    11              </progression>
    12            </textquery>
    13             </query>',
    14             1) > 0
    15  ORDER  BY SCORE(1) DESC
    16  /
      SCORE(1) COMPANY_ID COMPANY_NAME
           100         30 Laris Gordman llc.
    1 row selected.
    SCOTT@orcl12c> EXEC CTX_DDL.OPTIMIZE_INDEX ('letters_index', 'FULL')
    PL/SQL procedure successfully completed.
    SCOTT@orcl12c> SELECT COUNT(*) FROM dr$letters_index$i
      2  /
      COUNT(*)
            24
    1 row selected.

  • Need Help on Oracle text

    Hi Masters,
    I am working on Oracle Text. I have executed the below step/commands. All are executed successfully. But I didn't seen any improvement in my task. But I have one doubt, will explain below.
    create table ent_dnt as select * from entitlement_dnt;
    BEGIN
        CTX_DDL.CREATE_PREFERENCE ('oracletext_datastore', 'MULTI_COLUMN_DATASTORE');
        CTX_DDL.SET_ATTRIBUTE
          ('oracletext_datastore', 'COLUMNS',
            'ORDER_NUMBER, GENERIC_PRODUCT_NAME_EXT, ENTITLEMENT_REF_ID, DEVICE_ASSET_ID, DEVICE_UNIQUE_ID, SWSERVICETAG, PRODUCT_DESC');
    END;
    CREATE INDEX idx_oracle_text
       ON Ent_dnt (search_cols)
        INDEXTYPE IS CTXSYS.CONTEXT
      PARAMETERS ('DATASTORE  oracletext_datastore');
    BEGIN
    DBMS_STATS.GATHER_TABLE_STATS('EE', 'ent_DNT', cascade=>TRUE);
    DBMS_STATS.GATHER_TABLE_STATS('EE', 'upd_DNT', cascade=>TRUE);
    dbms_stats.gather_index_stats('EE', 'idx_oracle_text1');
    dbms_stats.gather_index_stats('EE', 'idx_oracle_text');
    END;
    the above steps are created / executed successfully. But when execute my select query..I didn't seen anywhere oracle text index name in my explain plan.
    Plan
    SELECT STATEMENT  ALL_ROWSCost: 28,393  Bytes: 49,675  Cardinality: 5 
      3 SORT AGGREGATE  Bytes: 8  Cardinality: 1 
      2 TABLE ACCESS BY INDEX ROWID TABLE EE.EE_PROD_GRP_ENTITLEMENT Cost: 4  Bytes: 8  Cardinality: 1 
      1 INDEX RANGE SCAN INDEX EE.IDX_PGE_ENT_ID Cost: 3  Cardinality: 1 
      5 SORT AGGREGATE  Bytes: 8  Cardinality: 1 
      4 TABLE ACCESS FULL TABLE EE.ENT_DNT Cost: 26,781  Bytes: 8  Cardinality: 1 
      20 VIEW EE. Cost: 28,393  Bytes: 49,675  Cardinality: 5 
      19 COUNT STOPKEY 
      18 VIEW EE. Cost: 28,393  Bytes: 49,610  Cardinality: 5 
      17 SORT GROUP BY STOPKEY  Cost: 28,393  Bytes: 2,295  Cardinality: 5 
      16 HASH JOIN OUTER  Cost: 28,392  Bytes: 2,295  Cardinality: 5 
      14 NESTED LOOPS OUTER  Cost: 28,388  Bytes: 1,808  Cardinality: 4 
      11 NESTED LOOPS OUTER  Cost: 28,384  Bytes: 1,600  Cardinality: 4 
      8 HASH JOIN  Cost: 28,383  Bytes: 1,552  Cardinality: 4 
      6 TABLE ACCESS FULL TABLE EE.UPD_DNT Cost: 1,089  Bytes: 174  Cardinality: 6 
      7 TABLE ACCESS FULL TABLE EE.ENT_DNT Cost: 27,292  Bytes: 110,648,108  Cardinality: 308,212 
      10 TABLE ACCESS BY INDEX ROWID TABLE EE.PRODUCT_LICENSE_PART Cost: 1  Bytes: 12  Cardinality: 1 
      9 INDEX RANGE SCAN INDEX EE.IDX_PLP_PD_DATA_ID Cost: 0  Cardinality: 1 
      13 TABLE ACCESS BY INDEX ROWID TABLE EE.PD_KT_DETAILS Cost: 1  Bytes: 52  Cardinality: 1 
      12 INDEX RANGE SCAN INDEX EE.IDX_PKD_PART_NUM Cost: 0  Cardinality: 1 
      15 TABLE ACCESS FULL TABLE EE.LEGACY_CONFIG Cost: 3  Bytes: 35  Cardinality: 5 
    and cost is also so high. But when I ran the below query. I didn't see any $ tables.
    TEST@orcl_11gR2> SELECT object_name, object_type
      2  FROM   user_objects
      3  WHERE  object_name LIKE '%oracle%'
      4  /
    Usually DR$ $I, $K,$N,$R,$X tables are not creaed. where is the problem? please help me. I have to complete this task.
    Regards
    AR

    Hi Roger,
    Thanks alot for your reply. This is my query. Yes I didn't used contain clause in my query. But i don't know how to use.
    SELECT B.*,
           CASE WHEN ISBOUND = 'Y' AND ALLOWRESEND = 'Y' THEN 'Y' ELSE 'N' END
              AS Allowunbind,
           CASE
              WHEN ISBOUND = 'Y' AND IsThisAnUpgrade = 'N' AND Allowresend = 'N'
              THEN
                 'Y'
              ELSE
                 CASE
                    WHEN     ISBOUND = 'N'
                         AND BINDING_TYPE = INITCAP ('TRUSTED')
                         AND ALLOWRESEND = 'N'
                    THEN
                       'Y'
                    ELSE
                       'N'
                 END
           END
              AS AllowBind,
           FNC_GET_GROUPNAME_V3 (B.ENTITLEMENT_ID) GROUP_NAME,
           FNC_GET_USERGROUPNAME_V3 (B.ENTITLEMENT_ID, '[email protected]')
              USER_GROUP_NAME,
           FNC_GET_ROLE_V3 (B.ENTITLEMENT_ID, '[email protected]') ROLE_NAME,
           (SELECT MAX (PGE_IS_ASSIGNED)
              FROM ENT_DNT
             WHERE ENTITLEMENT_ID = B.ENTITLEMENT_ID)
              AS IS_ASSIGNED
      FROM (SELECT *
              FROM (SELECT A.*, ROWNUM RNUM
                      FROM (SELECT *
                              FROM (SELECT *
                                      FROM (SELECT DISTINCT
                                                   ENTDNT.ORDER_DATE,
                                                   ENTDNT.ORDER_NUMBER,
                                                   ENTDNT.ENTITLEMENT_ID,
                                                   ENTDNT.ENTITLEMENT_REF_ID,
                                                   ENTDNT.CUSTOMER_NUM,
                                                   ENTDNT.ENTITLEMENT_STATUS_ID,
                                                   ENTDNT.ENT_QTY,
                                                   ENTDNT.ENTITLEMENTNAME,
                                                   ENTDNT.ACT_KEY_LOB_ID,
                                                   ENTDNT.LIC_KEY_LOB_ID,
                                                   ENTDNT.LICENSE_KEY,
                                                   ENTDNT.ENT_TYPE_ID,
                                                   ENTDNT.PRODUCT_DATA_ID,
                                                   ENTDNT.PRODUCT_NAME,
                                                   ENTDNT.TYPE_DIMENSION_EXT,
                                                   ENTDNT.BINDING_TYPE,
                                                   DECODE (
                                                      ENTDNT.ENT_TYPE_ID,
                                                      1, ENTDNT.PRODUCT_DESC,
                                                      3, ENTDNT.GENERIC_PRODUCT_NAME_EXT)
                                                      AS PRODUCT_DESC,
                                                   DECODE (
                                                      ENTDNT.ENT_TYPE_ID,
                                                      3, PKD.PRIMARY_LICENSE_IDENTIFIER,
                                                      2, 'SOFTWARE_SERVICETAG',
                                                      1, 'ENTITLEMENTID',
                                                      NULL)
                                                      AS PRIMARYLICENSEIDENTIFIER,
                                                   CASE
                                                      WHEN     DECODE (
                                                                 ENTDNT.ENT_TYPE_ID,
                                                                  3, DECODE (
                                                                        PKD.KEY_SOURCE_TYPE,
                                                                        'SOURCE_NO_KEY', 'N',
                                                                        'Y'),
                                                                  1, 'Y',
                                                                  LC.IS_KEY_REQUIRED) =
                                                                  'Y'
                                                           AND ENTDNT.ENTITLEMENT_STATUS_ID =
                                                                  '0'
                                                           AND (   ENTDNT.LIC_KEY_LOB_ID
                                                                      IS NOT NULL
                                                                OR ENTDNT.LICENSE_KEY
                                                                      IS NOT NULL
                                                                OR ENTDNT.ACT_KEY_LOB_ID
                                                                      IS NOT NULL)
                                                      THEN
                                                         'Y'
                                                      WHEN     ENTDNT.ENTITLEMENT_STATUS_ID =
                                                                  '0'
                                                           AND (   ENTDNT.LIC_KEY_LOB_ID
                                                                      IS NOT NULL
                                                                OR ENTDNT.LICENSE_KEY
                                                                      IS NOT NULL)
                                                      THEN
                                                         'Y'
                                                      ELSE
                                                         'N'
                                                   END
                                                      AS KEYREQUIRED,
                                                   ENTDNT.ISTHISANUPGRADE,
                                                   ENTDNT.DEVICE_ASSET_ID,
                                                   ENTDNT.SWSERVICETAG,
                                                   PKD.PHVALUE,
                                                   CASE
                                                      WHEN -- ENTDNT.BINDING_TYPE = 'Trusted'
                                                          ENTDNT.BINDING_TYPE =
                                                              INITCAP ('TRUSTED')
                                                      THEN
                                                         'N'
                                                      WHEN    ENTDNT.BINDING_TYPE =
                                                                 INITCAP (
                                                                    'COMPONENT')
                                                           -- OR ENTDNT.BINDING_TYPE = 'DeviceID'
                                                           OR ENTDNT.BINDING_TYPE =
                                                                 INITCAP (
                                                                    'DEVICEID')
                                                           --OR ENTDNT.BINDING_TYPE = 'ServiceTag'
                                                           OR ENTDNT.BINDING_TYPE =
                                                                 INITCAP (
                                                                    'SERVICETAG')
                                                      THEN
                                                         'Y'
                                                      ELSE
                                                         'N'
                                                   END
                                                      AS ISBOUND,
                                                   CASE
                                                      WHEN     ENTDNT.ENT_TYPE_ID =
                                                                  3
                                                           AND PKD.ALLOW_RESEND =
                                                                  'Y'
                                                           AND ENTDNT.ENTITLEMENT_STATUS_ID =
                                                                  '0'
                                                           AND (   ENTDNT.LIC_KEY_LOB_ID
                                                                      IS NOT NULL
                                                                OR ENTDNT.LICENSE_KEY
                                                                      IS NOT NULL
                                                                OR ENTDNT.ACT_KEY_LOB_ID
                                                                      IS NOT NULL)
                                                      THEN
                                                         'Y'
                                                      WHEN     ENTDNT.ENTITLEMENT_STATUS_ID =
                                                                  '0'
                                                           AND (   ENTDNT.LIC_KEY_LOB_ID
                                                                      IS NOT NULL
                                                                OR ENTDNT.LICENSE_KEY
                                                                      IS NOT NULL)
                                                      THEN
                                                         'Y'
                                                      ELSE
                                                         'N'
                                                   END
                                                      AS ALLOWRESEND,
                                                   ENTDNT.GENERIC_PRODUCT_NAME_EXT,
                                                   PLP.LICENSE_PART_NUMBER
                                                      AS SRVPARTNUMBER,
                                                   ENTDNT.DEVICE_UNIQUE_ID,
                                                   (SELECT MAX (IS_ASSIGNED)
                                                      FROM EE_PROD_GRP_ENTITLEMENT PGE
                                                     WHERE ENTITLEMENT_ID =
                                                              ENTDNT.ENTITLEMENT_ID)
                                                      AS IS_ASSIGNED,
                                                   ENTDNT.SINGLEFILEPERID
                                              FROM ent_dnt ENTDNT,
                                                   PD_KT_DETAILS PKD,
                                                   PRODUCT_LICENSE_PART PLP,
                                                   Legacy_Config LC,
                                                   upd_dnt UPDNT
                                             WHERE     ENTDNT.PRODUCT_GROUP_ID =
                                                          UPDNT.PRODUCT_GROUP_ID
                                                   AND UPDNT.EMAIL_ADDRESS =
                                                          '[email protected]'
                                                   AND ENTDNT.ENT_TYPE_ID =
                                                          LC.ENTITLEMENT_TYPE_ID(+)
                                                   AND PLP.PRODUCT_DATA_ID(+) =
                                                          ENTDNT.PRODUCT_DATA_ID
                                                   AND PKD.PART_NUMBER(+) =
                                                          ENTDNT.LIC_PART_NUM
                                                   AND UPDNT.IS_DELETED = 'N'
                                                   AND ENTDNT.ENTITLEMENT_STATUS_ID IN
                                                          (0, 4)
                                                   AND ENTDNT.IS_DELETED = 'N')
                                     WHERE    (UPPER (GENERIC_PRODUCT_NAME_EXT) LIKE
                                                  '%IDRAC%')
                                           OR (ORDER_NUMBER LIKE '%251608469%')
                                           OR (ENTITLEMENT_REF_ID LIKE '%162523200%')
                                           OR (DEVICE_ASSET_ID LIKE '%162523200%')
                                           OR (DEVICE_UNIQUE_ID LIKE '%162523200%')
                                           OR (SWSERVICETAG LIKE '%162523200%')
                                           OR (UPPER (PRODUCT_DESC) LIKE
                                                  '%162523200%'))
                             WHERE    (UPPER (GENERIC_PRODUCT_NAME_EXT) LIKE
                                          '%575757%')
                                   OR (ORDER_NUMBER LIKE '%251608469%')
                                   OR (ENTITLEMENT_REF_ID LIKE '%162523200%')
                                   OR (DEVICE_ASSET_ID LIKE '%162523200%')
                                   OR (DEVICE_UNIQUE_ID LIKE '%162523200%')
                                   OR (SWSERVICETAG LIKE '%162523200%')
                                   OR (UPPER (PRODUCT_DESC) LIKE '%162523200%')) A
                     WHERE ROWNUM <= 100)
             WHERE RNUM >= 1) B;
    yes..you are 100% correct. I did mistake with like operator. now I executed the below query. displaying all oracle related tables and indexes. Thank you.
    SELECT object_name, object_type
    FROM   user_objects
    WHERE  object_name LIKE '%ORACLE%'
    but here I have a problem. how can i run the below select for my above query?
    SELECT *
      2  FROM  Entitlement_dnt
      3  WHERE  CONTAINS (search_cols, REPLACE (:i_OpenSearchText, ',', ' AND ')) > 0
    here what can I do the value for :I_opensearchText ? confused.
    please help me..!!
    Regards
    AR

  • Performance issue with Oracle Text index

    Hi Experts,
    We are on Oracle 11.2..0.3 on Solaris 10. I have implemented Oracle Text in our environment and I am facing a strange performance issue that is happening in our environment.
    One sql having CONTAINS clause is taking forever - more than 20 minutes and still does not complete. This sql has a contains clause and an exists clause and a not exists clause.
    Now if I remove the exists clause and a not exists clause , it completes fast. but with those two clauses it is just taking forever. It is late night so i am not able to post the table and sql query details and will do so tomorrow but based on this general description, are there any pointers for me to review?
    sql query doing fine:
    SELECT
        U.CLNT_OID, U.USR_OID, S.MAILADDR
    FROM
        access_usr U
        INNER JOIN access_sia S
            ON S.USR_OID = U.USR_OID AND S.CLNT_OID = U.CLNT_OID
        WHERE U.CLNT_OID = 'ABCX32S'
        AND CONTAINS(LAST_NAME , 'TO%' ) >0
    --sql query that hangs forever:
    SELECT
        U.CLNT_OID, U.USR_OID, S.MAILADDR
    FROM
        access_usr U
        INNER JOIN access_sia S
            ON S.USR_OID = U.USR_OID AND S.CLNT_OID = U.CLNT_OID
        WHERE U.CLNT_OID = 'ABCX32S'
        AND CONTAINS(LAST_NAME , 'TO%' ) >0
    and exists (--one clause here wiht a few table joins)
    and not exists (--one clause here wiht a few table joins);
    --Now another strange thing I found is if instead of 'TO%' in this sql, if I were to use 'ZZ%' or 'L1%' it works fast but for 'TO%' it goes slow with those two exists not exists clauses!
    I will be most thankful for the inputs.
    OrauserN

    Hi Barbara,
    First of all, thanks a lot for reviewing the issue.
    Unluckily making the change to empty_stoplist did not work out. I am today copying the entire sql here that has this issue and will be most thankful for more insights/pointers on what can be done.
    Here is the entire sql:
    SELECT U.CLNT_OID,
           U.USR_OID,
           S.EMAILADDRESS,
           U.FIRST_NAME,
           U.LAST_NAME,
           S.JOBCODE,
           S.LOCATION,
           S.DEPARTMENT,
           S.ASSOCIATEID,
           S.ENTERPRISECOMPANYCODE,
           S.EMPLOYEEID,
           S.PAYGROUP,
           S.PRODUCTLOCALE
      FROM    ACCESS_USR U
           INNER JOIN
              ACCESS_SIA S
           ON S.USR_OID = U.USR_OID AND S.CLNT_OID = U.CLNT_OID
    WHERE     U.CLNT_OID = 'G39NY3D25942TXDA'
           AND EXISTS
                  (SELECT 1
                     FROM ACCESS_USR_GROUP_XREF UGX
                          INNER JOIN ACCESS_GROUP RELG
                             ON     RELG.CLNT_OID = UGX.CLNT_OID
                                AND RELG.GROUP_OID = UGX.GROUP_OID
                          INNER JOIN ACCESS_GROUP G
                             ON     G.CLNT_OID = RELG.CLNT_OID
                                AND G.GROUP_TYPE_OID = RELG.GROUP_TYPE_OID
                    WHERE     UGX.CLNT_OID = U.CLNT_OID
                          AND UGX.USR_OID = U.USR_OID
                          AND G.GROUP_OID = 920512943
                          AND UGX.INCLUDED = 1)
           AND NOT EXISTS
                      (SELECT 1
                         FROM    ACCESS_USR_GROUP_XREF UGX
                              INNER JOIN
                                 ACCESS_GROUP G
                              ON     G.CLNT_OID = UGX.CLNT_OID
                                 AND G.GROUP_OID = UGX.GROUP_OID
                        WHERE     UGX.CLNT_OID = U.CLNT_OID
                              AND UGX.USR_OID = U.USR_OID
                              AND G.GROUP_OID = 920512943
                              AND UGX.INCLUDED = 1)
           AND CONTAINS (U.LAST_NAME, 'Bon%') > 0;
    Like I said before if the EXISTS and NOT EXISTS clause are removed it works in sub-second. But with those EXISTS and NOT EXISTS CLAUSE IT TAKES ANY WHERE FROM 25 minutes to more than one hour.
    NOte also that it was not TO% but Bon% in the CONTAINS clause that is giving the issue - sorry that was wrong on my part.
    Also please see below the ORACLE TEXT index defined on the table ACCESS_USER:
    --definition of preferences used in the index:
    SET SERVEROUTPUT ON size unlimited
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    DECLARE
       v_err       VARCHAR2 (1000);
       v_sqlcode   NUMBER;
       v_count     NUMBER;
    BEGIN
       ctxsys.ctx_ddl.create_preference ('cust_lexer', 'BASIC_LEXER');
       ctxsys.ctx_ddl.set_attribute ('cust_lexer', 'base_letter', 'YES'); -- removes diacritics
    EXCEPTION
       WHEN OTHERS
       THEN
          v_err := SQLERRM;
          v_sqlcode := SQLCODE;
          v_count := INSTR (v_err, 'DRG-10701');
          IF v_count > 0
          THEN
             DBMS_OUTPUT.put_line (
                'The required preference named CUST_LEXER with BASIC LEXER is already set up');
          ELSE
             RAISE;
          END IF;
    END;
    DECLARE
       v_err       VARCHAR2 (1000);
       v_sqlcode   NUMBER;
       v_count     NUMBER;
    BEGIN
       ctxsys.ctx_ddl.create_preference ('cust_wl', 'BASIC_WORDLIST');
       ctxsys.ctx_ddl.set_attribute ('cust_wl', 'SUBSTRING_INDEX', 'true'); -- to improve performance
    EXCEPTION
       WHEN OTHERS
       THEN
          v_err := SQLERRM;
          v_sqlcode := SQLCODE;
          v_count := INSTR (v_err, 'DRG-10701');
          IF v_count > 0
          THEN
             DBMS_OUTPUT.put_line (
                'The required preference named CUST_WL with BASIC WORDLIST is already set up');
          ELSE
             RAISE;
          END IF;
    END;
    --now below is the code of the index:
    CREATE INDEX ACCESS_USR_IDX3 ON ACCESS_USR
    (FIRST_NAME)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS('LEXER cust_lexer WORDLIST cust_wl SYNC (ON COMMIT)');
    CREATE INDEX ACCESS_USR_IDX4 ON ACCESS_USR
    (LAST_NAME)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS('LEXER cust_lexer WORDLIST cust_wl SYNC (ON COMMIT)');
    The strange thing is that, like I said, If I remove the exists clause the query returns very fast. Also if I modify the query to use only one NOT EXISTS clause and remove the other EXISTS clause it returns in less than one second.  Also if I remove the EXISTS clause and use only the NOT EXISTS  clause it returns in less than 4 seconds. But with both clauses it runs forever!
    When I tried to get dbms_xplan.display_cursor to get the query plan (for the case of both exists and not exists clause in the query), it said that previous statement's sql id was 0 or something like that so that I was not able to see the query plan. I will keep trying to get this plan (it takes 25 minutes to one hour each time but will get this info soon). Again any pointers are most helpful.
    Regards
    OrauserN

  • Searching from beginning of a line/string with Oracle Text ...

    Oracle Database 10.2.0.3, Solaris
    Hi,
    what sounds very easy with the LIKE operator seems to be impossible with the Oracle Text Operator Contains ;
    Searching for 'Deutsche%' results with LIKE ->
    'Deutsche Bank'
    'Deutsche Post'
    'Deutsche Oracle Community'
    But with Contains-Operator which is token based the result is following ('$Deutsche%')
    'Deutsche Bank'
    'Armin Deutscher'
    We want to get results starting with 'Deutscher...' But with Contains and some configuration i did not find a way. Combining LIKE with Contains did not help too because Contains expands the word in more instances then LIKE.
    Indexed Columns are varchar2 typed
    any idea?
    kind regards
    Karl
    Message was edited by:
    kreitsch

    Have you evaluated the query rewrite template with CONTAINS?
    http://download.oracle.com/docs/cd/B19306_01/text.102/b14218/csql.htm#sthref122

  • Help with Oracle Report Builder and SQL Server2000

    Hey guys,
    I just installed it Oracle Developer Suite10g with Report Builder and I am trying to use Report builder and wants to connect with SQL Server 2000. The problem that I am running in to is SQL Server 2000 i have is Window Authentication so Does not required to enter user name and password. So how can i connect my report builder to SQL server or is it possible to connect Report builder to SQL server?
    Also, I want to create small practice version of database in Oracle how do i do it? what i mean by that is I installed trial version or Oracle developer 10g from www.oracle.com and now trying to get some knowledge with oracle. Could any one can give me some direction in this matter please.
    Thank You
    Key

    Have a look at the reports help for the purpose header and trailer sections. Here is an exert:
    "Report sectioning enables you to define multiple layouts in the same report, each with a different target audience, output format, page layout, page size, or orientation. You can define up to three report sections, each with a body area and a margin area: the names of the sections are Header, Main, and Trailer. By default, a report is defined in the Main section. In the other sections, you can define different layouts, rather than creating multiple separate reports. If you wish, you can use the margin and body of the Header and Trailer sections to create a Header and Trailer page for your reports."

Maybe you are looking for