Dan
Dan

Reputation: 2847

Postgresql partial index exceeds maximum index row size

I am trying to create a partial index to speed up full text search in my postgresql database.

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

I am getting the following error when trying to create my index:

index row requires 16016 bytes, maximum size is 8191

Some of the descriptions are quite long and are exceeding the row limit for my index. All I want from my index though is to make sure that I am not considering books with no description in my search (roughly 10% of the descriptions are null). Is there any way around this restriction or a better way to structure this index?

Upvotes: 4

Views: 5733

Answers (1)

Clodoaldo Neto
Clodoaldo Neto

Reputation: 125444

Use 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

Upvotes: 3

Related Questions