-
Notifications
You must be signed in to change notification settings - Fork 18
OP-1802 Add index on familly and insuree fields to improve database performance #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
| ), | ||
| migrations.AddIndex( | ||
| model_name='insuree', | ||
| index=models.Index(fields=['legacy_id', 'validity_from', 'validity_to', 'chf_id'], name='tblInsuree_LegacyI_6f5da6_idx'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multicolumn indexes should be used sparingly. In most situations, an index on a single column is sufficient and saves space and time. Indexes with more than three columns are unlikely to be helpful unless the usage of the table is extremely stylized.
From PSQL docs: https://www.postgresql.org/docs/current/indexes-multicolumn.html
I know that not every implementation uses psql, but that code will work for everyone so it is worth considering if that many indexes are needed or wanted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments from me:
- I don't see a necessity to add validity_from in the index column.
- Add some columns on leaf level. That will help increase the performance.
- Give a proper name like IX_tblName_ColumnName
- Provide the fill factor (something like 80)
| ), | ||
| migrations.AddIndex( | ||
| model_name='insuree', | ||
| index=models.Index(fields=['legacy_id', 'validity_from', 'validity_to', 'chf_id'], name='tblInsuree_LegacyI_6f5da6_idx'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments from me:
- I don't see a necessity to add validity_from in the index column.
- Add some columns on leaf level. That will help increase the performance.
- Give a proper name like IX_tblName_ColumnName
- Provide the fill factor (something like 80)
| managed = True | ||
| db_table = 'tblFamilies' | ||
| indexes = [ | ||
| models.Index(fields=['legacy_id', 'validity_from', 'validity_to']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer my previous comment
| db_table = 'tblInsuree' | ||
| indexes = [ | ||
| models.Index(fields=['legacy_id', 'validity_from', 'validity_to', 'chf_id']) | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer to my previous comment
No description provided.