求救优化SQL
SELECT tRegPatient.PatientID,tRegPatient.LocalName,tRegPatient.EnglishName,tRegPatient.Birthday,tRegPatient.Telephone,tRegPatient.ReferenceNo,tRegPatient.Address,tRegVisit.InhospitalNo,tRegVisit.ClinicNo,tRegVisit.CurrentAge,
tRegVisit.BedNo,tRegOrder.AccNo,tRegProcedure.ExamSystem,tRegProcedure.Modality,tRegProcedure.Charge,tRegProcedure.Status as RPStatus,
(SELECT LocalName from tUser where tUser.UserGuid=tRegProcedure.Registrar) as Registrar,
(SELECT LocalName from tUser where tUser.UserGuid=tRegProcedure.Technician) as Technician,
(SELECT LocalName from tUser where tUser.UserGuid=tRegProcedure.TechDoctor) as TechDoctor,
(SELECT LocalName from tUser where tUser.UserGuid=tRegProcedure.TechNurse) as TechNurse,
(SELECT Description from tDictionaryValue where tDictionaryValue.DictionaryValue=tRegPatient.Gender and tDictionaryValue.Tag=1) as Gender,
(SELECT Description from tDictionaryValue where tDictionaryValue.DictionaryValue=tRegProcedure.Status and tDictionaryValue.Tag=13) as Status,
(SELECT Description from tDictionaryValue where tDictionaryValue.DictionaryValue=tRegOrder.ApplyDept and tDictionaryValue.Tag=2) as ApplyDept,
(SELECT Description from tDictionaryValue where tDictionaryValue.DictionaryValue=tRegOrder.ApplyDoctor and tDictionaryValue.Tag=8) as ApplyDoctor,
(SELECT Description from tDictionaryValue where tDictionaryValue.DictionaryValue=tRegVisit.PatientType and tDictionaryValue.Tag=5) as PatientType,
(SELECT Description from tDictionaryValue where tDictionaryValue.DictionaryValue=tRegVisit.InhospitalRegion and tDictionaryValue.Tag=3) as InhospitalRegion,
tRegProcedure.RegisterDt,tRegProcedure.ExamineDt,tRegProcedure.BookingBeginDt,tRegProcedure.BookingEndDt,tRegProcedure.ProcedureGuid,
tProcedureCode.Description,tProcedureCode.ModalityType,tProcedureCode.Bodypart,tProcedureCode.CheckingItem,tProcedureCode.BookingNotice,
tModality.Room
FROM tRegPatient,tRegVisit,tRegOrder,tRegProcedure,tProcedureCode,tModality
where tRegPatient.PatientGuid=tRegVisit.PatientGuid and tRegVisit.VisitGuid=tRegOrder.VisitGuid and tRegOrder.OrderGuid=tRegProcedure.OrderGuid and tRegProcedure.ProcedureCode=tProcedureCode.ProcedureCode and tRegProcedure.Modality=tModality.Modality
关联挺多表的,表结构不可能再修改,现在返回789333需要6秒时间,不知道还能什么优化? 在线结帖
[解决办法]
好长的语句阿...
[解决办法]
78万?6s?不知道慢不慢哦...
有索引的化就会快点...
[解决办法]
好长
[解决办法]
这样会看晕我们的~LZ
[解决办法]
UserGuid
tDictionaryValue.DictionaryValue 与tUser.UserGuid 都加上索引,能稍微快点
但说实话除了这个没什么好优化的,一般情况下,数据库的优化就是最优的了