-
Problem report
-
Resolution: Unresolved
-
Trivial
-
None
-
6.0.31
-
None
Steps to reproduce:
- Create some some hosts with thousands of items or even one host with something like 50000 items. Each of the items should have several tags
- Run a query for just that host in the Latest data page
- Notice how long it takes to complete
In app/controllers/CControllerLatest.php the first query for items should include a 'limit' option that is set with $search_limit. If the $select_items_cnt has not exceeded $search_limit, then the query queries for all that hosts' items, which is unecessary since it is never returned to the user's browser anyway.
In the for-loop, we should set this on each pass of the foreach loop:
$limit = $search_limit - $select_items_cnt;
And then in the API::Item()->get we should add this after 'preservekeys' => true
'limit' => $limit
In my environment, with a host having 40000 items, the original query took 4.2 minutes. This is on SSD, bare metal Dell R640. When I add the code modifications above, the query takes 3.6 seconds. My GUI search limit is set to 5000, so this is still very good performance (3.6 seconds). This is a problem because the Home tab in Latest data typically has no filters set, so if the first host it gets has thousands of items the GUI experience will be very bad for the users.