是否可以创建多字符多列索引?

时间:2011-09-06 07:18:35

标签: postgresql

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

the index column : (columnA, column B)  

我想在零件列A列上创建一个gist索引,并在零件列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))

1 个答案:

答案 0 :(得分:0)

来自manual

  

目前,只支持B树,GiST和GIN索引类型   多列索引。

试一试!