我遇到了分组问题,但我无法解决问题。如何才能取得良好的业绩呢?
select
`s`.`RECNO` AS `RECNO`,
`s`.`CTRL_ACIL` AS `CTRL_ACIL`,
`s`.`OZEL_KOD` AS `OZEL_KOD`,
`s`.`KULLANICI` AS `KULLANICI`,
`s`.`TARIH` AS `TARIH`,
`s`.`DURUM` AS `durumNo`,
`se`.`FIRMA_UNVANI` AS `FIRMA_UNVANI`,
`se`.`ADRES_ISTEL` AS `ADRES_ISTEL`,
`se`.`RECNO` AS `servis_id`,
`i`.`RECNO` AS `REFERANS_NO`,
`i`.`YAPILANLAR_M` AS `YAPILANLAR_M`,
`m`.`MUSTERI_UNVANI` AS `MUSTERI_UNVANI`,
(case `s`.`DURUM` when _utf8'0' then _utf8'Aç?k' when _utf8'1' then _utf8'Kapal?' end) AS `DURUM`,
format(sum((`d`.`MIKTAR` * `d`.`B_FIYAT`)),2) AS `TALEP_TUTAR`,
format(sum((`d`.`ONAY_MIKTAR` * `d`.`B_FIYAT`)),2) AS `ONAYLANAN_TUTAR`
from
(((((`siparis` `s` left join `siparis_det` `d` on((`s`.`RECNO` = `d`.`SRECNO`))) left join `servisler` `se` on((`s`.`servis_id` = `se`.`RECNO`))) left join `isemri_det` `de` on((`s`.`ISEMRIDET_RECNO` = `de`.`RECNO`))) left join `isemri` `i` on((`i`.`RECNO` = `de`.`ISEMRI_RECNO`))) left join `musteri_tan` `m` on((`m`.`RECNO` = `i`.`MUSTERI_RECNO`)))
group by
`s`.`RECNO`
order by
`s`.`RECNO` desc
答案 0 :(得分:1)
在这些字段上添加索引:
siparis: (RECNO), (servis_id), (ISEMRIDET_RECNO)
siparis_det: (SRECNO)
servisler: (RECNO)
isemri_det: (RECNO), (ISEMRI_RECNO)
musteri_tan: (RECNO)
isemri: (RECNO), (MUSTERI_RECNO)
这应该可以提高性能。
您的查询看起来像是来自视图的查询。你用视图吗?视图的性能可以低于简单查询的性能。