Skip relationship query when we know there are none
Skip relationship query when we know there are none

A majority of the time, parent_rel_ids is an array. So it is easy enough
to get the size.
If parent_rel_ids is an empty array, then essentially we're running
Relationship.where(:id => [])

Which will return no records. Rails agrees as it produces
a query with "WHERE 1=0"

This skips these queries. The savings is variable.
One customer's database returned no savings, the other went from
81 queries to 67 (17%)

Tests were in place for parents and no parents

tinaafitz/manageiq,israel-hdez/manageiq,aufi/manageiq,jntullo/manageiq,mresti/manageiq,d-m-u/manageiq,jameswnl/manageiq,jvlcek/manageiq,kbrock/manageiq,mkanoor/manageiq,syncrou/manageiq,mzazrivec/manageiq,romanblanco/manageiq,fbladilo/manageiq,chessbyte/manageiq,tzumainn/manageiq,skateman/manageiq,lpichler/manageiq,mzazrivec/manageiq,jvlcek/manageiq,josejulio/manageiq,ilackarms/manageiq,andyvesel/manageiq,billfitzgerald0120/manageiq,andyvesel/manageiq,hstastna/manageiq,josejulio/manageiq,branic/manageiq,NaNi-Z/manageiq,hstastna/manageiq,fbladilo/manageiq,syncrou/manageiq,josejulio/manageiq,jrafanie/manageiq,agrare/manageiq,ailisp/manageiq,gerikis/manageiq,chessbyte/manageiq,jntullo/manageiq,hstastna/manageiq,borod108/manageiq,djberg96/manageiq,israel-hdez/manageiq,borod108/manageiq,gmcculloug/manageiq,skateman/manageiq,jrafanie/manageiq,yaacov/manageiq,juliancheal/manageiq,gerikis/manageiq,matobet/manageiq,mfeifer/manageiq,tzumainn/manageiq,pkomanek/manageiq,matobet/manageiq,gmcculloug/manageiq,skateman/manageiq,chessbyte/manageiq,mkanoor/manageiq,josejulio/manageiq,aufi/manageiq,tinaafitz/manageiq,romanblanco/manageiq,djberg96/manageiq,skateman/manageiq,yaacov/manageiq,NickLaMuro/manageiq,matobet/manageiq,jvlcek/manageiq,pkomanek/manageiq,kbrock/manageiq,chessbyte/manageiq,matobet/manageiq,durandom/manageiq,jameswnl/manageiq,ailisp/manageiq,syncrou/manageiq,d-m-u/manageiq,gerikis/manageiq,aufi/manageiq,juliancheal/manageiq,durandom/manageiq,mfeifer/manageiq,agrare/manageiq,NaNi-Z/manageiq,juliancheal/manageiq,mzazrivec/manageiq,mkanoor/manageiq,lpichler/manageiq,andyvesel/manageiq,ManageIQ/manageiq,aufi/manageiq,NaNi-Z/manageiq,tzumainn/manageiq,ailisp/manageiq,mzazrivec/manageiq,yaacov/manageiq,romanblanco/manageiq,tinaafitz/manageiq,pkomanek/manageiq,jntullo/manageiq,mresti/manageiq,tzumainn/manageiq,syncrou/manageiq,israel-hdez/manageiq,tinaafitz/manageiq,djberg96/manageiq,jntullo/manageiq,hstastna/manageiq,jameswnl/manageiq,pkomanek/manageiq,mresti/manageiq,agrare/manageiq,juliancheal/manageiq,ailisp/manageiq,ilackarms/manageiq,ManageIQ/manageiq,kbrock/manageiq,ManageIQ/manageiq,d-m-u/manageiq,mresti/manageiq,djberg96/manageiq,jameswnl/manageiq,israel-hdez/manageiq,jrafanie/manageiq,borod108/manageiq,billfitzgerald0120/manageiq,lpichler/manageiq,branic/manageiq,lpichler/manageiq,NickLaMuro/manageiq,branic/manageiq,billfitzgerald0120/manageiq,jvlcek/manageiq,yaacov/manageiq,andyvesel/manageiq,branic/manageiq,NickLaMuro/manageiq,mfeifer/manageiq,gerikis/manageiq,ilackarms/manageiq,fbladilo/manageiq,ilackarms/manageiq,billfitzgerald0120/manageiq,d-m-u/manageiq,borod108/manageiq,NickLaMuro/manageiq,mfeifer/manageiq,durandom/manageiq,NaNi-Z/manageiq,agrare/manageiq,durandom/manageiq,ManageIQ/manageiq,mkanoor/manageiq,gmcculloug/manageiq,fbladilo/manageiq,kbrock/manageiq,gmcculloug/manageiq,jrafanie/manageiq,romanblanco/manageiq