简体   繁体   English

Rails全文Postgres搜索:db中的索引是强制性的吗?

[英]Rails Full Text Postgres search: are index in db mandatory?

Maybe is a stupid question, but I'm adding full text search to my small CMS. 也许这是一个愚蠢的问题,但是我正在为小型CMS添加全文搜索。

I'm following the guide here and I have installed pg_search gem. 我在这里遵循指南并且已经安装了pg_search gem。 I add the search function to my Content model and Product mode, and everything is working but is very very slow. 我将搜索功能添加到我的“内容”模型和“产品”模式中,一切正常,但速度非常慢。

I don't add any index to my db table with migration: I'm searching on content.name and content.summary: do I need indexes too? 我不会在迁移时向数据库表添加任何索引:我正在搜索content.name和content.summary:我也需要索引吗?

No, they aren't mandatory, but they will most likely speed up (significantly) the searches. 不,它们不是强制性的,但它们很可能会(显着)加快搜索速度。

From the PostgreSQL docs: PostgreSQL文档:

Note that indexes are not mandatory for full text searching, but in cases where a column is searched on a regular basis, an index is usually desirable 请注意,对于全文搜索而言,索引不是必需的,但是在定期搜索列的情况下,通常需要索引

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM