Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 943
Dan Avatar asked Sep 19 '25 02:09

Dan


1 Answers

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
like image 129
Clodoaldo Neto Avatar answered Sep 20 '25 18:09

Clodoaldo Neto