candlepin/candlepin — pull request #177 by bkearney (2013-02-18 19:27:15+00:00)
Title: Improve the performance is checking for guests for a given host.

This patch removes a sub-select from the query in lieu of using joins. Joins tend to be much more performant. This does hardcode the table names which is bad, but the table names existed in the old subselect. This should not be any more fragile.

During the research, it was pointed out that this query should facter in the owner to handle the cases where two owners have guests witht he same UUID. This patch resolves that issue as well by taking in the owner id as part of the query.