On 2/18/2016 5:05 AM, Stian Thorgersen wrote:


On 18 February 2016 at 08:43, Marek Posolda <mposolda@redhat.com> wrote:
On 18/02/16 08:07, Stian Thorgersen wrote:
Having two many joins (fetching everything about a realm in one query) is probably going to be bad for performance, especially if there are loads of clients and roles. There can also be large difference between different vendors.
Maybe clients and roles (and groups?) shouldn't be loaded eagerly with realm, but I guess most of the other stuff can be (ie. federation providers, identity providers, SMTP configurations etc). Also for clients we can eagerly load most of the stuff (ie. redirectUris, scopes ). ATM we eagerly preload whole realm in CachedRealm constructor, but we have fetchType.LAZY everywhere. IMO this is not optimal and would mean lot of SQL at startup during realm preload (I did not doublecheck myself).

I don't really think it's a priority and I suspect performance might actually be worse if we do a lot of eager loading than lazy loading. Depends on how Hibernate loads it of course, but if it does it through a crazy join then performance will suffer. 
 

We don't do EAGER SQL loading of clients.  We just load every client/role when a realm is loaded.

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com