Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
什么索引将提高表的数据库性能
CREATE TABLE my_table ( word_set text[] )
对于请求WHERE my_table.word_set @> '<some word>'
WHERE my_table.word_set @> '<some word>'
在 my_table 上使用 GIN (word_set) 创建索引 idx_test;
检查 EXPLAIN ANALYZE 以查看是否使用了索引。当您的表几乎为空或没有足够的唯一数据时关闭 enable_seqscan。拥有索引并不意味着数据库将始终使用该索引:使用索引可能比顺序磁盘扫描慢。这一切都取决于。