<del id="d4fwx"><form id="d4fwx"></form></del>
      <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

            <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
          • 怎么使用PostgreSQL中Hash索引-創(chuàng)新互聯(lián)

            本篇內(nèi)容介紹了“怎么使用PostgreSQL中Hash索引”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

            創(chuàng)新互聯(lián)從2013年開始,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目網(wǎng)站制作、成都網(wǎng)站制作網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元白堿灘做網(wǎng)站,已為上家服務(wù),為白堿灘各地企業(yè)和個人服務(wù),聯(lián)系電話:18982081108

            邏輯結(jié)構(gòu)
            可以把Hash Index理解為一個Hash Table,每個Hash bucket存儲根據(jù)Hash Function計算得到的對應(yīng)的索引條目,為了節(jié)省空間,Hash索引條目只存儲Hash Code(即Hash Value) + TID而不存儲Hash Key(即索引鍵值),掃描索引后還必須讀取相應(yīng)的數(shù)據(jù)表行,因此Index Only Scan不適用于Hash Index.

            testdb=# drop table if exists t_idx1;
            DROP TABLE
            testdb=# create table t_idx1(id int,c1 varchar(20));
            CREATE TABLE
            testdb=# create index idx_t_idx1_id on t_idx1 using hash(id);
            CREATE INDEX
            testdb=# insert into t_idx1 select generate_series(1,100000);
            INSERT 0 100000
            testdb=# analyze t_idx1;
            ANALYZE
            testdb=# explain verbose select * from t_idx1 where id = 1;
                                                 QUERY PLAN                                     
            ------------------------------------------------------------------------------------
             Index Scan using idx_t_idx1_id on public.t_idx1  (cost=0.00..8.02 rows=1 width=62)
               Output: id, c1
               Index Cond: (t_idx1.id = 1)
            (3 rows)
            testdb=# -- 不能實現(xiàn)Index Only Scan
            testdb=# explain verbose select id from t_idx1 where id = 100;
                                                QUERY PLAN                                     
            -----------------------------------------------------------------------------------
             Index Scan using idx_t_idx1_id on public.t_idx1  (cost=0.00..8.02 rows=1 width=4)
               Output: id
               Index Cond: (t_idx1.id = 100)
            (3 rows)

            而普通的B-Tree索引是可以Index Only Scan的:

            testdb=# create table t_idx2(id int,c1 varchar(20));
            CREATE TABLE
            testdb=# insert into t_idx2 select generate_series(1,100000);
            INSERT 0 100000
            testdb=# create index idx_t_idx2_id on t_idx2 using btree(id);
            CREATE INDEX
            testdb=# analyze t_idx2;
            ANALYZE
            testdb=# explain verbose select id from t_idx2 where id = 100;
                                                   QUERY PLAN                                       
            ----------------------------------------------------------------------------------------
             Index Only Scan using idx_t_idx2_id on public.t_idx2  (cost=0.29..8.31 rows=1 width=4)
               Output: id
               Index Cond: (t_idx2.id = 100)
            (3 rows)

            有四種頁面,分別是Meta page,Bucket Page,Overflow page和Bitmap page.

            頁面類型說明
            Meta pagepage number zero, which contains information on what is inside the index.
            Bucket pagesmain pages of the index, which store data as ?hash code — TID? pairs.
            Overflow pagesstructured the same way as bucket pages and used when one page is insufficient for a bucket
            Bitmap pageswhich keep track of overflow pages that are currently clear and can be reused for other buckets

            使用pageinspect插件可查看index中的相關(guān)信息

            testdb=# select hash_page_type(get_raw_page('idx_t_idx1_id',0));
             hash_page_type 
            ----------------
             metapage
            (1 row)
            testdb=# select hash_page_type(get_raw_page('idx_t_idx1_id',1));
             hash_page_type 
            ----------------
             bucket
            (1 row)
            testdb=# \x
            Expanded display is on.
            testdb=# select * from hash_page_stats(get_raw_page('idx_t_idx1_id',1));
            -[ RECORD 1 ]---+-----------
            live_items      | 189
            dead_items      | 0
            page_size       | 8192
            free_size       | 4368
            hasho_prevblkno | 256
            hasho_nextblkno | 4294967295
            hasho_bucket    | 0
            hasho_flag      | 2
            hasho_page_id   | 65408
            testdb=# select * from hash_page_stats(get_raw_page('idx_t_idx1_id',2));
            -[ RECORD 1 ]---+-----------
            live_items      | 201
            dead_items      | 0
            page_size       | 8192
            free_size       | 4128
            hasho_prevblkno | 257
            hasho_nextblkno | 4294967295
            hasho_bucket    | 1
            hasho_flag      | 2
            hasho_page_id   | 65408

            “怎么使用PostgreSQL中Hash索引”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

            標(biāo)題名稱:怎么使用PostgreSQL中Hash索引-創(chuàng)新互聯(lián)
            網(wǎng)頁路徑:http://www.jbt999.com/article44/cddpee.html

            成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)ChatGPT定制網(wǎng)站網(wǎng)站建設(shè)網(wǎng)站內(nèi)鏈網(wǎng)站改版

            廣告

            聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

            手機網(wǎng)站建設(shè)

              <del id="d4fwx"><form id="d4fwx"></form></del>
              <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

                    <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
                  • www.av7.av | 色之综合天天综合色天天素质 | 草草视频在线 | 午夜福利在线视频 | 蜜桃精品av久久久久久 |