Досталась в наследство разработка, запрос в которой обрабатывается порядка 10 минут, в то время когда четко определены даты, подразделение, мол и группа МЦ. Что с ним не так?
Код: Выделить всё
select
MbpMove.*, MbpIn.*, KatMbp.*, KatMol.*, KatEd.Name, KatOrg.Name, Katpodr.*, KatMc.*, TempGrn.*
from
MbpMove,MbpIn,MbpIn MbpInT,KatMBP KatMBPT,KatMbp,KatMol,KatEd,KatOrg,Katpodr,KatMc,KatParty,GroupMc,
KatPodr KatPodrP (ReadOnly),
KatMol KatMolP (ReadOnly),
GroupMc GroupMcP (ReadOnly),
KatMbp KatMbpP (ReadOnly),
Pick,
Pick PickPodr, // wList = 11
Pick PickMol, // wList = 8
Pick PickMbp, // wList = 23
Pick PickGr, // wList = 2
TempGrn
where
((
//-------------------для расхода--------------------------------
MBPIn.NRec == MBPOut.cMBPIn and
DateT2 >> MbpIn.din and
Word(1) == MbpIn.InEkspl (NoIndex) and
MBPInT.cMBP /== KatMBPT.NRec (NoIndex) and
(Word(1) = MbpInT.InEkspl) and
DateT2 >> MbpInT.DateSpis (NoIndex) and
DateT2 >> MbpInT.din (NoIndex) and
MBPIn.cMBP /== KatMBP.NRec and
KatMBP.cMc == KatMc.Nrec and
'' == KatMbp.DESgR (NoIndex)
and MBPIn.cMol == KatMol.NRec
and MBPIn.cPodr == KatPodr.NRec
and KatMBP.cGroupMc == GroupMc.Nrec
and KatMbp.cEd == KatEd.Nrec
and word(11) == PickPodr.wList
and PickPodr.cRec == KatPodrP.Nrec
and word( 8) == PickMol.wList
and PickMol.cRec == KatMolP.Nrec
and word( 2) == PickGr.wList
and PickGr.cRec == GroupMcP.Nrec
and word(23) == PickMbp.wList
and PickMbp.cRec == KatMbpP.Nrec
and MbpIn.nrec == exclassval.crec
and 2001 == exclassval.wtable
and 78 == exclassval.classcode
and exclassval.cclassseg == exclassseg.nrec
))
Condition EnterPodr as SearchMarker(MarkPodr, MBPIn.cpodr, IndexNo)
Condition EnterMol as SearchMarker(MarkMol, MBPIn.cMol, IndexNo)
Condition EnterGr as SearchMarker(MarkGr, KatMbp.CGROUPMC, IndexNo)
Condition EnterMbp as SearchMarker(MarkMbp, MBPIn.cMBP, IndexNo)
Condition PodrMol as SearchMarker(MarkPodr, MBPIn.cpodr, IndexNo)
and SearchMarker(MarkMol, MBPIn.cMol, IndexNo2)
Condition PodrGr as SearchMarker(MarkPodr, MBPIn.cpodr, IndexNo)
and SearchMarker(MarkGr, KatMbp.CGROUPMC, IndexNo3)
Condition PodrMbp as SearchMarker(MarkPodr, MBPIn.cpodr, IndexNo)
and SearchMarker(MarkMbp, MBPIn.cMBP, IndexNo4)
Condition MolGr as SearchMarker(MarkMol, MBPIn.cMol, IndexNo2)
and SearchMarker(MarkGr, KatMbp.CGROUPMC, IndexNo3)
Condition MolMbp as SearchMarker(MarkMol, MBPIn.cMol, IndexNo2)
and SearchMarker(MarkMbp, MBPIn.cMBP, IndexNo4)
Condition GrMbp as SearchMarker(MarkGr, KatMbp.CGROUPMC, IndexNo3)
and SearchMarker(MarkMbp, MBPIn.cMBP, IndexNo4)
Condition MolGrMbp as SearchMarker(MarkMol, MBPIn.cMol, IndexNo2)
and SearchMarker(MarkGr, KatMbp.CGROUPMC, IndexNo3)
and SearchMarker(MarkMbp, MBPIn.cMBP, IndexNo4)
Condition PodrGrMbp as SearchMarker(MarkPodr, MBPIn.cpodr, IndexNo)
and SearchMarker(MarkGr, KatMbp.CGROUPMC, IndexNo3)
and SearchMarker(MarkMbp, MBPIn.cMBP, IndexNo4)
Condition PodrMolMbp as SearchMarker(MarkPodr, MBPIn.cpodr, IndexNo)
and SearchMarker(MarkMol, MBPIn.cMol, IndexNo2)
and SearchMarker(MarkMbp, MBPIn.cMBP, IndexNo4)
Condition PodrMolGr as SearchMarker(MarkPodr, MBPIn.cpodr, IndexNo)
and SearchMarker(MarkMol, MBPIn.cMol, IndexNo2)
and SearchMarker(MarkGr, KatMbp.CGROUPMC, IndexNo3)
Condition Combi as SearchMarker(MarkPodr, MBPIn.cpodr, IndexNo)
and SearchMarker(MarkMol, MBPIn.cMol, IndexNo2)
and SearchMarker(MarkGr, KatMbp.CGROUPMC, IndexNo3)
and SearchMarker(MarkMbp, MBPIn.cMBP, IndexNo4)
order by TempGrn.NrecMc
;