<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當(dāng)前位置: 首頁(yè) - 科技 - 知識(shí)百科 - 正文

        初識(shí)全文索引

        來(lái)源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-09 15:12:03
        文檔

        初識(shí)全文索引

        初識(shí)全文索引:通常來(lái)說(shuō),全文索引大多用在OLAP環(huán)境當(dāng)中,全文索引擅長(zhǎng)于詞匯的快速搜索。 一、全文索引和普通b_tree索引對(duì)比 SQL create tablet1 (id int,name varchar(10)); Table created. SQL create indext1_ind on t1(name); In
        推薦度:
        導(dǎo)讀初識(shí)全文索引:通常來(lái)說(shuō),全文索引大多用在OLAP環(huán)境當(dāng)中,全文索引擅長(zhǎng)于詞匯的快速搜索。 一、全文索引和普通b_tree索引對(duì)比 SQL create tablet1 (id int,name varchar(10)); Table created. SQL create indext1_ind on t1(name); In

        通常來(lái)說(shuō),全文索引大多用在OLAP環(huán)境當(dāng)中,全文索引擅長(zhǎng)于詞匯的快速搜索。 一、全文索引和普通b_tree索引對(duì)比 SQL create tablet1 (id int,name varchar(10)); Table created. SQL create indext1_ind on t1(name); Index created. SQL create tablet2 as s

        通常來(lái)說(shuō),全文索引大多用在OLAP環(huán)境當(dāng)中,全文索引擅長(zhǎng)于詞匯的快速搜索。

        一、全文索引和普通b_tree索引對(duì)比

        SQL> create tablet1 (id int,name varchar(10));

        Table created.

        SQL> create indext1_ind on t1(name);

        Index created.

        SQL> create tablet2 as select * from t1;

        Table created.

        SQL> create indext2_ind on t2(name) indextype is ctxsys.context;

        Index created.

        SQL> select *from t1 where name like '%tom%';

        ID NAME

        --------------------

        1 tom

        2 tom tom

        2 tom tom

        Execution Plan

        ----------------------------------------------------------

        Plan hash value:3589342044

        --------------------------------------------------------------------------------------

        | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

        --------------------------------------------------------------------------------------

        | 0 | SELECT STATEMENT | | 1 | 10 | 2 (0)| 00:00:01 |

        | 1 | TABLE ACCESS BY INDEX ROWID| T1 | 1 | 10 | 2 (0)| 00:00:01 |

        |* 2 | INDEX FULL SCAN | T1_IND| 1 | | 1 (0)| 00:00:01 |

        --------------------------------------------------------------------------------------

        PredicateInformation (identified by operation id):

        ---------------------------------------------------

        2 - filter("NAME" LIKE '%tom%' AND"NAME" IS NOT NULL)

        Statistics

        ----------------------------------------------------------

        0 recursive calls

        0 db block gets

        4 consistent gets

        0 physical reads

        0 redo size

        676 bytes sent via SQL*Net to client

        519 bytes received via SQL*Net from client

        2 SQL*Net roundtrips to/from client

        0 sorts (memory)

        0 sorts (disk)

        3 rows processed

        SQL> select *from t2 where contains(name,'tom')>0;

        ID NAME

        --------------------

        1 tom

        2 tom tom

        2 tom tom

        Execution Plan

        ----------------------------------------------------------

        Plan hash value:785228215

        --------------------------------------------------------------------------------------

        | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

        --------------------------------------------------------------------------------------

        | 0 | SELECT STATEMENT | | 3 | 30 | 7 (0)| 00:00:01 |

        | 1 | TABLE ACCESS BY INDEX ROWID| T2 | 3 | 30 | 7 (0)| 00:00:01 |

        |* 2 | DOMAIN INDEX | T2_IND| | | 1 (0)| 00:00:01 |

        --------------------------------------------------------------------------------------

        PredicateInformation (identified by operation id):

        ---------------------------------------------------

        2 -access("CTXSYS"."CONTAINS"("NAME",'tom')>0)

        Statistics

        ----------------------------------------------------------

        10 recursive calls

        0 db block gets

        14 consistent gets

        0 physical reads

        0 redo size

        676 bytes sent via SQL*Net to client

        519 bytes received via SQL*Net from client

        2 SQL*Net roundtrips to/from client

        0 sorts (memory)

        0 sorts (disk)

        3 rows processed

        SQL> selectobject_name,object_type from user_objects order by 1;

        OBJECT_NAME OBJECT_TYPE

        -------------------------------------------------

        --DR開頭的四張表為全文索引的基表

        DR$T2_IND$X INDEX

        DRC$T2_IND$R INDEX

        SYS_IL0000236119C00006$$ INDEX

        SYS_IL0000236124C00002$$ INDEX

        SYS_IOT_TOP_236122 INDEX

        SYS_IOT_TOP_236128 INDEX

        SYS_LOB0000236119C00006$$ LOB

        OBJECT_NAME OBJECT_TYPE

        -------------------------------------------------

        SYS_LOB0000236124C00002$$ LOB

        T1 TABLE

        T1_IND INDEX

        T2 TABLE

        T2_IND INDEX

        二、DML操作對(duì)全文索引的影響

        以context方式創(chuàng)建的全文索引并不是基于事務(wù)的,默認(rèn)情況下,即使一個(gè)dml操作提交,信息也不會(huì)更新到全文索引中。

        1、insert 操作

        SQL> create tablet(name varchar2(30));

        Table created.

        SQL> create indext_ind on t(name) indextype is ctxsys.context;

        Index created.

        SQL> insert intot values('i am an oracle dba');

        1 row created.

        SQL> commit;

        insert數(shù)據(jù)已提交,我們看看全文索引是否已更新

        SQL> setautotrace on

        SQL> select *from t where name like '%dba%';

        NAME

        ------------------------------

        i am an oracle dba

        Execution Plan

        ----------------------------------------------------------

        Plan hash value:1601196873

        --------------------------------------------------------------------------

        | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

        --------------------------------------------------------------------------

        | 0 | SELECT STATEMENT | | 1 | 17 | 2 (0)| 00:00:01 |

        |* 1 | TABLE ACCESS FULL| T | 1 | 17 | 2 (0)| 00:00:01 |

        --------------------------------------------------------------------------

        PredicateInformation (identified by operation id):

        ---------------------------------------------------

        1 - filter("NAME" IS NOT NULL AND"NAME" LIKE '%dba%')

        Note

        -----

        - dynamic sampling used for this statement(level=2)

        Statistics

        ----------------------------------------------------------

        5 recursive calls

        0 db block gets

        15 consistent gets

        0 physical reads

        0 redo size

        538 bytes sent via SQL*Net to client

        520 bytes received via SQL*Net from client

        2 SQL*Net roundtrips to/from client

        0 sorts (memory)

        0 sorts (disk)

        1 rows processed

        SQL> set line 200

        SQL> select *from t where contains(name,'dba') >0;

        no rows selected

        Execution Plan

        ----------------------------------------------------------

        Plan hash value:315187259

        -------------------------------------------------------------------------------------

        | 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 | 1 | 29 | 4 (0)| 00:00:01 |

        |* 2 | DOMAIN INDEX | T_IND| | | 4 (0)| 00:00:01 |

        -------------------------------------------------------------------------------------

        PredicateInformation (identified by operation id):

        ---------------------------------------------------

        2 -access("CTXSYS"."CONTAINS"("NAME",'dba')>0)

        Note

        -----

        - dynamic sampling used for this statement(level=2)

        Statistics

        ----------------------------------------------------------

        1829 recursive calls

        0 db block gets

        2696 consistent gets

        30 physical reads

        0 redo size

        332 bytes sent via SQL*Net to client

        509 bytes received via SQL*Net from client

        1 SQL*Net roundtrips to/from client

        164 sorts (memory)

        0 sorts (disk)

        0 rows processed

        以上發(fā)現(xiàn),全文索引并沒有自動(dòng)更新,而是把記錄存放在線面的ctxsys.dr$pending表中。

        SQL> setautotrace off

        SQL> select *from ctxsys.dr$pending;

        PND_CID PND_PID PND_ROWID PND_TIMESTAMP P

        -------------------- ------------------ ------------------ -

        1084 0 AABGmVAAEAAAADmAAA 03-APR-14 N

        SQL> insert intot values('he is an oracle dba');

        1 row created.

        SQL> commit;

        Commit complete.

        SQL> select *from ctxsys.dr$pending;

        PND_CID PND_PID PND_ROWID PND_TIMESTAMP P

        -------------------- ------------------ ------------------ -

        1084 0 AABGmVAAEAAAADmAAA 03-APR-14 N

        1084 0 AABGmVAAEAAAADmAAB 03-APR-14 N

        SQL> select *from t where contains(name,'dba') >0;

        no rows selected

        為了把信息同步到全文索引中,我們需要手工同步:

        SQL> alter indext_ind rebuild parameters ('sync');

        Index altered.

        SQL> select *from t where contains(name,'dba') >0;

        NAME

        ------------------------------

        i am an oracle dba

        he is an oracle dba

        SQL> select *from ctxsys.dr$pending;

        no rows selected

        2、delete操作

        SQL> select *from t;

        NAME

        ------------------------------

        i am an oracle dba

        he is an oracle dba

        SQL> delete fromt where name='he is an oracle dba';

        1 row deleted.

        SQL> select *from t where contains(name,'dba') >0;

        NAME

        ------------------------------

        i am an oracle dba

        SQL> select *from ctxsys.dr$pending;

        no rows selected

        SQL> select *from ctxsys.dr$delete;

        DEL_IDX_IDDEL_IXP_ID DEL_DOCID

        -------------------- ----------

        1084 0 2

        這里我們看到全文索引立即生效了,至于ctxsys.dr$delete里面的數(shù)據(jù)是delete操作的中間狀態(tài),用來(lái)維護(hù)一個(gè)事物,無(wú)論事物提交或者回滾。

        SQL> rollback;

        Rollback complete.

        SQL> select *from t where contains(name,'dba') >0;

        NAME

        ------------------------------

        i am an oracle dba

        he is an oracle dba

        SQL> select *from ctxsys.dr$delete;

        no rows selected

        3、update操作

        update操作相當(dāng)于delete+insert操作,所以默認(rèn)情況下需要手動(dòng)刷新全文索引。

        SQL> update t setname='oracle dba' where name='i am an oracle dba';

        1 row updated.

        SQL> select *from ctxsys.dr$delete;

        DEL_IDX_IDDEL_IXP_ID DEL_DOCID

        -------------------- ----------

        1084 0 1

        SQL> select *from ctxsys.dr$pending;

        PND_CID PND_PID PND_ROWID PND_TIMESTAMP P

        -------------------- ------------------ ------------------ -

        1084 0 AABGmVAAEAAAADmAAA 03-APR-14 N

        SQL> select *from t where contains(name,'dba') > 0;

        NAME

        ------------------------------

        he is an oracle dba

        SQL> alter indext_ind rebuild parameters ('sync');

        Index altered.

        SQL> select *from t where contains(name,'dba') > 0;

        NAME

        ------------------------------

        he is an oracle dba

        oracle dba

        由于全文索引創(chuàng)建對(duì)象大多是海量數(shù)據(jù)的表,dml操作如果實(shí)時(shí)更新會(huì)影響到系統(tǒng)性能。創(chuàng)建全文索引同步的三個(gè)選項(xiàng):

        manual:默認(rèn)選項(xiàng)

        every:在一個(gè)時(shí)間段后更新索引

        on commitdml:在事務(wù)提交后更新索引

        語(yǔ)法如下:

        create index t_indon t(name) indextype is ctxsys.context parameters('sync (on commit)');

        查看全文索引信息和性能的工具包c(diǎn)tx_report

        聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        初識(shí)全文索引

        初識(shí)全文索引:通常來(lái)說(shuō),全文索引大多用在OLAP環(huán)境當(dāng)中,全文索引擅長(zhǎng)于詞匯的快速搜索。 一、全文索引和普通b_tree索引對(duì)比 SQL create tablet1 (id int,name varchar(10)); Table created. SQL create indext1_ind on t1(name); In
        推薦度:
        標(biāo)簽: 全文 大多 通常
        • 熱門焦點(diǎn)

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲另类激情综合偷自拍图| 亚洲丝袜中文字幕| 国产亚洲美日韩AV中文字幕无码成人| 亚洲AV日韩精品久久久久久久| 亚洲国产精品一区二区三区在线观看| 一级做a爰片性色毛片免费网站| 91高清免费国产自产拍2021| 亚洲精品国产精品乱码不卡| 亚洲人成综合网站7777香蕉| 四虎永久在线观看免费网站网址| 亚洲中文字幕久久精品无码喷水 | 三级黄色在线免费观看| 久久综合AV免费观看| 亚洲av女电影网| 色猫咪免费人成网站在线观看| 亚洲欧洲日产国码一级毛片 | 久久久久久久岛国免费播放| 亚洲精品国产成人99久久| 九九九精品视频免费| 日韩高清免费观看| 亚洲另类春色校园小说| 日韩免费高清播放器| 亚洲色偷拍区另类无码专区| 亚洲av永久中文无码精品综合 | 阿v免费在线观看| 性做久久久久久久免费看| 午夜亚洲AV日韩AV无码大全| 久久午夜夜伦鲁鲁片免费无码影视| 国产亚洲综合网曝门系列| 日韩免费人妻AV无码专区蜜桃| 亚洲免费观看视频| 91在线免费视频| 国产AV无码专区亚洲AWWW| 国产成人AV片无码免费| 久久精品国产亚洲| 国产午夜不卡AV免费| 亚洲人成网站日本片| 亚洲另类少妇17p| 18禁黄网站禁片免费观看不卡| 亚洲AV无码一区二区大桥未久| 免费黄网在线观看|