postgresql - Postgres - Gin 索引不起作用

标签 postgresql full-text-search

看来我的服务器不会使用gin index。

  1. 我创建了一个包含一张表的新数据库。
  2. 我插入了一行作为示例。
  3. 我已经加载了 trigram 扩展并使用 trigram 创建了 gin 索引
  4. 但是当我检查索引是否正常工作时,我发现它不正常
  5. 有什么想法吗?

SQL: http://pastebin.com/1yDQQA1Z

附言一天前,我学习了一个关于三元组的教程。基本上它和我上面的例子一样。该表有 2 列,numeric(5, 0) 和 character varying(具有 gin trgm 索引的列)。查询与使用“%”的类似运算符一起使用,并且索引正常工作(我可以在查询解释中看到使用位图),所以我知道,我的服务器可以使用索引(并且已正确安装)。

提前致谢。

最佳答案

不要在一行上测试,这是没有意义的。

这是解释原因的文档摘录,在 Examining Index Usage 中:

Use real data for experimentation. Using test data for setting up indexes will tell you what indexes you need for the test data, but that is all.

It is especially fatal to use very small test data sets. While selecting 1000 out of 100000 rows could be a candidate for an index, selecting 1 out of 100 rows will hardly be, because the 100 rows probably fit within a single disk page, and there is no plan that can beat sequentially fetching 1 disk page.

关于postgresql - Postgres - Gin 索引不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14547889/

相关文章:

sql-server - Sql Server 多词搜索并对结果进行排名

php - 如何在不更改 php.ini max_execution_time 的情况下避免超过 60 秒的最大执行时间 Laravel

apache - 如何开发一个简单的搜索引擎以在本地文件中进行全文搜索

python - 正则表达式字典 [谷歌类型搜索和正则表达式匹配]

sql - 从 x 年前开始计算运行总和

postgresql - 使用 Postgres 进行 Azure 搜索

full-text-search - Solr查询-有没有办法限制响应中文本字段的大小

ruby-on-rails - 如何在 rails 中测试各种测试用例的 postgres 触发器功能?

ruby-on-rails - 删除一些以前的数据后,如何在 PostgreSQL 中重新启动对表的 id 计数?

postgresql - 使用 PostgreSQL 将 .sql 文件读取到磁盘