Project

General

Profile

Feature #186

UI Slows down when reports are not purged form DB.

Added by Telmo X about 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Database
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

If you don't purged the reports from your database the lookup queries for the last report of a hosts start slowing down due to the way ActiveRecord queries for it:
Host.reports.last will generate the following SQL statement:

Report Load (1611.5ms) SELECT * FROM `reports` WHERE (`reports`.host_id = 19) ORDER BY reports.id DESC LIMIT 1

By changing that query to Host.find(host.id).reports.maximum('id')) we make a more efficient query improving the response.

Report Load (3.2ms) SELECT * FROM `reports` WHERE (`reports`.`id` = 85955)

Patch attached

0001-report-lookup-change.patch 0001-report-lookup-change.patch 3.99 KB change Host.reports.last to Host.find(host.id).reports.maximun('id') Telmo X, 03/22/2010 04:17 PM

Associated revisions

Revision bc4f0284 (diff)
Added by Telmo X about 9 years ago

fixes #186 - When reports are kept in the database and not deleted/purged the Host.reports.last query starts slowing down and the hosts index page can take minutes to load depending on the number of hosts. By changing Host.reports.last to Host.find(host.id).reports.maximum('id') we make a more efficient query to the database cutting the lookup time.

Revision 69cbb0f5 (diff)
Added by Ohad Levy about 9 years ago

refs #186 - minor optimization and avoid a problem when there is no
report in the DB while the host last report date exists

History

#1 Updated by Telmo X about 9 years ago

  • Status changed from New to Ready For Testing

#2 Updated by Ohad Levy about 9 years ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF