BlogsGitLabPostgreSQL Trigram Indexes for Search

PostgreSQL Trigram Indexes for Search

PostgreSQL Trigram Indexes for Search

1
posts
2016

GitLab has improved its search performance for PostgreSQL users by implementing trigram indexes. This enhancement allows for faster queries using LIKE conditions, significantly speeding up searches for issues, comments, commits, code, merge requests, and snippets. The implementation involved adapting Rails to support PostgreSQL-specific index types and ensuring compatibility with MySQL.

2016

Fast Search Using PostgreSQL Trigram Text Indexes

3/18/2016

This post details the implementation of PostgreSQL trigram indexes to improve search performance in GitLab. It explains how trigram indexes work by breaking text into 3-letter sequences and how they can be used with LIKE/ILIKE conditions. The post also covers the technical challenges of integrating this feature while maintaining MySQL compatibility, including modifications to `db/schema.rb` and the introduction of `postgresql_opclasses_support.rb` and `mysql_ignore_postgresql_options.rb` initializers. It also notes the switch to ILIKE on PostgreSQL for better performance.