Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a query which is running on mysql 5.5, and i stuck at the temprory table problem.

Query is working in small amount of time but when i am sending concurrently it's stucking in status of "Copying to tmp table"

Here is the query:

SELECT SQL_NO_CACHE 
u.ID,tes.ID TESIS_ID, u.KOD, tes.ENLEM, tes.ADRES, tes.BOYLAM, u.IPTALGUVENCE, u.GENELIPTALGUVENCE, tes.YILDIZ, u.ODEMESECENEK_ID, u.NOTLAR, u.WEBGOSTER, u.PARABIRIM_ID,  u.OPERATOR_ID, '2012-01-01' as SONGUNCELLEME, u.OZELNOTLAR, u.WEBUYARI, u.URUNTURU, tes.BAYANSIZBAY, tes.GUNBAZLIYAS 
, MIN(fc.UCRET) as UCRET, fc.FIYAT_ID 
 FROM psturop_static.std_urun u 
 join psturop_static.std_tesis AS tes on tes.ID=u.TESIS_ID 
 left join psturop_static.std_urunfiyatowner as ufo on ufo.URUN_ID=u.ID 
 left join psturop_static.std_urunozelfiyat ozel ON ufo.ID=ozel.FIYATLANDIRMA_ID 
 join psturop_static.std_urunfiyatchild as fc on fc.FIYAT_ID = ufo.ID 
 left join psturop_static.std_tesisoda tesisoda on tesisoda.TESIS_ID=tes.ID AND ufo.ODA_ID=tesisoda.ID 
 left join psturop_static.std_tesisodakonaklama tesisOdaKonaklama on tesisOdaKonaklama.ODA_ID=tesisoda.ID 
 left join psturop_defs.dfd_konaklama konaklama on tesisOdaKonaklama.KONAKLAMATURU_ID=konaklama.ID 
 WHERE u.AKTIF=1 
AND u.URUNTURU=0 
 AND (ufo.OZELFIYAT=0 OR (ozel.ACENTA_ID=0 AND ozel.KULLANICI_ID=0 AND ufo.OZELFIYAT=1)) AND ufo.VISIBLE=1 
 AND fc.TARIH>='2013-06-20' AND fc.TARIH<'2013-06-23' 
 AND IF(ufo.TARIHDENETIM = 1 , (ufo.GIRISBAS <= '2013-06-20' AND ufo.GIRISSON >= '2013-06-20') ,1) 
 AND IF(ufo.GIRISGUNU =  0 , 1, ufo.GIRISGUNU = 4) 
 AND ((konaklama.YETISKIN=1 AND fc.FIYATTIPI_ID=3) OR (konaklama.YETISKIN=2 AND fc.FIYATTIPI_ID=1) OR (konaklama.YETISKIN=3 AND fc.FIYATTIPI_ID=4) OR (konaklama.YETISKIN=4 AND fc.FIYATTIPI_ID=5) OR (konaklama.YETISKIN=5 AND fc.FIYATTIPI_ID=6) OR (konaklama.YETISKIN=6 AND fc.FIYATTIPI_ID=12))
 AND ((( (konaklama.YETISKIN=2 AND konaklama.ILAVE=0 AND konaklama.COCUK=0) OR (konaklama.YETISKIN=1 AND konaklama.ILAVE=1 AND konaklama.COCUK=0)))) 
 GROUP BY u.ID 
 ORDER BY u.ISIM 
 LIMIT 20 OFFSET 0

Here is explain:

'1', 'SIMPLE', 'fc', 'range', 'TARIH,FIYAT_ID,FIYATTIPI_ID', 'TARIH', '3', NULL, '20150', 'Using where; Using temporary; Using filesort'
'1', 'SIMPLE', 'ufo', 'eq_ref', 'PRIMARY,URUN_ID,ODA_ID', 'PRIMARY', '4', 'psturop_static.fc.FIYAT_ID', '1', 'Using where'
'1', 'SIMPLE', 'u', 'eq_ref', 'PRIMARY,TESIS_ID', 'PRIMARY', '4', 'psturop_static.ufo.URUN_ID', '1', 'Using where'
'1', 'SIMPLE', 'tes', 'eq_ref', 'PRIMARY,ID', 'PRIMARY', '4', 'psturop_static.u.TESIS_ID', '1', ''
'1', 'SIMPLE', 'ozel', 'ref', 'FIYATLANDIRMA_ID', 'FIYATLANDIRMA_ID', '4', 'psturop_static.ufo.ID', '1', 'Using where'
'1', 'SIMPLE', 'tesisoda', 'eq_ref', 'PRIMARY,TESIS_ID', 'PRIMARY', '4', 'psturop_static.ufo.ODA_ID', '1', 'Using where'
'1', 'SIMPLE', 'tesisOdaKonaklama', 'ref', 'ODA_ID,KONAKLAMATURU_ID', 'ODA_ID', '4', 'psturop_static.ufo.ODA_ID', '4', 'Using where'
'1', 'SIMPLE', 'konaklama', 'eq_ref', 'PRIMARY', 'PRIMARY', '4', 'psturop_static.tesisOdaKonaklama.KONAKLAMATURU_ID', '1', 'Using where'

Thank You,

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.