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
7724eed0
Commit
7724eed0
authored
Sep 30, 2020
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Limit postgres_indexes to owned schemas
Relates to
https://gitlab.com/gitlab-org/gitlab/-/issues/254995
parent
8537faa8
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
1 deletion
+61
-1
changelogs/unreleased/ab-reindexing-limit-schema.yml
changelogs/unreleased/ab-reindexing-limit-schema.yml
+5
-0
db/migrate/20200930094812_update_postgres_indexes_view.rb
db/migrate/20200930094812_update_postgres_indexes_view.rb
+54
-0
db/schema_migrations/20200930094812
db/schema_migrations/20200930094812
+1
-0
db/structure.sql
db/structure.sql
+1
-1
No files found.
changelogs/unreleased/ab-reindexing-limit-schema.yml
0 → 100644
View file @
7724eed0
---
title
:
Limit postgres_indexes to owned schemas
merge_request
:
43834
author
:
type
:
other
db/migrate/20200930094812_update_postgres_indexes_view.rb
0 → 100644
View file @
7724eed0
# frozen_string_literal: true
class
UpdatePostgresIndexesView
<
ActiveRecord
::
Migration
[
6.0
]
DOWNTIME
=
false
def
up
execute
(
<<~
SQL
)
CREATE OR REPLACE VIEW postgres_indexes AS
SELECT
pg_namespace.nspname || '.' || pg_class.relname as identifier,
pg_index.indexrelid,
pg_namespace.nspname as schema,
pg_class.relname as name,
pg_index.indisunique as unique,
pg_index.indisvalid as valid_index,
pg_class.relispartition as partitioned,
pg_index.indisexclusion as exclusion,
pg_indexes.indexdef as definition,
pg_relation_size(pg_class.oid) as ondisk_size_bytes
FROM pg_index
INNER JOIN pg_class ON pg_class.oid = pg_index.indexrelid
INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid
INNER JOIN pg_indexes ON pg_class.relname = pg_indexes.indexname
WHERE pg_namespace.nspname <> 'pg_catalog'
AND pg_namespace.nspname IN (
current_schema(),
'gitlab_partitions_dynamic',
'gitlab_partitions_static'
)
SQL
end
def
down
execute
(
<<~
SQL
)
CREATE OR REPLACE VIEW postgres_indexes AS
SELECT
pg_namespace.nspname || '.' || pg_class.relname as identifier,
pg_index.indexrelid,
pg_namespace.nspname as schema,
pg_class.relname as name,
pg_index.indisunique as unique,
pg_index.indisvalid as valid_index,
pg_class.relispartition as partitioned,
pg_index.indisexclusion as exclusion,
pg_indexes.indexdef as definition,
pg_relation_size(pg_class.oid) as ondisk_size_bytes
FROM pg_index
INNER JOIN pg_class ON pg_class.oid = pg_index.indexrelid
INNER JOIN pg_namespace ON pg_class.relnamespace = pg_namespace.oid
INNER JOIN pg_indexes ON pg_class.relname = pg_indexes.indexname
WHERE pg_namespace.nspname <> 'pg_catalog'
SQL
end
end
db/schema_migrations/20200930094812
0 → 100644
View file @
7724eed0
b92b48a17bfd350a70017bfee99bcfb3dbc5ae9e33c8f23ab593666e5c3900aa
\ No newline at end of file
db/structure.sql
View file @
7724eed0
...
...
@@ -14428,7 +14428,7 @@ CREATE VIEW postgres_indexes AS
JOIN
pg_class
ON
((
pg_class
.
oid
=
pg_index
.
indexrelid
)))
JOIN
pg_namespace
ON
((
pg_class
.
relnamespace
=
pg_namespace
.
oid
)))
JOIN
pg_indexes
ON
((
pg_class
.
relname
=
pg_indexes
.
indexname
)))
WHERE
(
pg_namespace
.
nspname
<>
'pg_catalog'
::
name
);
WHERE
(
(
pg_namespace
.
nspname
<>
'pg_catalog'
::
name
)
AND
(
pg_namespace
.
nspname
=
ANY
(
ARRAY
[
"current_schema"
(),
'gitlab_partitions_dynamic'
::
name
,
'gitlab_partitions_static'
::
name
]))
);
CREATE
TABLE
postgres_reindex_actions
(
id
bigint
NOT
NULL
,
...
...
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