【问题标题】:Is it possible to create a multitype multicolumn index?是否可以创建多类型多列索引?
【发布时间】:2011-09-06 17:09:49
【问题描述】:

如果一个表的 A 列是几何类型,B 列是时间戳(1),没有时区类型, PostgreSQL 是否允许在 A 列和 B 列上创建多类型多列索引?

the index column : (columnA, column B)  

我想在part列A列上创建一个gist索引,在part列columnB上创建一个btree索引;

以下是我的情况,我想优化以下sql。

SELECT id,content,the_geo,lon,lat,skyid,addtime FROM mapfriends.user_map_book 
where          the_geo && mapfriends.ST_BUFFER(mapfriends.geometryfromtext('POINT(100.54687 36.06684)'),0.001)     
order by addtime desc limit 30  

表的索引

db_lbs=> \d mapfriends.user_map_book
                                           Table "mapfriends.user_map_book"
    Column    |              Type              |                               Modifiers                               
--------------+--------------------------------+-----------------------------------------------------------------------
 id           | integer                        | not null default nextval('mapfriends.user_map_book_id_seq'::regclass)
 content      | character varying(100)         | 
 lon          | double precision               | 
 lat          | double precision               | 
 skyid        | integer                        | 
 addtime      | timestamp(1) without time zone | default now()
 the_geo      | mapfriends.geometry            | 
 viewcount    | integer                        | default 0
 lastreadtime | timestamp without time zone    | 
 ischeck      | boolean                        | 
Indexes:
    "user_map_book_pkey" PRIMARY KEY, btree (id)
    "idx_map_book_skyid" btree (skyid, addtime)
    "idx_user_map_book_atime" btree (addtime DESC)
    "user_map_book_idx_gin" gist ((the_geo::box))

【问题讨论】:

  • 按照 Frank Heikens 的建议,您尝试过吗?它有效吗?另外,你见过this 吗?这可能是你的答案。对于 (tsvector , date) 索引,我对 GIN 有同样的问题。

标签: postgresql


【解决方案1】:

来自manual

目前,仅支持 B-tree、GiST 和 GIN 索引类型 多列索引。

试试看吧!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-15
    • 2017-05-24
    • 1970-01-01
    • 2013-01-27
    • 1970-01-01
    • 2015-09-20
    • 1970-01-01
    • 2012-12-14
    相关资源
    最近更新 更多