问题描述
- mysql 视图 left join 非常慢
-
select uuid() ASmyid
,tu
.id
ASid
,tu
.job_number
ASjob_number
,tu
.email
ASuseremail
,tu
.name
ASname
,tu
.dept
ASdept
,tu
.manger
ASmanger
,tu
.status
ASstatus
,tu
.createDate
AScreateDate
,tu
.updateDate
ASupdateDate
,tchk
.name
ASsysName
,tchk
.number
ASsysNumber
,tchk
.status
ASsysStatus
,tchk
.createDate
ASsysCreateDate
,'香港集群账号' AStableName
from (tiw_user
tu
left OUTER jointiw_clusterHkNum
tchk
on((tchk
.tiwUid
=tu
.id
))) where 1 = 1
union all
select uuid() ASmyid
,tu
.id
ASid
,tu
.job_number
ASjob_number
,tu
.email
ASuseremail
,tu
.name
ASname
,tu
.dept
ASdept
,tu
.manger
ASmanger
,tu
.status
ASstatus
,tu
.createDate
AScreateDate
,tu
.updateDate
ASupdateDate
,tcsz
.name
ASsysName
,tcsz
.number
ASsysNumber
,tcsz
.status
ASsysStatus
,tcsz
.createDate
ASsysCreateDate
,'深圳集群账号' AStableName
from (tiw_user
tu
left OUTER jointiw_clusterSzNum
tcsz
on((tcsz
.tiwUid
=tu
.id
))) where 1 = 1
union all
select uuid() ASmyid
,tu
.id
ASid
,tu
.job_number
ASjob_number
,tu
.email
ASuseremail
,tu
.name
ASname
,tu
.dept
ASdept
,tu
.manger
ASmanger
,tu
.status
ASstatus
,tu
.createDate
AScreateDate
,tu
.updateDate
ASupdateDate
,tcwh
.name
ASsysName
,tcwh
.number
ASsysNumber
,tcwh
.status
ASsysStatus
,tcwh
.createDate
ASsysCreateDate
,'武汉集群账号' AStableName
from (tiw_user
tu
left OUTER jointiw_clusterWhNum
tcwh
on((tcwh
.tiwUid
=tu
.id
))) where 1 = 1说明:(一共用十表union进行连接 代码都是重复)且左右表的数据量相差比较大
时间: 2024-12-22 06:15:21