Skip to content
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

Duplicate database indexes #18191

Open
acscampos opened this issue Dec 10, 2024 · 0 comments
Open

Duplicate database indexes #18191

acscampos opened this issue Dec 10, 2024 · 0 comments
Labels
status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user

Comments

@acscampos
Copy link

acscampos commented Dec 10, 2024

Proposed Changes

As requested by @jeremystretch in discussion #18188, I am submitting this housekeeping issue to remove duplicate database indexes.

I started using the feature 'Index Tuning' of the Azure PostgreSQL flexible server for the Netbox database. Netbox version is 3.7.1 and PostgreSQL version is 14.13. After 24 hours, it found 6 rcommendations, all of them to drop duplicate indexes:

  • Duplicate of "vpn_tunneltermination_termination". The equivalent index "vpn_tunneltermination_termination" is a unique index, while "vpn_tunnelt_termina_c1f04b_idx" is not.
  • Duplicate of "core_managedfile_unique_root_path". The equivalent index "core_managedfile_unique_root_path" is a unique index, while "core_managedfile_root_path" is not.
  • Duplicate of "core_autosyncrecord_object". The equivalent index "core_autosyncrecord_object" is a unique index, while "core_autosy_object__c17bac_idx" is not.
  • Duplicate of "core_datafile_unique_source_path". The equivalent index "core_datafile_unique_source_path" is a unique index, while "core_datafile_source_path" is not.
  • Duplicate of "vpn_l2vpntermination_assigned_object". The equivalent index "vpn_l2vpntermination_assigned_object" is a unique index, while "vpn_l2vpnte_assigne_9c55f8_idx" is not.
  • Duplicate of "dcim_cabletermination_unique_termination". The equivalent index "dcim_cabletermination_unique_termination" is a unique index, while "dcim_cablet_termina_884752_idx" is not.

Justification

As explained, this is likely because Netbox Team explicitly defines an index for the generic foreign key (GFK) relation termination, which Django does not do automatically. Separately, Netbox Team also declares a uniqueness constraint for this pair of fields, to ensure an object cannot have more than one termination. Hence the duplicate indexes. It should be safe to remove the former index.

@acscampos acscampos added the type: housekeeping Changes to the application which do not directly impact the end user label Dec 10, 2024
@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user
Projects
None yet
Development

No branches or pull requests

2 participants