Optimize store_ids_for_new_records by getting rid of the O(n^2) lookups
Optimize store_ids_for_new_records by getting rid of the O(n^2) lookups

Optimize store_ids_for_new_records by getting rid of the O(n^2)
lookups. These lookups can take hours when we go over 50-100k records
being processed by store_ids_for_new_records.

And seems like there might be a Rails issue, since by doing
association.push(new_records) at
https://github.com/Ladas/manageiq/blob/48aa323551c8825e02170e251afa717ca807d2ed/app/models/ems_refresh/save_inventory_helper.rb#L69-L69

The association has the records doubled, the association is passed
into store_ids_for_new_records as 'records' parameter
https://github.com/Ladas/manageiq/blob/48aa323551c8825e02170e251afa717ca807d2ed/app/models/ems_refresh/save_inventory_helper.rb#L114-L114

And here when we do:
records.count => 50k
records.uniq.count => 25k
records.reload.count => 25k

That was slowing down the store_ids_for_new_records method even
more it seems.

Partially fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=1436176

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