mysql - Minimize Row Locking in an Update with Subqueries -


i've got sp (percona 5.6) doing update 3 subselects. each subquery doing count different filters. sp is

update table1 set column1 = (select count table2 ...), set column2 = (select count table2 ...), set column3 = (select count table2 ...); 

i detect deadlocks when sp running , rows in table2 gets updated.

therefore try figure out how minimize row locking time table2 during sp. happens if pull out subqueries, eg

set @count1 = (select count table2 ...); set @count2 = (select count table2 ...); set @count3 = (select count table2 ...);  update table1 set column1 = @count1, set column2 = @count2, set column3 = @count3; 

i'm aware can cause inconsistency, in case ok. change regarding locking time? i'm not sure if whole sp running 1 transaction. change performance?

try set tx_isolation = read-uncommitted duration of sp.

is select count... select count(*) ... ... , hits lots of rows? or hitting 1 row?

is there 1 row in table1? or did leave off clause?

(i worried over-simplified question; lead getting irrelevant advice.)


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -