Lost connection to MySQL server during query Here is a part of my query:

SELECT * 
INTO   OUTFILE 'Target_File_Name' fields TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY ''
FROM   ( 
              SELECT 'Start time', 
                     'Calling no', 
                     'Called no', 
                     'Calltype', 
                     'Cust. name', 
                     'Total Dur.', 
                     'Call stat' 
              UNION 
                    ( 
                           SELECT cdr_startdatetime, 
                                  cdr_a_number ,( 
                                  CASE cdr_b_number 
                                         WHEN 0 THEN '' 
                                         ELSE ( 
                                                CASE cdr_calltypewhen 1 THEN concat('011',cdr_b_number)
                                                       ELSE concat('1',cdr_b_number) 
                                                end) 
                                  end ), 
                                  cdr_calltype_name , 
                                  cdr_customername ,( 
                                  CASE 
                                         WHEN cdr_totalduration&gt;0 THEN round(cdr_totalduration/60,1)
                                         ELSE 0.00 
                                  end), 
                                  cdr_callstat 
                           FROM   tlb_cdrdetails_4 FORCE INDEX(index_callstatus) 
                           WHERE  cdr_startdatetime &gt;= cast('2012-04-01 00:00' AS    datetime) 
                           AND    cdr_startdatetime &lt;= cast('2012-04-30 23:59:59' AS datetime) 
                           AND    cdr_callstat IN (42, 
                                                   52) 
                           AND    cdr_customerid IN (123,1000,1001) 
                           AND    cdr_carrierid  IN (114,1039,115))) tbl


It fetches 8 million records. It's causing a "lost connection to MySQL during query" error. Is the network speed an issue while downloading huge amount of data?
8 million rows? - network speed will determine how long it takes to download the rows, but as to why you are losing connection, you'd have to dig deeper to see if you have a timeout setting?