Postgresql 是否可以创建多类型多列索引?
如果一个表的a列是几何类型,B列是没有时区类型的时间戳(1), PostgreSQL是否允许在a列和B列上创建多类型多列索引Postgresql 是否可以创建多类型多列索引?,postgresql,Postgresql,如果一个表的a列是几何类型,B列是没有时区类型的时间戳(1), PostgreSQL是否允许在a列和B列上创建多类型多列索引 the index column : (columnA, column B) 我想在零件列a上创建一个要点索引,在零件列B上创建一个btree索引 下面是我的例子,我想优化下面的sql SELECT id,content,the_geo,lon,lat,skyid,addtime FROM mapfriends.user_map_book where
the index column : (columnA, column B)
我想在零件列a上创建一个要点索引,在零件列B上创建一个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))
从:
目前,只有B树、GiST和GIN索引类型支持
多列索引
试试看 正如Frank Heikens所建议的,你试过了吗?它有用吗?还有,你看到了吗?这可能是你的答案。我对GIN有同样的问题,关于(tsvector,date)索引。