【问题标题】:Postgresql partial index exceeds maximum index row sizePostgresql 部分索引超出最大索引行大小
【发布时间】:2017-01-23 16:50:00
【问题描述】:

我正在尝试创建部分索引以加快我的 postgresql 数据库中的全文搜索。

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

尝试创建索引时出现以下错误:

index row requires 16016 bytes, maximum size is 8191

有些描述很长,超出了我的索引的行数限制。不过,我想要从我的索引中获得的只是确保我在搜索中不考虑没有描述的书籍(大约 10% 的描述是空的)。有没有办法绕过这个限制或更好的方法来构建这个索引?

【问题讨论】:

    标签: postgresql indexing


    【解决方案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
    

    【讨论】:

    • 感谢您的回复,我现在实际上正在使用 tsvector 的索引,但如果描述是,则 tsvector 为空,我想从搜索中排除这些行。有什么好的方法吗?
    • @user1023465:编辑where...
    猜你喜欢
    • 1970-01-01
    • 2020-03-23
    • 1970-01-01
    • 2013-10-09
    • 2018-11-30
    • 1970-01-01
    • 2018-03-10
    • 2018-10-05
    • 1970-01-01
    相关资源
    最近更新 更多