Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
627696c4
Commit
627696c4
authored
Jan 11, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the fastest available method for various Geo status counts
parent
4180b3de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
24 deletions
+47
-24
changelogs/unreleased-ee/4491-geo-fdw-optimise-queries.yml
changelogs/unreleased-ee/4491-geo-fdw-optimise-queries.yml
+5
-0
ee/app/finders/geo/attachment_registry_finder.rb
ee/app/finders/geo/attachment_registry_finder.rb
+20
-18
ee/app/finders/geo/project_registry_finder.rb
ee/app/finders/geo/project_registry_finder.rb
+14
-6
ee/app/finders/geo/registry_finder.rb
ee/app/finders/geo/registry_finder.rb
+8
-0
No files found.
changelogs/unreleased-ee/4491-geo-fdw-optimise-queries.yml
0 → 100644
View file @
627696c4
---
title
:
Use the fastest available method for various Geo status counts
merge_request
:
4024
author
:
type
:
fixed
ee/app/finders/geo/attachment_registry_finder.rb
View file @
627696c4
...
...
@@ -13,33 +13,35 @@ module Geo
end
def
count_synced_attachments
find_synced_attachments
.
count
if
aggregate_pushdown_supported?
find_synced_attachments
.
count
else
legacy_find_synced_attachments
.
count
end
end
def
count_failed_attachments
find_failed_attachments
.
count
if
aggregate_pushdown_supported?
find_failed_attachments
.
count
else
legacy_find_failed_attachments
.
count
end
end
def
find_synced_attachments
relation
=
if
use_legacy_queries?
legacy_find_synced_attachments
else
fdw_find_synced_attachments
end
relation
if
use_legacy_queries?
legacy_find_synced_attachments
else
fdw_find_synced_attachments
end
end
def
find_failed_attachments
relation
=
if
use_legacy_queries?
legacy_find_failed_attachments
else
fdw_find_failed_attachments
end
relation
if
use_legacy_queries?
legacy_find_failed_attachments
else
fdw_find_failed_attachments
end
end
# Find limited amount of non replicated attachments.
...
...
ee/app/finders/geo/project_registry_finder.rb
View file @
627696c4
...
...
@@ -102,13 +102,21 @@ module Geo
.
where
(
project_registry:
{
project_id:
nil
})
end
# @return [ActiveRecord::Relation<Geo::
Fdw::Project
>]
# @return [ActiveRecord::Relation<Geo::
ProjectRegistry
>]
def
fdw_find_enabled_wikis
feature_fdw_table
=
Geo
::
Fdw
::
ProjectFeature
.
table_name
Geo
::
ProjectRegistry
.
synced_wikis
.
joins
(
"INNER JOIN
#{
feature_fdw_table
}
ON
#{
feature_fdw_table
}
.project_id = project_registry.project_id"
)
.
where
(
"
#{
feature_fdw_table
}
.wiki_access_level > ?"
,
::
ProjectFeature
::
DISABLED
)
project_id_matcher
=
Geo
::
Fdw
::
ProjectFeature
.
arel_table
[
:project_id
]
.
eq
(
Geo
::
ProjectRegistry
.
arel_table
[
:project_id
])
# Only read the IDs of projects with disabled wikis from the remote database
not_exist
=
Geo
::
Fdw
::
ProjectFeature
.
where
(
wiki_access_level:
[
::
ProjectFeature
::
DISABLED
,
nil
])
.
where
(
project_id_matcher
)
.
select
(
'1'
)
.
exists
.
not
Geo
::
ProjectRegistry
.
synced_wikis
.
where
(
not_exist
)
end
# @return [ActiveRecord::Relation<Geo::Fdw::Project>]
...
...
ee/app/finders/geo/registry_finder.rb
View file @
627696c4
...
...
@@ -10,6 +10,14 @@ module Geo
protected
# When this feature isn't present, FDW queries pull every row from the
# remote database and perform aggregates locally, leading to surprisingly
# slow COUNT queries on large tables. For more details, see this link:
# https://www.enterprisedb.com/blog/postgresql-aggregate-push-down-postgresfdw
def
aggregate_pushdown_supported?
Gitlab
::
Geo
.
fdw?
&&
Gitlab
::
Database
.
version
.
to_f
>=
10.0
end
def
use_legacy_queries?
# Selective project replication adds a wrinkle to FDW
# queries, so we fallback to the legacy version for now.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment