Incorrect key file for table '/tmp/#sql_18b4_0.MYI'; try to repair it

后端 未结 1 1907
忘掉有多难
忘掉有多难 2021-01-24 09:25

I got a query from our developers that is not executing on server and giving below error-

Incorrect key file for table \'/tmp/#sql_18b4_0.MYI\'; try to repair it         


        
相关标签:
1条回答
  • 2021-01-24 10:18

    Oh shit this was a silly mistake from my developer end, After 30 minutes brain storming to design this query in different way I got this issue that developer was using join in wrong way, due to this mysql was not able to proper join tables data and consuming all space in /tmp directory and throwing this error. Correct query is here-

    SELECT `PsMasterSubject`.`id`, `PsMasterSubject`.`name`, `PsProgram`.`name`, `PsStreamLevel`.`id` 
    FROM `misdb`.`ps_master_subjects` AS `PsMasterSubject` 
    LEFT JOIN `misdb`.`ps_programs` AS `PsProgram` ON (`PsMasterSubject`.`ps_program_id` = `PsProgram`.`id`) 
    LEFT JOIN `misdb`.`ps_stream_levels` AS `PsStreamLevel` ON (`PsStreamLevel`.`id` = `PsProgram`.`ps_stream_level_id`) 
    LEFT JOIN `misdb`.`ps_program_levels` AS `PsProgramLevel` ON (`PsProgramLevel`.`id` = `PsStreamLevel`.`ps_program_level_id`) 
    WHERE 1 = 1 
    ORDER BY `PsMasterSubject`.`id` DESC LIMIT 10;
    

    Now question is here that is this a mysql bug as mysql should throw wrong syntax error but here mysql is trying to create a temporary table for temp data.

    I will be very thankful if anyone can clear this to me.

    0 讨论(0)
提交回复
热议问题