php - Keep Sql Connection open for iterating many requests? Or close each step? -
hey there -- general operation calling sql server, or requiring open connection @ that.
say have anywhere 20 1000 select calls make each item in data being looped. each step, i'll select sql, store data locally in struct, proceed. not expensive call, should keep connection open entire loop? or should open , close every step?
how expensive in run time opening connection? think it'd better keep connection open, correct response this.
thanks.
how expensive in run time opening connection
this considers cpu speed , doesn't consider bandwidth.
keeping open connection saves on cpu blocks other requests being able use connection. trade off. tough "correct response" without knowing lot more, in either case seems 1 tinkering tolerances instead of nailing nominals
that said typically start keeping connection open duration of unit of sql work , close it.
although 1 thing seem little sketchy line
20 1000 select calls make each item in data being looped.
try , more set based operations instead.
Comments
Post a Comment