VM表
教师表
TeacherClass表
teacherid
的classid
班级表
Uni Table
ID
名称
的classid
我想要获取VM.id,teacher1.id,teacher1_uni.id,teacher2.id,teacher2_uni.id
当前查询:
select
VM.id,
VM.teacher1_id,
getUni(VM.teacher1_id),
VM.teacher2_id,
getUnit(VM.teacher2_id)
from VM
getUni(@teacherid):
select
U.id
from Uni
join Class C on Uni.classid = C.id
join TeacherClass TC on TC.classid = C.id
where TC.teacherid = @teacherid
上述查询很慢,并在21秒后返回数据。请帮助我加快速度。我想函数调用使我的查询变慢。如何优化此查询?