There are substantial performance differences between the two index types,so it is important to understand their characteristics. A GiST index is lossy,meaning that the index may produce false matches,and it is necessary to check the actual table row to eliminate such false matches. (Postgresql does this automatically when needed.) GiST indexes are lossy because each document is represented in the index by a fixed-length signature. The signature is generated by hashing each word into a single bit in an n-bit string,with all these bits OR-ed together to produce an n-bit document signature. When two words hash to the same bit position there will be a false match. If all words in the query have matches (real or false) then the table row must be retrieved to see if the match is correct. Lossiness causes performance degradation due to unnecessary fetches of table records that turn out to be false matches. Since random access to table records is slow,this limits the usefulness of GiST indexes. The likelihood of false matches depends on several factors,in particular the number of unique words,so using dictionaries to reduce this number is recommended. GIN indexes are not lossy for standard queries,but their performance depends logarithmically on the number of unique words. (However,GIN indexes store only the words (lexemes) of tsvector values,and not their weight labels. Thus a table row recheck is needed when using a query that involves weights.) In choosing which index type to use,GiST or GIN,consider these performance differences: GIN index lookups are about three times faster than GiST GIN indexes take about three times longer to build than GiST GIN indexes are moderately slower to update than GiST indexes,but about 10 times slower if fast-update support was disabled (see Section 54.3.1 for details) GIN indexes are two-to-three times larger than GiST indexes As a rule of thumb,GIN indexes are best for static data because lookups are faster. For dynamic data,GiST indexes are faster to update. Specifically,GiST indexes are very good for dynamic data and fast if the number of unique words (lexemes) is under 100,000,while GIN indexes will handle 100,000+ lexemes better but are slower to update. Note that GIN index build time can often be improved by increasing maintenance_work_mem,while GiST index build time is not sensitive to that parameter参考:http://www.postgresql.org/docs/9.2/static/textsearch-indexes.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。