Home > database >  After using the union all query speed becomes 7 s individual queries added up to no more than 3 s
After using the union all query speed becomes 7 s individual queries added up to no more than 3 s

Time:03-30

SELECT the NAME
,
Taskname,
Taskstartdate,
Manager,
Startdate,
Completiondate,
Enddate,
Projectid,
Project_relation_type,
Departmentid,
Requester,
DAY,
Create_time,
Taskid,
Projecttypename,
Projectnumber,
The progress,
Rapiddegree
The FROM
(
SELECT the NAME
,
Taskname,
Taskstartdate,
Manager,
Startdate,
Completiondate,
Enddate,
Projectid,
Project_relation_type,
Departmentid,
Requester,
DAY,
Create_time,
Taskid,
Projecttypename,
Projectnumber,
The progress,
Rapiddegree
The FROM
(
The SELECT MAX
(t1. NAME) AS the NAME,
CASE

WHEN MAX (t3. End_time_) IS NOT NULL
AND MAX (t3. Name_)='archive' THEN
'over the ELSE MAX (t3) name_)
END AS taskName,
MAX (t3. Start_time_) AS taskStartDate,
MAX (t5. Realname) AS a manager,
To_char (t1) the start_date, 'yyyy - MM) AS the startDate,
To_char (t1.com pletion_date, '- dd yyyy - MM) AS completionDate,
CASE

The WHEN t1. End_date IS NULL THEN
To_char (CURRENT_DATE, 'yyyy - MM) ELSE to_char (t1) end_date,' yyyy - MM)
END AS endDate,
T1 uuid AS projectId,
T1 project_relation_type,
MAX (e.d epartment_id) AS departmentId,
MAX (t10. NAME) AS the requester,
CURRENT_DATE - t1. The start_date AS DAY,
MAX (t1, create_time) AS create_time,
MAX (t3. Id_) AS taskId,
MAX (t13. NAME) AS projectTypeName,
T1 project_number AS projectNumber,
MAX (
COALESCE (t14. Percentage, '0')) AS progress,
MAX (t1. Rapid_degree) AS rapidDegree
The FROM
T_project t1
INNER JOIN act_hi_procinst t2 ON t2. Business_key_=t1. The uuid
INNER JOIN act_hi_taskinst t3 ON t3. Start_time_ IN (
The SELECT MAX
(t4. Start_time_)
The FROM
Act_hi_taskinst t4
INNER JOIN t_user t5 ON t5. Uuid=t4. Assignee_
WHERE
T5. Department='59358597482 a45bba4f049998474ab31'
GROUP BY
T4. Proc_inst_id_
)
AND t3. Proc_inst_id_=t2. Id_
LEFT the JOIN t_user t5 ON t5. Uuid=t1. The manager
LEFT the JOIN t_customer t10 ON t10. Uuid=t1. The requester
LEFT the JOIN t_project_type t13 ON t13. Uuid=t1. Project_type
LEFT the JOIN t_project_progress t14 ON t14. Project_id=t1. The uuid
AND t14. Department_id='59358597482 a45bba4f049998474ab31'
AND (
T14. The DATE IN (SELECT MAX (DATE) FROM t_project_progress t15 WHERE t15. Project_id=t1. The uuid AND t15. Department_id='59358597482 a45bba4f049998474ab31))
LEFT the JOIN (SELECT * FROM t_project_effect t16 WHERE t16, department_id='59358597482 a45bba4f049998474ab31) e ON e.p roject_id=t1. The uuid
GROUP BY
T1. Uuid
The ORDER BY
T1. Create_time DESC
B)
WHERE
1=1
AND b.t askName (IN ', director of the receiving AND assign ', 'head receive', 'project', 'a check) UNION ALL
SELECT
*
The FROM
(
The SELECT MAX
(t1. NAME) AS the NAME,
CASE

WHEN MAX (t3. End_time_) IS NOT NULL
AND MAX (t3. Name_)='archive' THEN
'over the ELSE MAX (t3) name_)
END AS taskName,
MAX (t3. Start_time_) AS taskStartDate,
MAX (t5. Realname) AS a manager,
To_char (t1) the start_date, 'yyyy - MM) AS the startDate,
To_char (t1.com pletion_date, '- dd yyyy - MM) AS completionDate,
CASE

The WHEN t1. End_date IS NULL THEN
To_char (CURRENT_DATE, 'yyyy - MM) ELSE to_char (t1) end_date,' yyyy - MM)
END AS endDate,
T1 uuid AS projectId,
T1 project_relation_type,
MAX (e.d epartment_id) AS departmentId,
MAX (t10. NAME) AS the requester,
CURRENT_DATE - t1. The start_date AS DAY,
MAX (t1, create_time) AS create_time,
MAX (t3. Id_) AS taskId,
MAX (t13. NAME) AS projectTypeName,
T1 project_number AS projectNumber,
MAX (
COALESCE (t14. Percentage, '0')) AS progress,
MAX (t1. Rapid_degree) AS rapidDegree
The FROM
T_project t1
INNER JOIN act_hi_procinst t2 ON t2. Business_key_=t1. The uuid
INNER JOIN act_hi_taskinst t3 ON t3. Start_time_ IN (
The SELECT MAX
(t4. Start_time_)
The FROM
Act_hi_taskinst t4
INNER JOIN t_user t5 ON t5. Uuid=t4. Assignee_
GROUP BY
T4. Proc_inst_id_
)
AND t3. Proc_inst_id_=t2. Id_
LEFT the JOIN t_user t5 ON t5. Uuid=t1. The manager
LEFT the JOIN t_customer t10 ON t10. Uuid=t1. The requester
LEFT the JOIN t_project_type t13 ON t13. Uuid=t1. Project_type
LEFT the JOIN t_project_progress t14 ON t14. Project_id=t1. The uuid
AND t14. Department_id='59358597482 a45bba4f049998474ab31'
AND (
T14. The DATE IN (SELECT MAX (DATE) FROM t_project_progress t15 WHERE t15. Project_id=t1. The uuid AND t15. Department_id='59358597482 a45bba4f049998474ab31))
LEFT the JOIN (SELECT * FROM t_project_effect t16 WHERE t16, department_id='59358597482 a45bba4f049998474ab31) e ON e.p roject_id=t1. The uuid
GROUP BY
T1. Uuid
The ORDER BY
T1. Create_time DESC
B)
WHERE
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related