mysql - Why prepared statements are managed by each session? -
why prepared statements managed each session?
i not sure of databases handle prepared statements per session. postgresql , mysql(maybe) do.
why not shared between session? there reason?
for example, there many connections in connection pool , connections share same queries , generate same prepared statements. why database not let connections share prepared statement?
maintaining shared cache expensive - should protect cache against race condition, should clean cache, ... first argument. second argument more important - prepared statement cached execution plan - plan optimized 1 vector of parameters. when using different parameter's vector, plan can suboptimal again vector. there philosophy, user can uses different vectors , needs different plans. using session shared plan cache doesn't eliminate overhead generating plans (although overhead fast simple queries minimal), eliminates overhead , race conditions related management of shared data, , partially reduce risk of using suboptimal prepared plans.
Comments
Post a Comment