Skip to content

Conversation

@kevel-dev
Copy link

No description provided.

),
migrations.AddIndex(
model_name='insuree',
index=models.Index(fields=['legacy_id', 'validity_from', 'validity_to', 'chf_id'], name='tblInsuree_LegacyI_6f5da6_idx'),
Copy link

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.

Copy link
Member

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:

  1. I don't see a necessity to add validity_from in the index column.
  2. Add some columns on leaf level. That will help increase the performance.
  3. Give a proper name like IX_tblName_ColumnName
  4. 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'),
Copy link
Member

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:

  1. I don't see a necessity to add validity_from in the index column.
  2. Add some columns on leaf level. That will help increase the performance.
  3. Give a proper name like IX_tblName_ColumnName
  4. Provide the fill factor (something like 80)

managed = True
db_table = 'tblFamilies'
indexes = [
models.Index(fields=['legacy_id', 'validity_from', 'validity_to'])
Copy link
Member

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'])
]
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants