Fetch all filter values with AJAX in list views #2251

Closed
opened 2025-12-29 17:24:08 +01:00 by adam · 6 comments
Owner

Originally created by @aruhier on GitHub (Dec 28, 2018).

Environment

  • Python version: 3.7
  • NetBox version: 2.5.2

Proposed Functionality

In views like /dcim/devices/ or /dcim/racks/, that include a search bar with filters, values inside each filters could be fetched asynchronously with AJAX, instead of waiting for the server to fill them before rendering the page.

Use Case

If in one of these filters, there is a lot of objects (multiple thousands), currently the page takes time to render, as it is single threaded and heavy on CPU (in the python code, not necessarily in database if you disable the natural ordering sort).

The most important when listing some objects in a view is the table of objects, there is no really need to wait for the filters to be rendered. These filters could be fetched in AJAX, and marked as disabled as long as the query is not over.

The page would be a lot quicker to render. For me, with 150K devices and 4K racks, by doing that for the devices view, django-debug-toolbar indicates a reduction from 3s CPU time to 800ms.
Also, it would allow to multithread each filter, and would work even better if the user has a cluster of Netbox servers.

Database Changes

None

External Dependencies

None

Originally created by @aruhier on GitHub (Dec 28, 2018). ### Environment * Python version: 3.7 * NetBox version: 2.5.2 ### Proposed Functionality In views like `/dcim/devices/` or `/dcim/racks/`, that include a search bar with filters, values inside each filters could be fetched asynchronously with AJAX, instead of waiting for the server to fill them before rendering the page. ### Use Case If in one of these filters, there is a lot of objects (multiple thousands), currently the page takes time to render, as it is single threaded and heavy on CPU (in the python code, not necessarily in database if you disable the natural ordering sort). The most important when listing some objects in a view is the table of objects, there is no really need to wait for the filters to be rendered. These filters could be fetched in AJAX, and marked as disabled as long as the query is not over. The page would be a lot quicker to render. For me, with 150K devices and 4K racks, by doing that for the devices view, django-debug-toolbar indicates a reduction from 3s CPU time to 800ms. Also, it would allow to multithread each filter, and would work even better if the user has a cluster of Netbox servers. ### Database Changes None ### External Dependencies None
adam added the status: acceptedtype: feature labels 2025-12-29 17:24:08 +01:00
adam closed this issue 2025-12-29 17:24:08 +01:00
Author
Owner

@DanSheps commented on GitHub (Dec 30, 2018):

I imagine this will come when there is front-end rewrite done, like v3 or something.

@DanSheps commented on GitHub (Dec 30, 2018): I imagine this will come when there is front-end rewrite done, like v3 or something.
Author
Owner

@aruhier commented on GitHub (Dec 30, 2018):

I already started to work on this, if someone is interested.

@aruhier commented on GitHub (Dec 30, 2018): I already started to work on this, if someone is interested.
Author
Owner

@lampwins commented on GitHub (Dec 31, 2018):

If this were to be done, it would be rolled into the select2 UI changes which are under active development in the select2-ui branch.

@lampwins commented on GitHub (Dec 31, 2018): If this were to be done, it would be rolled into the select2 UI changes which are under active development in the select2-ui branch.
Author
Owner

@lampwins commented on GitHub (Jan 9, 2019):

This has been wrapped into #2753 and is currently implemented for the DCIM app in the select2-ui branch.

@lampwins commented on GitHub (Jan 9, 2019): This has been wrapped into #2753 and is currently implemented for the DCIM app in the `select2-ui` branch.
Author
Owner

@lampwins commented on GitHub (Jan 16, 2019):

Implemented in develop

@lampwins commented on GitHub (Jan 16, 2019): Implemented in `develop`
Author
Owner

@aruhier commented on GitHub (Jan 16, 2019):

Great, thanks a lot!

Sorry, I finally didn't have time to deal with that.

@aruhier commented on GitHub (Jan 16, 2019): Great, thanks a lot! Sorry, I finally didn't have time to deal with that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2251