Bug #17143
openPerformance degradation in "non-targeted" search through WebUI or API
Description
After upgrading to 1.13.1, I immediately noticed the huge delays in search through the hosts in both WebUI and API (the latter is actually worse than WebUI). Here are few examples:
- time curl -kSs -u admin:$PASS https://localhost/api/hosts | jq '.' | grep total
"total": 1695,
"subtotal": 1695,
real 0m0.816s
user 0m0.040s
sys 0m0.076s
But the search through my 1695 hosts on this instances takes 2.5 minutes (!):
- time curl -kSs -u admin:$PASS https://localhost/api/hosts?search=test | jq '.' | grep total
"total": 1695,
"subtotal": 1,
real 2m25.147s
user 0m0.053s
sys 0m0.063s
Corresponding logs (WebUI search):
2016-10-28 18:39:29 a607439e [app] [I] Parameters: {"utf8"=>"✓", "search"=>"test"}
2016-10-28 18:40:16 a607439e [app] [I] Rendered hosts/_list.html.erb (10.1ms)
2016-10-28 18:40:16 a607439e [app] [I] Rendered hosts/index.html.erb within layouts/application (18.0ms)
2016-10-28 18:40:17 a607439e [app] [I] Rendered common/_searchbar.html.erb (11.6ms)
2016-10-28 18:40:17 a607439e [app] [I] Rendered layouts/_application_content.html.erb (12.2ms)
2016-10-28 18:40:17 a607439e [app] [I] Rendered home/_user_dropdown.html.erb (1.9ms)
2016-10-28 18:40:17 a607439e [app] [I] Read fragment views/tabs_and_title_records-6 (1.1ms)
2016-10-28 18:40:17 a607439e [app] [I] Rendered home/_topbar.html.erb (43.9ms)
2016-10-28 18:40:17 a607439e [app] [I] Rendered layouts/base.html.erb (45.5ms)
2016-10-28 18:40:17 a607439e [app] [I] Completed 200 OK in 47691ms (Views: 73.3ms | ActiveRecord: 47585.0ms)
API:
2016-10-29 13:44:51 8a9d5e4a [app] [I] Started GET "/api/hosts?search=test" for 127.0.0.1 at 2016-10-29 13:44:51 -0700
2016-10-29 13:44:51 8a9d5e4a [app] [I] Processing by Api::V2::HostsController#index as JSON
2016-10-29 13:44:51 8a9d5e4a [app] [I] Parameters: {"search"=>"test", "apiv"=>"v2"}
2016-10-29 13:44:51 8a9d5e4a [app] [I] Authorized user admin(Admin User)
2016-10-29 13:46:10 8a9d5e4a [app] [I] Rendered api/v2/hosts/index.json.rabl within api/v2/layouts/index_layout (58.6ms)
2016-10-29 13:47:28 8a9d5e4a [app] [I] Completed 200 OK in 156710ms (Views: 62.3ms | ActiveRecord: 156519.5ms)
This was not the case in previous versions. "targeted" search (search=name~something) still works perfectly fine.
Is this an intended change in behavior?