【发布时间】:2016-08-25 23:54:16
【问题描述】:
表格是产品:
Table "public.product"
Column | Type |
-----------------+--------------------------+
id | uuid |
attributes | jsonb |
请注意,attributes 是一个 jsonb 字段。目前我有大约 5k 行,我正在像这样查询它:
select id, to_tsvector(attributes::text) @@ to_tsquery('22222') from product;
这个查询已经需要几秒钟才能完成,我想知道我是否可以做些什么来改善这个时间,即索引或改进的查询?
为了启动这个查询返回:
id | found
--------------------------------------+-------
a8230602-ff3f-4414-affc-3594abcfa617 | f
da0c70d5-5108-42ea-941d-123589129feb | f
24ac417a-466c-465c-b346-4fad7a9ad3d8 | f
4bee6122-c5d7-4e0c-840e-e04c28888a9a | f
ce5fe539-bcb2-4cec-9012-b2501df7012e | f
这是不可取的,有没有办法只返回匹配的行?
【问题讨论】:
标签: json postgresql database-design full-text-search full-text-indexing