US 12,277,118 B2
Query optimization method and apparatus
Jian Niu, Zhejiang (CN)
Assigned to Alipay (Hangzhou) Information Technology Co., Ltd., Hangzhou (CN)
Filed by Alipay (Hangzhou) Information Technology Co., Ltd., Zhejiang (CN)
Filed on Jun. 22, 2021, as Appl. No. 17/354,465.
Claims priority of application No. 202010766906.X (CN), filed on Aug. 3, 2020.
Prior Publication US 2022/0035813 A1, Feb. 3, 2022
Int. Cl. G06F 16/2453 (2019.01); G06F 11/34 (2006.01)
CPC G06F 16/24544 (2019.01) [G06F 11/3419 (2013.01)] 11 Claims
OG exemplary drawing
 
1. A query optimization method, comprising:
obtaining a plurality of query tasks to be optimized, each query task including at least one subtask, and when a same query task includes at least two subtasks, a query dependence relationship existing between the at least two subtasks;
combining the plurality of query tasks based on the query dependence relationship to obtain a combined task; and
merging at least two subtasks in different query tasks of the plurality of query tasks based on the combined task to obtain a first merged subtask, the first merged subtask being executed to obtain query results of the at least two subtasks in the different query tasks,
wherein the merging the at least two subtasks in the different query tasks to obtain the first merged subtask includes:
determining all non-dependent subtasks of the plurality of query tasks based on the query dependence relationship, to form a first task set of the combined task, wherein each non-dependent subtask is a subtask that can be executed without depending on any other subtask, and the first task set includes all non-dependent subtasks of the plurality of query tasks; and
merging at least two non-dependent subtasks in the first task set to obtain the first merged subtask;
wherein the method further includes:
after forming the first task set of the combined task, determining, from the combined task based on the query dependence relationship, subtasks that depend on each subtask in the first task set that includes all non-dependent subtasks of the plurality of query tasks, to form a second task set of the combined task;
executing the subtasks in the first task set and storing query results; and
if the second task set and the first task set have subtasks with a same query condition and query data source, using a query result of a subtask in the first task set as a query result of the same subtask in the second task set,
wherein executing the subtasks in the first task set and storing the query results include:
concurrently executing the subtasks in the first task set; and
placing, into a cache, a query result of a subtask whose query duration meets a predetermined condition.