Project

General

Profile

Actions

Bug #12621

closed

Excessive TemplateKind DB queries when retrieving API docs

Added by Dominic Cleal about 9 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
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 1 (0 open1 closed)

Related to Foreman - Feature #11643: Allow through API methods to render templates without configuring a host in build modeClosedShlomi Zadok09/01/2015Actions
Actions #1

Updated by Dominic Cleal about 9 years ago

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

Updated by Tom Caspy almost 9 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

Actions #3

Updated by The Foreman Bot almost 9 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
Actions #4

Updated by Tom Caspy almost 9 years ago

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

Also available in: Atom PDF