Skip to main content
Ctrl+K

документация Tantor Special Edition 15.12

Оглавление:

  • Preface
    • 1.  What Is Tantor SE?
    • 2. A Brief History of PostgreSQL
    • 3. What are the differences between Tantor SE 15 and PostgreSQL 15
    • 4. Conventions
    • 5. Bug Reporting Guidelines
  • Часть I. Tutorial
    • Глава 1. Synopsis
    • Глава 2. The SQL Language
    • Глава 3. Advanced Features
  • Часть II. The SQL Language
    • Глава 4. SQL Syntax
    • Глава 5. Data Definition
    • Глава 6. Data Manipulation
    • Глава 7. Queries
    • Глава 8. Data Types
    • Глава 9. Functions and Operators
    • Глава 10. Type Conversion
    • Глава 11. Indexes
    • Глава 12. Full Text Search
    • Глава 13. Concurrency Control
    • Глава 14. Performance Tips
    • Глава 15. Parallel Query
    • Глава 16. Autonomous Transactions
  • Часть III. Server Administration
    • Глава 17. Installation from Binaries
    • Глава 18. Server Setup and Operation
    • Глава 19. Server Configuration
    • Глава 20. Client Authentication
    • Глава 21. Database Roles
    • Глава 22. Managing Databases
    • Глава 23. Localization
    • Глава 24. Routine Database Maintenance Tasks
    • Глава 25. Backup and Restore
    • Глава 26. High Availability, Load Balancing, and Replication
    • Глава 27. Monitoring Database Activity
    • Глава 28. Monitoring Disk Usage
    • Глава 29. Reliability and the Write-Ahead Log
    • Глава 30. Logical Replication
    • Глава 31. Just-in-Time Compilation (JIT)
  • Часть IV. Client Interfaces
    • Глава 32. libpq — C Library
    • Глава 33. Large Objects
    • Глава 34. ECPG — Embedded SQL in C
    • Глава 35. The Information Schema
  • Часть V. Server Programming
    • Глава 36. Extending SQL
    • Глава 37. Triggers
    • Глава 38. Event Triggers
    • Глава 39. The Rule System
    • Глава 40. Procedural Languages
    • Глава 41. PL/pgSQL — SQL Procedural Language
    • Глава 42. PL/Tcl — Tcl Procedural Language
    • Глава 43. PL/Perl — Perl Procedural Language
    • Глава 44. PL/Python — Python Procedural Language
    • Глава 45. Server Programming Interface
    • Глава 46. Background Worker Processes
    • Глава 47. Logical Decoding
    • Глава 48. Replication Progress Tracking
    • Глава 49. Archive Modules
  • Часть VI. Reference
    • SQL Commands
    • PostgreSQL Client Applications
    • PostgreSQL Server Applications
  • Часть VII. Internals
    • Глава 50. Overview of PostgreSQL Internals
    • Глава 51. System Catalogs
    • Глава 52. System Views
    • Глава 53. Frontend/Backend Protocol
    • Глава 54. PostgreSQL Coding Conventions
    • Глава 55. Native Language Support
    • Глава 56. Writing a Procedural Language Handler
    • Глава 57. Writing a Foreign Data Wrapper
    • Глава 58. Writing a Table Sampling Method
    • Глава 59. Writing a Custom Scan Provider
    • Глава 60. Genetic Query Optimizer
    • Глава 61. Table Access Method Interface Definition
    • Глава 62. Index Access Method Interface Definition
    • Глава 63. Generic WAL Records
    • Глава 64. Custom WAL Resource Managers
    • Глава 65. B-Tree Indexes
    • Глава 66. GiST Indexes
    • Глава 67. SP-GiST Indexes
    • Глава 68. GIN Indexes
    • Глава 69. BRIN Indexes
    • Глава 70. Hash Indexes
    • Глава 71. Database Physical Storage
    • Глава 72. System Catalog Declarations and Initial Contents
    • Глава 73. How the Planner Uses Statistics
    • Глава 74. Backup Manifest Format
  • Часть VIII. Appendixes
    • Предметный указатель A. Tantor SE Error Codes
    • Предметный указатель B. Date/Time Support
    • Предметный указатель C. SQL Key Words
    • Предметный указатель D. SQL Conformance
    • Предметный указатель E. Release Notes
    • Предметный указатель F. Additional Supplied Modules
    • Предметный указатель G. Additional Supplied Programs
    • Предметный указатель H. Additional External Modules
    • Предметный указатель I. External Projects
    • Предметный указатель J. Tantor SE Limits
    • Предметный указатель K. Acronyms
    • Предметный указатель L. Glossary
    • Предметный указатель M. Color Support
    • Предметный указатель N. Obsolete or Renamed Features
  • Bibliography
  • Предметный указатель

12.9. Preferred Index Types for Text Search

12.9. Preferred Index Types for Text Search#

12.9. Preferred Index Types for Text Search
12.9. Preferred Index Types for Text Search
Назад НаверхГлава 12. Full Text SearchНачало Далее

12.9. Preferred Index Types for Text Search

There are two kinds of indexes that can be used to speed up full text searches: GIN and GiST. Note that indexes are not mandatory for full text searching, but in cases where a column is searched on a regular basis, an index is usually desirable.

To create such an index, do one of:

CREATE INDEX name ON table USING GIN (column);

Creates a GIN (Generalized Inverted Index)-based index. The column must be of tsvector type.

CREATE INDEX name ON table USING GIST (column [ { DEFAULT | tsvector_ops } (siglen = number) ] );

Creates a GiST (Generalized Search Tree)-based index. The column can be of tsvector or tsquery type. Optional integer parameter siglen determines signature length in bytes (see below for details).

GIN indexes are the preferred text search index type. As inverted indexes, they contain an index entry for each word (lexeme), with a compressed list of matching locations. Multi-word searches can find the first match, then use the index to remove rows that are lacking additional words. 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.

A GiST index is lossy, meaning that the index might produce false matches, and it is necessary to check the actual table row to eliminate such false matches. (Tantor SE does this automatically when needed.) GiST indexes are lossy because each document is represented in the index by a fixed-length signature. The signature length in bytes is determined by the value of the optional integer parameter siglen. The default signature length (when siglen is not specified) is 124 bytes, the maximum signature length is 2024 bytes. 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. Longer signatures lead to a more precise search (scanning a smaller fraction of the index and fewer heap pages), at the cost of a larger index.

A GiST index can be covering, i.e., use the INCLUDE clause. Included columns can have data types without any GiST operator class. Included attributes will be stored uncompressed.

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.

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.

Partitioning of big collections and the proper use of GIN and GiST indexes allows the implementation of very fast searches with online update. Partitioning can be done at the database level using table inheritance, or by distributing documents over servers and collecting external search results, e.g., via Foreign Data access. The latter is possible because ranking functions use only local information.


Назад Наверх Далее
12.8. Testing and Debugging Text Search Начало 12.10. psql Support
Коммерческое использование возможно только с письменного разрешения компании ОOO “Лаборатории Тантор”
© ООО "Лаборатории Тантор"
  • Положение о технической поддержке
  • Политика обработки файлов сookie
  • Пользовательское соглашение сайта
Продукты
  • СУБД Tantor
  • Платформа Tantor
  • Документация
Контакты
  • +7 495 369-48-16
  • info@tantorlabs.ru
15.12.0 - 77d56436 - 2025-07-18 14:56:16