These are chat archives for ManageIQ/manageiq/performance

26th
Apr 2018
Keenan Brock
@kbrock
Apr 26 2018 19:34
looking
@djberg96 how many are there?
how much do you want to tweak?
I like 44 better with the where clause
Daniel Berger
@djberg96
Apr 26 2018 19:36
couldn't remember how to do a where clause with a join in AR
Keenan Brock
@kbrock
Apr 26 2018 19:36
aah
ok
@djberg96 are there a bunch of records?
would it make sense to make it 100% sql? no records over the wire?
Jason Frey
@Fryguy
Apr 26 2018 19:37
OrchestrationStackOutput.where(:type => "ManageIQ::Providers::Azure::CloudManager::OrchestrationStack").update_all('ems_ref = replace(ems_ref, "\", "/"') or something close to that
Daniel Berger
@djberg96
Apr 26 2018 19:37
Jason suggested it, but I try not to resort to that
Keenan Brock
@kbrock
Apr 26 2018 19:37
yea - you want to use replace
lol (or regex_replace ;) )
Jason Frey
@Fryguy
Apr 26 2018 19:37
I'd rather we use an update_all statement if we can to avoid effective N+1s on saves
Keenan Brock
@kbrock
Apr 26 2018 19:38
@djberg96 um. I know it looks complex and all. but the difference is in a totally different ballpark
Daniel Berger
@djberg96
Apr 26 2018 19:38
well, there's no :type on an OrchestrationStackOutput, it's joining through OrchestrationStack
Keenan Brock
@kbrock
Apr 26 2018 19:38
ok
sure
not sure if joins works with an update all
may need a sub select
update orchestration_stack_parameters
set value = value
where (select type from orchestration_stacks where orchestration_stacks.id = stack_id) = 'xtr';
that works (I can get ruby if you need)
trying a join clause
Keenan Brock
@kbrock
Apr 26 2018 19:43
aah this works too:
update orchestration_stack_parameters
set value = replace(value, '\', '/')
from orchestration_stacks
where orchestration_stacks.id = stack_id
and type = 'ManageIQ::Providers::Azure::CloudManager::OrchestrationStack';
Daniel Berger
@djberg96
Apr 26 2018 19:47
how would you do that in AR?
Keenan Brock
@kbrock
Apr 26 2018 19:49
getting there...
OrchestrationStackParameter
  .where(:stack_id => OrchestrationStack.where(:type => "ManageIQ::Providers::Azure::CloudManager::OrchestrationStack"))
  .update_all("value = replace(value, '\', '/')")
one more second please
OrchestrationStackParameter
  .where(:stack_id => ManageIQ::Providers::Azure::CloudManager::OrchestrationStack.select(:id))
  .update_all("value = replace(value, '\', '/')")
now if you don't want to define CloudManager, because you don't want the type
then the first one is probably better
since this is a migration, I think the first one is better
changed - don't need the joins
not sure if you'll need \\ or \
@djberg96 let me know how that works for you
Daniel Berger
@djberg96
Apr 26 2018 19:53
trying it out now, thanks
Daniel Berger
@djberg96
Apr 26 2018 19:58
Minor mod: .update_all("ems_ref = replace(ems_ref, '\\', '/')")
but yes, that works, thanks!
using the first one
is there a clever way to replace multiple columns, or do I just make multiple update_all calls?
Daniel Berger
@djberg96
Apr 26 2018 21:06
nm, got it
Keenan Brock
@kbrock
Apr 26 2018 21:26
@djberg96 yea - [].each do |klass]