在有少量数据的情况下,查询工作正常,但是在海量数据中,查询无法正常工作,并显示错误消息“#2013-查询期间与MySQL服务器的连接丢失”。
我正在开发需要从数据库中连接许多表的软件。该查询在有少量数据的同时工作正常,现在我在此阶段拥有大量数据。Query无法正常工作。在没有限制的数据较少的情况下,查询工作正常,但是我尝试使用限制的数据太多,但没有用。 我增加了执行量,查询运行了大约119秒。我想要更快的结果,因为增加服务器的执行时间不是可取的。
查询如下。
SELECT
`TA`.`id` AS `taid`,
`T`.`id` AS `trip_id`,
`TA`.`id` AS `adv_id`,
`VO`.`id` AS `VO_id`,
`P`.`id` AS `p_id`,
`V`.`id` AS `v_id`,
`J`.`id` AS `job_id`,
`T`.`lr_date` AS `date`,
`T`.`lr_no`,
`J`.`movement_nature`,
`J`.`material`,
`J`.`job_no`,
`V`.`vehicle_code`,
`T`.`container1`,
`T`.`container2`,
`T`.`cont_size`,
`T`.`from_id`,
`T`.`total_freight`,
`J`.`freight`,
SUM(TA.amount) AS amount,
SUM(TA.card) AS card,
SUM(TA.add_card) AS add_card,
`TA`.`rate` AS `rate`,
SUM(TA.add_amount) AS add_amount,
SUM(TA.party_advance) AS party_advance,
SUM(TA.total_qty) AS fuel_amt,
`VO`.`voucher_no`,
`P`.`name` AS `party`,
`O`.`name` AS `owner`,
`R`.`frm`,
`R`.`too`,
`T`.`user` AS `trip_user`,
`TA`.`user` AS `trip_adv_user`,
`VO`.`user` AS `v_user`,
`J`.`bill_no`,
`D`.`name` AS `driver_name`,
`TA`.`adv_type` AS `adv_type`,
`TA`.`repair`,
`T`.`status`,
`J`.`job_nature`,
`T`.`pc_packages`
FROM
`job` `J`
LEFT JOIN `trip_log` `T` ON
`T`.`job_id` = `J`.`id`
LEFT JOIN `trip_advance` `TA` ON
`TA`.`trip_id` = `T`.`id`
LEFT JOIN `voucher` `VO` ON
`VO`.`trip_adv_id` = `TA`.`id`
LEFT JOIN `vehicle` `V` ON
`V`.`id` = `T`.`vehicle_id`
LEFT JOIN `parties` `P` ON
`P`.`id` = `T`.`party`
LEFT JOIN `parties` `O` ON
`O`.`id` = `V`.`owner_code`
LEFT JOIN `route` `R` ON
`R`.`id` = `T`.`from_id`
LEFT JOIN `driver` `D` ON
`D`.`id` = `T`.`driver_id`
WHERE
`T`.`lr_date` >= "2019-04-15" AND `T`.`lr_date` <= "2019-04-30"
GROUP BY
`T`.`id` limit 10;
我希望得到更快的结果而不增加执行时间。