Skip to content

Commit

Permalink
Added index on cachevalue (#15199)
Browse files Browse the repository at this point in the history
* added index on cachevalue #14966

* Update netbox/extras/models/search.py

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>

* fixed migration

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
  • Loading branch information
abhi1693 and jeremystretch authored Feb 21, 2024
1 parent a1ee02c commit a3b8262
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.9 on 2024-02-20 17:15

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('extras', '0106_bookmark_user_cascade_deletion'),
]

operations = [
migrations.AddIndex(
model_name='cachedvalue',
index=models.Index(fields=['object_type', 'object_id'], name='extras_cachedvalue_object'),
),
]
3 changes: 3 additions & 0 deletions netbox/extras/models/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class Meta:
ordering = ('weight', 'object_type', 'value', 'object_id')
verbose_name = _('cached value')
verbose_name_plural = _('cached values')
indexes = (
models.Index(fields=('object_type', 'object_id'), name='extras_cachedvalue_object'),
)

def __str__(self):
return f'{self.object_type} {self.object_id}: {self.field}={self.value}'
Expand Down

0 comments on commit a3b8262

Please sign in to comment.