Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
ef870db3
Verified
Commit
ef870db3
authored
1 year ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Declare the dependency between element type and corpus IDs in PostgreSQL stats
parent
70bbfa19
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1998
Declare the dependency between element type and corpus IDs in PostgreSQL stats
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/documents/migrations/0066_element_type_implies_corpus.py
+31
-0
31 additions, 0 deletions
.../documents/migrations/0066_element_type_implies_corpus.py
with
31 additions
and
0 deletions
arkindex/documents/migrations/0066_element_type_implies_corpus.py
0 → 100644
+
31
−
0
View file @
ef870db3
# Generated by Django 4.1.7 on 2023-05-23 12:42
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
documents
'
,
'
0065_elementpath_constraints
'
),
]
operations
=
[
# This gives a hint to PostgreSQL's query planner that the element's corpus can be deduced from the type.
# If you filter by a specific type ID, then the corpus ID will be constant;
# all elements of the same type ID should be in the same corpus.
#
# This causes the query planner to create significantly better query plans when filtering by both corpus and type ID,
# as it understands that filtering on both type and corpus is the same as only filtering on the type,
# and the corpus filter will not reduce the planner's estimated row counts.
#
# On freshly created databases, this applies immediately. On existing databases, this will only have an effect after
# an autovacuum completes or after an administrator runs `ANALYZE documents_element`.
#
# See https://gitlab.com/teklia/arkindex/backend/-/issues/1309#note_1401556847 for context.
migrations
.
RunSQL
(
"
CREATE STATISTICS element_type_implies_corpus (dependencies) ON type_id, corpus_id FROM documents_element
"
,
"
DROP STATISTICS element_type_implies_corpus
"
,
elidable
=
False
,
),
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment