jsonb字段上的trigram索引不起作用?

时间:2015-01-23 07:32:31

标签: postgresql postgresql-9.4

我创建了这样的索引(documentData列的类型为jsonb):

CREATE INDEX trgm_idx 
ON "Documents" 
USING gin (cast(("documentData"#>'{text1}') AS text) gin_trgm_ops);

现在我正在执行以下查询:

EXPLAIN ANALYZE 
SELECT "documentData"#>'{text1}' 
FROM "Documents" 
WHERE cast("documentData"#>'{text1}' as text) % 'abc'

我得到以下输出

Seq Scan on "Documents"  (cost=0.00..1.08 rows=1 width=32) (actual time=2.116..2.116 rows=0 loops=1)
  Filter: ((("documentData" #> '{text1}'::text[]))::text % 'abc'::text)
  Rows Removed by Filter: 20
Planning time: 9.645 ms
Execution time: 4.877 ms

为什么查询不使用trigram索引?

0 个答案:

没有答案