Project

General

Profile

Bug #12621

Excessive TemplateKind DB queries when retrieving API docs

Added by Dominic Cleal about 4 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

When viewing uncached API docs (e.g. /apidoc/v2/hosts.html), there are loads of DB queries for TemplateKinds:

2015-11-27T09:50:41 [sql] [D]   TemplateKind Load (0.1ms)  SELECT "template_kinds".* FROM "template_kinds" 
2015-11-27T09:50:41 [sql] [D] TemplateKind Load (0.1ms) SELECT "template_kinds".* FROM "template_kinds"
2015-11-27T09:50:41 [sql] [D] TemplateKind Load (0.1ms) SELECT "template_kinds".* FROM "template_kinds"
2015-11-27T09:50:41 [sql] [D] TemplateKind Load (0.1ms) SELECT "template_kinds".* FROM "template_kinds"
2015-11-27T09:50:41 [sql] [D] TemplateKind Load (0.1ms) SELECT "template_kinds".* FROM "template_kinds"
2015-11-27T09:50:41 [sql] [D] TemplateKind Load (0.1ms) SELECT "template_kinds".* FROM "template_kinds"
2015-11-27T09:50:41 [sql] [D] TemplateKind Load (0.1ms) SELECT "template_kinds".* FROM "template_kinds"
2015-11-27T09:50:41 [sql] [D] TemplateKind Load (0.1ms) SELECT "template_kinds".* FROM "template_kinds"
2015-11-27T09:50:41 [sql] [D] TemplateKind Load (0.1ms) SELECT "template_kinds".* FROM "template_kinds"

This is because of my bad recommendation to query it on the fly in config/initializers/apipie.rb during #11643.

Perhaps to fix it we'll need to remove it again from the lambda but simply fail safely when the table isn't set up?


Related issues

Related to Foreman - Feature #11643: Allow through API methods to render templates without configuring a host in build modeClosed2015-09-01

Associated revisions

Revision 44ad385e (diff)
Added by Tom Caspy almost 4 years ago

fixes #12621 - adding cache for template kinds to prevent multiple queries

History

#1 Updated by Dominic Cleal about 4 years ago

  • Related to Feature #11643: Allow through API methods to render templates without configuring a host in build mode added

#2 Updated by Tom Caspy almost 4 years ago

don't think it's in config/initializers/apipie.rb, the only thing which does a similar thing there is TemplateKind.pluck(:name) which generates a SELECT "template_kinds"."name" FROM "template_kinds" query, not a select * from

will investigate further

#3 Updated by The Foreman Bot almost 4 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Tom Caspy
  • Pull request https://github.com/theforeman/foreman/pull/3138 added

#4 Updated by Tom Caspy almost 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF