Bug 1032192 - Improve query performance for alert cache refresh; using n + 1 selects

Elias Ross genman at noderunner.net
Fri May 9 21:42:29 UTC 2014


As it turns out, the queries used by the alert manager do not return
the AlertCondition object, so for large caches, there are N+1 queries
to the databases. This is not a problem in small cases, but in some
there's 1000+ queries made. This is especially slow with a remote
database.

Which led me to post this question:

http://stackoverflow.com/questions/23506988/jpql-constructor-expressions-how-to-eagerly-fetch-the-main-entity-in-select-ne

The obvious solution is to select every column individually, then
create an AlertCondition by hand. The problem with this is it means
changing lots of queries, class constructors and the like.

Is this something worth undertaking? If somebody can think of a better
way, let me know.


More information about the rhq-devel mailing list