diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-02 18:07:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-02 18:07:36 +0300 |
commit | e61f798b74e8e18fca7239fd01802182479bfcfc (patch) | |
tree | 4a49b062d8df2ffe3e6e8a07d2aadc034acb9092 /doc/development/sql.md | |
parent | afbfbfc87abfa006f1d369fdf9c740eb1c826808 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/sql.md')
-rw-r--r-- | doc/development/sql.md | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/doc/development/sql.md b/doc/development/sql.md index a98645cfcae..ddca88cb9bb 100644 --- a/doc/development/sql.md +++ b/doc/development/sql.md @@ -70,7 +70,7 @@ WHERE title ILIKE '%Draft:%'; Because the value for `ILIKE` starts with a wildcard the database is not able to use an index as it doesn't know where to start scanning the indexes. -Luckily, PostgreSQL _does_ provide a solution: trigram GIN indexes. These +Luckily, PostgreSQL _does_ provide a solution: trigram Generalized Inverted Index (GIN) indexes. These indexes can be created as follows: ```sql @@ -261,9 +261,9 @@ from `ActiveRecord::Base`. ## Use UNIONs -UNIONs aren't very commonly used in most Rails applications but they're very -powerful and useful. In most applications queries tend to use a lot of JOINs to -get related data or data based on certain criteria, but JOIN performance can +`UNION`s aren't very commonly used in most Rails applications but they're very +powerful and useful. Queries tend to use a lot of `JOIN`s to +get related data or data based on certain criteria, but `JOIN` performance can quickly deteriorate as the data involved grows. For example, if you want to get a list of projects where the name contains a @@ -279,7 +279,7 @@ OR namespaces.name ILIKE '%gitlab%'; ``` Using a large database this query can easily take around 800 milliseconds to -run. Using a UNION we'd write the following instead: +run. Using a `UNION` we'd write the following instead: ```sql SELECT projects.* @@ -301,7 +301,7 @@ This doesn't mean you should start using UNIONs everywhere, but it's something to keep in mind when using lots of JOINs in a query and filtering out records based on the joined data. -GitLab comes with a `Gitlab::SQL::Union` class that can be used to build a UNION +GitLab comes with a `Gitlab::SQL::Union` class that can be used to build a `UNION` of multiple `ActiveRecord::Relation` objects. You can use this class as follows: |