mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-13 02:58:17 -06:00
Add NATURAL_ORDERING opt to disable natsort
With a lot of objects, the sort query took more than 2s to complete, each time they were listed. Making the concession to disable natural ordering sort reduces this time to 0.1s, making the listing views and homepage snappier in our case.
This commit is contained in:
parent
d144d3a584
commit
210ddde630
@ -207,6 +207,15 @@ The amount of time (in seconds) to wait for NAPALM to connect to a device.
|
||||
|
||||
---
|
||||
|
||||
## NATURAL_ORDERING
|
||||
|
||||
Default: True
|
||||
|
||||
Enable or disable the natural sort order when listing objects (see the Wikipedia page for [Natural sort order](https://en.wikipedia.org/wiki/Natural_sort_order)).
|
||||
However, it is less efficient than the default sort, leading up to a high CPU consumption in database when sorting a lot of objects (a few thousands).
|
||||
|
||||
---
|
||||
|
||||
## PAGINATE_COUNT
|
||||
|
||||
Default: 50
|
||||
|
@ -296,7 +296,8 @@ class Site(ChangeLoggedModel, CustomFieldModel):
|
||||
to='extras.ImageAttachment'
|
||||
)
|
||||
|
||||
objects = NaturalOrderingManager()
|
||||
if settings.NATURAL_ORDERING:
|
||||
objects = NaturalOrderingManager()
|
||||
tags = TaggableManager()
|
||||
|
||||
csv_headers = [
|
||||
@ -543,7 +544,8 @@ class Rack(ChangeLoggedModel, CustomFieldModel):
|
||||
to='extras.ImageAttachment'
|
||||
)
|
||||
|
||||
objects = NaturalOrderingManager()
|
||||
if settings.NATURAL_ORDERING:
|
||||
objects = NaturalOrderingManager()
|
||||
tags = TaggableManager()
|
||||
|
||||
csv_headers = [
|
||||
@ -1432,7 +1434,8 @@ class Device(ChangeLoggedModel, ConfigContextModel, CustomFieldModel):
|
||||
to='extras.ImageAttachment'
|
||||
)
|
||||
|
||||
objects = NaturalOrderingManager()
|
||||
if settings.NATURAL_ORDERING:
|
||||
objects = NaturalOrderingManager()
|
||||
tags = TaggableManager()
|
||||
|
||||
csv_headers = [
|
||||
|
@ -118,6 +118,11 @@ NAPALM_TIMEOUT = 30
|
||||
# be provided as a dictionary.
|
||||
NAPALM_ARGS = {}
|
||||
|
||||
# Enable or disable the natural sort order when listing objects (see https://en.wikipedia.org/wiki/Natural_sort_order
|
||||
# for details). However, it is less efficient than the default sort, leading up to a high CPU consumption in database
|
||||
# when sorting a lot of objects (a few thousands).
|
||||
NATURAL_ORDERING = True
|
||||
|
||||
# Determine how many objects to display per page within a list. (Default: 50)
|
||||
PAGINATE_COUNT = 50
|
||||
|
||||
|
@ -63,6 +63,7 @@ NAPALM_USERNAME = getattr(configuration, 'NAPALM_USERNAME', '')
|
||||
NAPALM_PASSWORD = getattr(configuration, 'NAPALM_PASSWORD', '')
|
||||
NAPALM_TIMEOUT = getattr(configuration, 'NAPALM_TIMEOUT', 30)
|
||||
NAPALM_ARGS = getattr(configuration, 'NAPALM_ARGS', {})
|
||||
NATURAL_ORDERING = getattr(configuration, 'NATURAL_ORDERING', True)
|
||||
PAGINATE_COUNT = getattr(configuration, 'PAGINATE_COUNT', 50)
|
||||
PREFER_IPV4 = getattr(configuration, 'PREFER_IPV4', False)
|
||||
REPORTS_ROOT = getattr(configuration, 'REPORTS_ROOT', os.path.join(BASE_DIR, 'reports')).rstrip('/')
|
||||
|
Loading…
Reference in New Issue
Block a user