2017-01-23 968 views
0

我想創建一個部分索引來加速我的postgresql數據庫中的全文搜索。Postgresql部分索引超過最大索引行大小

index row requires 16016 bytes, maximum size is 8191 

,一些描述是相當長的,並且超過了我的索引行限制:

CREATE INDEX book_search_not_null_index ON books(description) WHERE description IS NOT NULL; 

當試圖創建我的索引我收到以下錯誤。儘管我想從我的索引中獲得所需,但要確保我不考慮沒有描述的書籍(大約10%的描述爲空)。有沒有辦法解決這個限制或更好的方法來構造這個索引?

回答

1

使用GIN indexes for full text search

create index book_search_not_null_index ON books 
using GIN (to_tsvector('english', description)) 
where description is not null 
+0

感謝您的答覆,我實際使用的的tsvector的指標,現在,但是是的tsvector如果無效的描述,我想排除的那些行搜索。有沒有一個好的方法來做到這一點? – user1023465

+0

@ user1023465:編輯'在哪裏......' –

+0

哦,這很完美,非常感謝! – user1023465