seata Optimize the Image of MySQLUpdateJoinExecutor

umuewwlo  于 4个月前  发布在  Mysql
关注(0)|答案(2)|浏览(118)

Why you need it?

For now. When I execute the sql like

update t1 innert join t2 on t1.id = t2.id set t1.name = 'Mike' where t1.id = 33

and the before image and after image would like this

before image 1 -> select t1.id, t1.name from t1 innert join t2 on t1.id = t2.id where t1.id = ? group by t1.id for update
after image 1 -> select t1.id, t1.name from t1 innert join t2 on t1.id = t2.id where t1.id in (?) group by t1.id

and the time complexity depends on the numbers of join table.

How it could be?

I have a idea that we do not join the table and do not group by the table when we build the image. For example execute the same sql

update t1 innert join t2 on t1.id = t2.id set t1.name = 'Mike' where t1.id = 33

first we found the primary key of t1 and t2

select t1.id, t2.id from t1 left join t2 on t1.id = t2.id where t1.id = 33

second we use the primary key of t1 and t2 to build the image of each table

before image 1 -> select t1.id, t1.name from t1
after image 1 -> select t2.id from t2

Add any other context or screenshots about the feature request here.

polhcujo

polhcujo1#

please assign it to me

yrdbyhpb

yrdbyhpb2#

额外增加一个查询主键值的sql,需要考虑做性能对比测试
1.无索引情况下,也就是where条件不存在索引 on和where columns都不是索引
2.where columns 存在索引
3. on columns 存在索引 where columns 也存在索引
4. 仅on columns 存在索引
以上四种情况需要对比目前join方式制作前镜像和额外join查询多表的pk,再发出基于pk查询的sql对比性能差距,初始数据可以先塞个100W,纯jdbc写个sample对比下 @renliangyu857@l81893521

相关问题