Project

General

Profile

Refactor #2003

improve pararmetize classes params retrivial speed

Added by Ohad Levy over 9 years ago. Updated over 9 years ago.

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

Description

Currently, when foreman search for a given parameter value, it would find the smart variable possible order and generate a few queries based on each matcher, for example:

SELECT "lookup_values".* FROM "lookup_values" WHERE "lookup_values"."match" = 'fqdn=host.example.com' AND ("lookup_values".lookup_key_id = 270) LIMIT 1
SELECT "lookup_values".* FROM "lookup_values" WHERE "lookup_values"."match" = 'domain=example.com' AND ("lookup_values".lookup_key_id = 270) LIMIT 1
SELECT "lookup_values".* FROM "lookup_values" WHERE "lookup_values"."match" = 'os=redhat 6.2' AND ("lookup_values".lookup_key_id = 270) LIMIT 1
.
.
.

since this happens for every parameter, this could eventually slow the system down.
an alternative approch would be to query to all possible values in one go, for example


 LookupValue Load (0.2ms)  SELECT "lookup_values".* FROM "lookup_values" WHERE "lookup_values"."match" = 'domain=example.com' AND "lookup_values"."lookup_key_id" IN (376, 270, 377, 275, 261)

Related issues

Related to Foreman - Bug #2011: Param Class optimization fails on PostgesClosed2012-12-05

Associated revisions

Revision 2b9392bb (diff)
Added by Ohad Levy over 9 years ago

SQL improvments for paramaters in host edit section refs #2003

Revision e76ac9ca (diff)
Added by Ohad Levy over 9 years ago

fixes #2003 - Improve Parameterized classes values retrieval time

This patch adds a new classification class which
tries to fetch all values at once

The initial implementation cared about a name / value at a time
however getting all at once (e.g. during a puppet ENC call) is much more
common.

This patch creates in memory tree of all possible values and process
them in memory instead of asking the database for each possible match.

History

#1 Updated by Ohad Levy over 9 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF