oracle text 12c new features
TRANSCRIPT
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Oracle Text 12c New Features
Ulrike Schwinn
Business Unit DatabaseOracle Deutschland B.V. & Co KG
Deutschsprachiger Oracle Text Blog (@cczarski und @uschwinn) http://oracle-text-de.blogspot.de/
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
New Features im Überblick• Performance– Erhöhung von MAX_INDEX_MEMORY– Near Real Time Index– BIG_IO– Separate Offsets–Query Result Cache– Pattern Stopclass
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
New Features im Überblick• Document Service– Forward und Save Copy Index– Snippets für Result Set Interface
• Abfragen– Neue und erweiterte Operatoren– SDATA Erweiterungen– Änderungen an Datastore Trigger
• Internationalisierung– Document Lexer
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
MAX_INDEX_MEMORY• Performance beim Anlegen, Verändern und Optimierung des Index–Memory Verwendung so hoch wie möglich setzen
• Erhöhung von MAX_INDEX_MEMORY in 12c auf 256 GB (statt 2GB vorher)• Möglich mit CTX_ADM oder CREATE/ALTER INDEX Kommando
• Sample Code: http://oracle-text-de.blogspot.de/2009/04/index-optimierung-einige-grundlagen.html
execute ctx_adm.set_parameter('MAX_INDEX_MEMORY', '256G')
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Near Real Time Index• Anforderung: Index möglich aktuell halten - sogar bei hoher Änderungsrate
– Problem: Häufiges Synchronisieren führt zu Fragmentierung
• Neu: Near real-time Index oder two level Index– Kleiner Stage Index im Memory und danach Merge in den Hauptindex
• Nutze neue Option “STAGE_ITAB” für Storage Preference– Neue Tabelle $G und Index $H
• Sample Code: stage_itab.sql, auto_opt.sqlhttp://oracle-text-de.blogspot.de/2013/10/oracle-text-in-oracle-12c-automatic.html
Aktualität Fragmentierung
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Near Real Time Index - Beispiel• Preference anlegen
• Optional: Cachen im KEEP Pool
• Index anlegen
exec ctx_ddl.create_preference('my_storage', 'BASIC_STORAGE') exec ctx_ddl.set_attribute('my_storage', 'STAGE_ITAB', 'true')
exec ctx_ddl.set_attribute('my_storage','G_TABLE_CLAUSE', 'storage (buffer_pool keep)') exec ctx_ddl.set_attribute('my_storage','G_INDEX_CLAUSE', 'storage (buffer_pool keep)')
create index my_index on my_table(text) indextype is ctxsys.contextparameters('storage my_storage sync (on commit)')
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Near Real Time Index - Beispiel insert into my_table values( 1, 'hello world' );insert into my_table values( 2, 'goodbye world' );commit;
SQL> select token_text from dr$my_index$g;TOKEN_TEXT----------------------------------------------------------------GOODBYEHELLOWORLD
SQL> select token_text from dr$my_index$i;
no rows selected
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Near Real Time Index - Merge• Manuell
• Automatisch über Scheduler Job
execute ctx_ddl.optimize_index(idx_name=>'MY_INDEX', optlevel=>'MERGE')
exec ctx_ddl.add_auto_optimize( 'my_index' )
select job_name, program_name, last_start_date from dba_scheduler_jobs where owner='CTXSYS‘;JOB_NAME PROGRAM_NAME-------------------- --------------------LAST_START_DATE----------------------------------------------------------------------DR$BGOPTJOB DR$BGOPTPRG01-JUN-15 09.32.48.660822 AM EUROPE/VIENNA
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Optimierung von TOKEN_INFO mit “BIG_IO”• In 11g: $I Tabelle mit TOKEN_INFO ist optimiert für BLOB mit 4000 Byte
Chunks (Inline Storage)• In 12c: Nutzung von Securefiles mit großen Chunks => Reduzierung von
Random I/O bei großen Indexeinträgen
Name Null? Type ----------------- -------- ------------ TOKEN_TEXT NOT NULL VARCHAR2(64) TOKEN_TYPE NOT NULL NUMBER(3) TOKEN_FIRST NOT NULL NUMBER(10) TOKEN_LAST NOT NULL NUMBER(10) TOKEN_COUNT NOT NULL NUMBER(10) TOKEN_INFO BLOB
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Optimierung von TOKEN_INFO mit “BIG_IO”• Realisierung über neue Storage Preference BIG_IO
• Sample Code: big_io.sql, big_io_test.sqlhttp://oracle-text-de.blogspot.in/2015/06/12c-feature-i-tabelle-mit-neuer-storage.html
exec ctx_ddl.create_preference('my_storage', 'BASIC_STORAGE' )exec ctx_ddl.set_attribute('my_storage', 'BIG_IO', 'true' )
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. Oracle Confidential – Internal/Restricted/Highly Restricted
11
Optimierung von TOKEN_INFO mit „separate Offsets“ • TOKEN_INFO besteht aus DOCID und OFFSET Informationen
1001 Nacht und Tag, Tag und Nacht 1002 Es war eine stürmische Nacht
NACHT (DOCID 1, INFO 1,2)(DOCID 2, INFO 3) TAG (DOCID 1, INFO 4,5)
STÜRMISCHE (DOCID 2, INFO 6)
TOKEN_TEXT TOKEN_INFO (BLOB)
ID TEXT
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Optimierung von TOKEN_INFO mit “Separate Offsets”• Problematik: Offset Daten können groß werden• Wann überhaupt Offset Informationen?– Notwendig für Phrasen, NEAR und Zone Section Abfragen– NICHT notwendig für Single Term Abfragen, Boolean oder Score Suche, bei AND, OR,
NOT, MINUS und FIELD Suche
ÞNeu in 12c: DOCID und Token Offsets können in separaten Spalten abgelegt werden
• Sample Code: separate_offsets.sql
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Optimierung von TOKEN_INFO mit “Separate Offsets”• Neue Option SEPARATE_OFFSETSexec ctx_ddl.create_preference( 'my_storage', 'BASIC_STORAGE' )exec ctx_ddl.set_attribute ( 'my_storage', 'SEPARATE_OFFSETS', 'true' )
describe dr$my_index$i Name Null? Type ----------------------------------------- -------- ---------------------- TOKEN_TEXT NOT NULL VARCHAR2(64) TOKEN_TYPE NOT NULL NUMBER(10) TOKEN_FIRST NOT NULL NUMBER(10) TOKEN_LAST NOT NULL NUMBER(10) TOKEN_COUNT NOT NULL NUMBER(10) TOKEN_INFO BLOB TOKEN_OFFSETS BLOB
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Performance mit Forward und Save Copy Index• Problem: Snippets und Highlight Operationen sind langsam, da das ganze
Dokument noch einmal ”processed” werden muss• Lösung: – Kopie als Forward Index in neue Tabelle $O– “Save Copy” Ablage in neue Tabelle $D (zusätzlich Compressed, Tokinized mit
Stopwörtern, als Plaintext oder gefiltert)
• Sample Code: forward_index.sql, snippets.sqlhttp://oracle-text-de.blogspot.de/2015/02/schnellere-text-abfragen-mit-snippet-in.html
exec ctx_ddl.create_preference( 'my_store', 'BASIC_STORAGE' )exec ctx_ddl.set_attribute ( 'my_store', 'FORWARD_INDEX', 'TRUE' )exec ctx_ddl.set_attribute ( 'my_store', 'SAVE_COPY', 'PLAINTEXT' )
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Spezieller Ergebniscache für Text-Abfragen
• Ähnlich wie bei Query Result Cache: spezieller Bereich für sich wiederholende Resultate• Gut geeignet für nachträgliches Filtern von Ergebnissen• Neue Storage Option QUERY_FILTER_CACHE_SIZE
• Neue Operator CTXFILTERCACHE mit zusätzlichen Optionen wie “save score” oder nur “top N by score”
execute ctx_ddl.create_preference('my_i_storage', 'basic_storage'); execute ctx_ddl.set_attribute('my_i_storage','query_filter_cache_size', '10M');
ctxfiltercache((query_text) [, save_score] [, topN])
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Spezieller Ergebniscache für Text-Abfragen - Beispiele
select * from texttabelle where contains(dokument, 'ctxfiltercache((Obama), true, true) and sdata(ressort = ''Politik'')' ) > 0;
exec ctx_query.store_sqe( 'securityclause1', '( john within secusers or sales within secgroups )', ctx_query.DURATION_SESSION);
select * from my_table where contains(text, 'fox and SQE(securityclause1)') > 0;select * from my_table where contains( text, 'fox and ctxfiltercache( (SQE(securityclause1)) )') > 0;
• Auch mit neuem Feature Session Duration Stored Query Expressions (SQE)
• Sample code: query_filter_cache.sqlhttp://oracle-text-de.blogspot.de/2014/09/ergebniscache-fur-text-abfragen.html
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Operatoren: NEAR und MNOT
• NEAR Erweiterungen– Nested NEAR; NEAR zusätzlich mit Ausdrücken
• MNOT (mild not) Operator–Wörter, welche nicht Teil sind von …
• Sample Code: mnot.sql
SELECT * FROM docs WHERE CONTAINS(txt, 'near((near((term1, term2),5), term3), 100)')>0
select * from my_table where contains(text, 'york MNOT new york' ) > 0; York is in Yorkshire, New York is in New YorkYork is a city in England
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Pattern Stopclass
• Definition von Stopwörtern mit “regular expression”• Beispiele– Keine Zahlen >= 5 Ziffern
– Keine langen Wörter >= 20 Zeichen
• Hinweis: Definition einer eigenen Stopliste ist erforderlich (nicht anwendbar auf Default Listen)• Sample Code: pattern_stopclass.sql
http://oracle-text-de.blogspot.de/2013/07/oracle-text-in-oracle12c-neues-feature.html
ctx_ddl.add_stopclass('stop', 'longwords', '[[:alnum:]]{20,}' )
exec ctx_ddl.add_stopclass('stop', 'fivedignums', '[[:digit:]\,\.]{5,}')
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Languages und Lexer• Neue CTX_DOC Prozedur policy_languages– Liefert Liste der Sprachen für ein Dokument (vergleichbar mit AUTO_LEXER)
• Document Level Lexer– Verschiedene Lexer für unterschiedliche Dokumente => Sprachen unabhängiger
Sublexer– Basiert auf MULTI_LEXER Technologie
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
SDATA Erweiterungen
• Updatable SDATA Sections– Synchrone Updates auf SDATA ohne Re-Indizierung
• Hinzufügen von SDATA Sektionen zum existierenden Index– Kein Re-Create erforderlich
• Mehr SDATA Sektionen (Maximal 99)–Maximum FILTER BY / ORDER BY noch bei 32
• Sample Code: sdata.sql
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
SDATA Erweiterungen
• Query Template kann nun nach SDATA sortieren<query> <textquery> digital and sdata(stocklevel > 4) </textquery> <order> <orderkey> SDATA(stocklevel) desc </orderkey> <orderkey> score desc </orderkey> </order></query>
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Änderungen an Datastore Trigger
• Index auf verschiedenen Spalten mit MULTI_COLUMN_STORE und USER_DATASTORE– Normalerweise Verwendung von Triggern wie folgt
• In 12c wird nun der Status von allen Spalten überprüft! Trigger wirkt nur wenn alle Spalten verändert wurden.• Fix mit Session oder System Kommando
CREATE OR REPLACE TRIGGER customer_update_trg BEFORE UPDATE OF lastname ON customers FOR EACH ROW BEGIN :new.firstname := :new.firstname; END;
alter session set "_fix_control"='14155722:OFF'
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Snippet Support in Result Set Interface
• Result Set Interface – XML Query Support seit 11g– Result Set Descriptor (XML Block) beschreibt Resultate in einem (!) SQL Call– Bereits für ROWIDs und SDATA Werte
• Ab 12c auch für Snippets<ctx_result_set_descriptor> <hitlist start_hit_num="1" end_hit_num="10" order="SCORE DESC"> <rowid /> <score /> <sdata name="title" /> <snippet radius="20" max_length="160" starttag="<b>" endtag="</b>" /> </hitlist> <count /></ctx_result_set_descriptor>
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
XQuery Text Unterstützung• Volltextsuche im XML DB Framework• “Universal Index” erlaubt das Mischen von strukturierten und
unstrukturierten Daten• Nutze PATH SECTION Typ mit XML_ENABLE = 'true'
SELECT po.idFROM PURCHASEORDER poWHERE XMLExists ('$src/purchaseOrder/billingInstruction/Address
[. contains text {$PHRASE1} ftand {$PHRASE2} using stemming] ' PASSING po.x, 'Science' as “PHRASE1”, 'Magdalen' as“PHRASE2”)
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
New Features im Überblick• Performance– Erhöhung von MAX_INDEX_MEMORY für mehr OPTIMIZE und CREATE Performance– Near Real Time Index: Häufige Index Syncs ohne Fragmentierung– BIG_IO: Neue Indexarchitektur reduziert Index Lookups bei großen Indexfragmenten– Separate Offsets: Trennung der Offset Informationen in der Indexstruktur reduziert
I/O für Abfragen, in denen Wortpositionen nicht gebraucht wird–Query Result Cache: Spezieller Ergebniscache– Pattern Stopclass: reguläre Ausdrücke für Tokens, die nicht indiziert werden sollen
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
New Features im Überblick• Document Service– „Forward and Save Copy“ Index: mehr Performance für Snippet Operationen– Snippets für Result Set Interface
• Abfragen– Neue und erweiterte Operatoren– SDATA Erweiterungen
• Internationalisierung– Document Lexer
Copyright © 2014 Oracle and/or its affiliates. All rights reserved.
Informationen• White Paper– http://www.oracle.com/technetwork/database/information-management/oracletext
12cfeatures-1932547.pdf
• Sample Code auf OTN– http://www.oracle.com/us/products/database/enterprise-edition/12ctechnicalovervi
ew-1961500.zip?ssSourceSiteId=otnen
• OTN mit Oracle Text– http://www.oracle.com/technetwork/database/features/index-098492.html