PostgreSQL hstore 列效能提升案例

來源:互聯網
上載者:User

PostgreSQL 支援hstore 來存放KEY->VALUE這類資料, 其實也類似於ARRAY或者JSON類型。  要高效的使用這類資料,當然離不開高效的索引。我們今天就來看看兩類不同的索引對於同一種檢索請求的效能問題。

假如我們有這樣一個原始表,基於str1欄位有一個BTREE索引。

t_girl=# \d status_check;
          Table "ytt.status_check"
 Column |        Type          | Modifiers
--------+-----------------------+-----------
 is_yes | boolean              | not null
 str1  | character varying(20) | not null
 str2  | character varying(20) | not null
Indexes:
    "index_status_check_str1" btree (str1)

裡面有10W條記錄。 資料大概如下,

t_girl=# select * from status_check limit 2;
 is_yes | str1 |        str2       
--------+------+----------------------
 f      | 0    | cfcd208495d565ef66e7
 t      | 1    | c4ca4238a0b923820dcc
(2 rows)


Time: 0.617 ms
t_girl=#

存放hstore類型的status_check_hstore 表結構,基於str1_str2欄位有一個GIST索引。

 Table "ytt.status_check_hstore"
  Column  |  Type  | Modifiers
-----------+---------+-----------
 is_yes    | boolean |
 str1_str2 | hstore  |
Indexes:
    "idx_str_str2_gist" gist (str1_str2)

 

t_girl=# select * from status_check_hstore limit 2;
 is_yes |          str1_str2         
--------+-----------------------------
 f      | "0"=>"cfcd208495d565ef66e7"
 t      | "1"=>"c4ca4238a0b923820dcc"
(2 rows)


Time: 39.874 ms

更多詳情見請繼續閱讀下一頁的精彩內容:

------------------------------------華麗麗的分割線------------------------------------

CentOS 6.3環境下yum安裝PostgreSQL 9.3

PostgreSQL緩衝詳述

Windows平台編譯 PostgreSQL

Ubuntu下LAPP(Linux+Apache+PostgreSQL+PHP)環境的配置與安裝

Ubuntu上的phppgAdmin安裝及配置

CentOS平台下安裝PostgreSQL9.3

PostgreSQL配置Streaming Replication叢集

------------------------------------華麗麗的分割線------------------------------------

PostgreSQL 的詳細介紹:請點這裡
PostgreSQL 的:請點這裡

  • 1
  • 2
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.