WO2024046015A1 - 一种数据查询方法、装置、存储介质及电子设备 - Google Patents

一种数据查询方法、装置、存储介质及电子设备 Download PDF

Info

Publication number
WO2024046015A1
WO2024046015A1 PCT/CN2023/110634 CN2023110634W WO2024046015A1 WO 2024046015 A1 WO2024046015 A1 WO 2024046015A1 CN 2023110634 W CN2023110634 W CN 2023110634W WO 2024046015 A1 WO2024046015 A1 WO 2024046015A1
Authority
WO
WIPO (PCT)
Prior art keywords
query
execution plan
target
executed
statement
Prior art date
Application number
PCT/CN2023/110634
Other languages
English (en)
French (fr)
Inventor
王涛
葛林成
Original Assignee
支付宝(杭州)信息技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 支付宝(杭州)信息技术有限公司 filed Critical 支付宝(杭州)信息技术有限公司
Publication of WO2024046015A1 publication Critical patent/WO2024046015A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2462Approximate or statistical queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation

Definitions

  • This specification relates to the field of computer technology, and in particular, to a data query method, device, storage medium and electronic equipment.
  • Graph database is currently a widely used database that can be used to store privacy data, business data, etc.
  • data is stored in the form of nodes and edges, which makes it easy to describe the relationships between data entities. For example, if you need to save the information of employees of a company, you can save the information of each employee in the company. to each node (an employee's information is saved in one node), and the relationship between any two employees (for example: colleague relationship, leadership relationship, etc.) can be passed between the two nodes corresponding to the two employees. represented by the side.
  • This specification provides a data query method, device, storage medium and electronic equipment to solve the problem of low database query data efficiency in related technologies.
  • This specification adopts the following technical solution:
  • This specification provides a data query method, which includes: obtaining a query statement input by the user, the query statement is used to query data from the database; and generating the query statement according to the query statement The corresponding execution plan; according to the execution plan, determine each query operation involved in the execution plan and the order in which each query operation is executed; according to the order in which each query operation is executed, determine from each query operation Target operation, the target operation is an operation other than the last query operation executed in each of the query operations; when executing the execution plan, duplicate results contained in the query results obtained by executing the target operation are deduplicated , and based on the query results after deduplication, the query data corresponding to the query statement is obtained.
  • generating an execution plan corresponding to the query statement according to the query statement specifically includes: performing syntax analysis on the query statement to obtain a syntax tree corresponding to the query statement; and generating the syntax tree corresponding to the query statement.
  • the execution plan corresponding to the above query statement specifically includes: performing syntax analysis on the query statement to obtain a syntax tree corresponding to the query statement; and generating the syntax tree corresponding to the query statement.
  • determine the target operation from each query operation according to the execution order of each query operation specifically including: judging whether there is a historical execution plan matching the execution plan in each historical execution plan; if If not, determine the target operation from each of the query operations according to the order in which the query operations are executed.
  • the method further includes: if it is determined that there is a historical execution plan matching the execution plan in each historical execution plan, then based on the historical execution plan matching the execution plan, from each query operation Determine the target operation.
  • determining the target operation from each of the query operations according to the order in which the query operations are executed includes: for each query operation involved in the execution plan, determining the query operation corresponding to the query operation. Query object; determine the target operation from each query operation according to the association between the query objects corresponding to each query operation and the order in which the query operations are executed.
  • the method when executing the execution plan, before deduplicating duplicate results contained in the query results obtained by executing the target operation, the method further includes: adding operation instructions corresponding to the target operation in the execution plan. position, determine the position where the deduplication operation is inserted in the execution plan as the target position; according to the target position, insert the deduplication operation instruction in the execution plan to generate an optimized execution plan; after executing the When executing the plan, duplicate results contained in the query results obtained by executing the target operation are deduplicated, which specifically includes: when executing the optimized execution plan, according to the inserted deduplication operation instruction, the Duplicate results contained in the query results obtained after the target operation are deduplicated.
  • a deduplication operation instruction into the execution plan according to the target location, which specifically includes: determining the deduplication operation instruction already included in the execution plan; adding the deduplication operation instruction already included in the execution plan. to the target location.
  • This specification provides a data query device, including: an acquisition module, used to obtain the query statement input by the user, the query statement is used to query data from the database; a generation module, used to generate the said query statement according to the query statement The execution plan corresponding to the query statement; the determination module is used to determine each query operation involved in the execution plan and the order of execution of each query operation according to the execution plan; the optimization module is used to execute each query operation according to the The sequence of determining the target operation from each of the query operations, the target operation is an operation other than the last query operation executed in each of the query operations; the query module is used to execute the execution plan when executing the execution plan. Duplicate results contained in the query results obtained by executing the target operation are deduplicated, and query data corresponding to the query statement is obtained based on the deduplicated query results.
  • This specification provides a computer-readable storage medium.
  • the storage medium stores a computer program.
  • the computer program is executed by a processor, the above data query method is implemented.
  • This specification provides an electronic device, including a memory, a processor and a device stored in the memory and capable of processing
  • a computer program running on the processor implements the above data query method when the processor executes the program.
  • At least one of the above technical solutions adopted in this manual can achieve the following beneficial effects:
  • the query statement input by the user is first obtained.
  • the query statement is used to query data from the database, and based on the query statement, a corresponding query statement is generated.
  • Execution plan according to the execution plan, determine each query operation involved in the execution plan and the order in which each query operation is executed.
  • each query operation determines the target operation from each query operation, where the target operation is except For operations other than the last executed query operation in each of the query operations, when executing the execution plan, duplicate results contained in the query results obtained by executing the target operation are deduplicated, and based on the deduplicated query results, the query is obtained Query data corresponding to the statement.
  • the execution order of the query operations involved in the generated execution plan can be used to determine which query results of the query operations are to be deduplicated in the execution plan, which can reduce The task volume when the database performs subsequent query operations is performed, and the query results of the determined query operations are deduplicated, thereby improving the efficiency of database query data.
  • Figure 1 is a schematic flow chart of a data query method provided in this manual
  • Figure 2 is a schematic diagram of the process of executing query statements in the database provided in this manual
  • Figure 3 is a schematic diagram of a data query device provided in this specification.
  • FIG. 4 is a schematic diagram of an electronic device corresponding to FIG. 1 provided in this specification.
  • Figure 1 is a schematic flowchart of a data query method provided in this specification, including the following steps S100 to S108.
  • the database can obtain the query statement entered by the user, generate an execution plan based on the query statement entered by the user, and then query the corresponding data based on the generated execution plan.
  • the query statement can be the query statement used by the user.
  • the execution subject used to implement the data query method may refer to a terminal device on which a database is deployed, such as a desktop computer, a laptop computer, or other terminal devices, or may refer to a designated device such as a server.
  • a terminal device on which a database is deployed such as a desktop computer, a laptop computer, or other terminal devices, or may refer to a designated device such as a server.
  • server the execution subject as an example to explain the query method of the data provided in this manual.
  • S104 According to the execution plan, determine each query operation involved in the execution plan and the order in which each query operation is executed.
  • the server can perform syntax analysis on the query statement to obtain the syntax tree corresponding to the query statement (that is, the derivation result of sentence meaning derivation based on the sentence pattern of the query statement), and then execute
  • the plan generator (a component in the database) generates an execution plan corresponding to the query statement based on the parsed syntax tree.
  • the execution plan is used to represent each query operation involved in the database execution of the query statement and the execution of each query operation. order, etc.
  • the query statement is "Query the names of books read by the friends of the user named A".
  • the database will first query the friends of the user named A.
  • the query results are B, C, and then the database It will continue to query the friends of B and C, and then query the books read by the friends of the users named A, and finally get the names of these books.
  • the database here performs these query operations. , and the order in which these query operations are executed, is an execution plan.
  • the execution plan can also be used to represent the path of the database to execute these query operations, as well as the execution of these query operations.
  • Query operation method for example: whether to query data according to the index, etc.
  • the server After the server generates the execution plan corresponding to the query statement, it can determine each query operation involved in the execution plan and the order in which each query operation is executed.
  • S106 Determine a target operation from each of the query operations according to the execution order of each of the query operations.
  • the target operation is an operation other than the last query operation executed among the query operations.
  • the server After determining each query operation involved in the execution plan and the order in which each query operation is executed based on the execution plan, the server can determine the target operation from each query operation based on the order in which each query operation is executed, where the target operation It is the operations involved in the execution plan except for the last query operation executed in each query operation.
  • the server can determine the query object corresponding to the query operation, based on the association between the query objects corresponding to each query operation, and the order in which each query operation is executed. , determine the target operation from each query operation.
  • the method of determining the target operation from each query operation may be to target each query involved in the execution plan.
  • a query operation based on the order in which each query operation is executed, determines the previous query operation executed before the query operation is executed, and determines whether the query object of this query operation directly depends on the query object of the previous query operation, for example :
  • the query statement is "query which books have been read by the friends of the person named A”
  • the second is "Who are the friends of each friend of the person named A”
  • the third is "Query what books have been read by the friends of each friend of the person named A", among which, the The books read by the friends of the person's friends completely depend on the friends of the friends named A. Therefore, it can be considered that the third query operation is completely dependent on the second query operation, that is, the first If the query
  • the server can determine whether the query object of the query operation directly depends on the query object of the previous query operation. For example, the server can determine whether the query operation satisfies the preset conditions according to the preconfigured conditions. condition. If yes, it is considered that the query object of this query operation directly depends on the query object of the previous query operation. For another example: the server can pass the query object of this query operation and the query object of the previous query operation. Perform lexical analysis to determine whether the query object of this query operation directly depends on the query object of the previous query operation.
  • the server can also determine the deduplication operations included in the execution plan. Based on the correlation between the query objects corresponding to each query operation and the order in which each query operation is executed, it can determine the execution time of each query operation. The correlation between the query object of the previous query operation executed before the query operation corresponding to the above-mentioned included deduplication operation in the sequence, and the query object of the query operation corresponding to the above-mentioned included deduplication operation. system to determine whether the previous query operation executed before the query operation corresponding to the above included deduplication operation in the execution sequence of each query operation is the target operation.
  • the server can deduplicate the query results of the query operations involved in the execution plan except for the query operation before the last executed query operation in each query operation, so that it can continue based on the deduplicated query results.
  • Query to obtain the query data corresponding to the query statement, which can then reduce the workload of the database when executing the query statement and improve the efficiency of data execution of the query statement.
  • the server can deduplicate the duplicate results contained in the query results obtained by executing the target operation when executing the execution plan, and obtain the query data corresponding to the query statement based on the deduplicated query results. .
  • the server can determine the position to insert the deduplication operation in the execution plan based on the position of the operation instruction corresponding to the target operation as the target position, and then according to the target position, execute Insert the deduplication operation instruction into the plan to generate the optimized execution plan, and save the optimized execution plan to the historical execution plan.
  • you can perform the target operation according to the inserted deduplication operation instruction. Duplicate results contained in the obtained query results are deduplicated.
  • the method for the server to insert the deduplication operation instruction in the execution plan may be to determine whether the deduplication operation for deduplicating the query results of the query operation included in the execution plan is a valid operation, which can be understood as, if so, then Copy the deduplication operations included in the execution plan to the target location. If not, adjust the deduplication operations included in the execution plan to the target location.
  • the database can first determine whether there is a historical execution plan matching the execution plan in each historical execution plan before determining the target operation. , if not, then determine the target operation from each query operation based on the order in which each query operation is executed. If it is judged that there is a historical execution plan that matches the execution plan in each historical execution plan, then based on the historical execution plan that matches the execution plan Execution plan, determine the target operation from each query operation involved in the execution plan.
  • the method to determine whether there is a historical execution plan matching the execution plan in each historical execution plan may be to remove the parameters in the execution plan, and then determine whether there is and remove the parameters in each historical execution plan.
  • a plan-consistent historical execution plan is an execution plan that matches this execution plan.
  • the execution plan is to query the friends of the user named A
  • the execution plan after removing the parameters is to query the friends of a certain user
  • this manual also provides a schematic diagram of the optimization process of the execution plan, as shown in Figure 2.
  • Figure 2 is a schematic diagram of the process of executing query statements in the database provided in this manual.
  • the database after the database obtains the query statement entered by the user, it can generate an execution plan corresponding to the query statement based on the query statement, and then determine whether there is an execution plan in each historical execution plan that matches the generated execution plan. Historical execution plan. If yes, determine the query operation that needs to be deduplicated based on the historical execution plan as the target operation. If not, determine the query operations required in the execution plan based on the order in which each query operation involved in the execution plan is executed. The query operation of the deduplication operation is used as the target operation. According to the position of the operation instruction corresponding to the target operation in the execution plan, the position of inserting the deduplication operation in the execution plan can be determined, and then the deduplication operation can be inserted in the execution plan.
  • the deduplication operation instructions inserted can be used to obtain the results obtained after executing the target operation
  • the duplicate results contained in the query results are deduplicated, and the query data corresponding to the query statement is obtained from the database based on the deduplicated query results.
  • the server can determine the execution plan corresponding to the query statement entered by the user based on the order of execution of the query operations involved in the generated execution plan when the query statement is executed by the database, and based on the historical execution plan.
  • the query results of which query operations are deduplicated can reduce the task load of the database when performing subsequent query operations, and the query results of the determined query operations are deduplicated, thereby improving the efficiency of database query data.
  • Figure 3 is a schematic diagram of a data query device provided in this specification, including: an acquisition module 301, used to obtain a query sentence input by a user, the query sentence is used to query data from a database; a generation module 302, used to generate data according to the The query statement is used to generate an execution plan corresponding to the query statement; the first determination module 303 is used to determine each query operation involved in the execution plan and the order of execution of each query operation according to the execution plan; the second The determination module 304 is configured to determine a target operation from each of the query operations according to the order in which the query operations are executed.
  • the target operation is an operation other than the last query operation executed in each of the query operations; check Query module 305, configured to deduplicate duplicate results contained in the query results obtained by executing the target operation when executing the execution plan, and obtain the query corresponding to the query statement based on the deduplicated query results. data.
  • the generation module 302 is specifically configured to perform syntax analysis on the query statement to obtain a syntax tree corresponding to the query statement; and generate an execution plan corresponding to the query statement based on the syntax tree.
  • the second determination module 304 is specifically configured to determine whether there is a historical execution plan matching the execution plan in each historical execution plan; if not, based on the order in which each query operation is executed, from all historical execution plans Determine the target operation in each query operation described above.
  • the second determination module 304 is specifically configured to, if it is determined that there is a historical execution plan matching the execution plan in each historical execution plan, then based on the historical execution plan matching the execution plan, from the Determine the target operation in each query operation.
  • the second determination module 304 is specifically configured to, for each query operation involved in the execution plan, determine the query object corresponding to the query operation; according to the association between the query objects corresponding to each query operation relationship, as well as the order in which each query operation is executed, and the target operation is determined from each of the query operations.
  • the query module 305 is specifically configured to, according to the position of the operation instruction corresponding to the target operation in the execution plan, determine the position where the deduplication operation is inserted in the execution plan as the target position; according to the At the target position, insert a deduplication operation instruction in the execution plan to generate an optimized execution plan; when executing the optimized execution plan, according to the inserted deduplication operation instruction, the target operation will be obtained after executing the The duplicate results contained in the query results are deduplicated.
  • the query module 305 is specifically configured to determine the deduplication operation instructions included in the execution plan; and add the included deduplication operation instructions to the target location.
  • This specification also provides a computer-readable storage medium, which stores a computer program.
  • the computer program can be used to execute a data query method provided in Figure 1 above.
  • FIG. 4 This specification also provides a schematic structural diagram of the electronic device shown in FIG. 4 corresponding to FIG. 1 .
  • the electronic device includes a processor, internal bus, network interface, memory and non-volatile memory, and of course may also include other hardware required for business.
  • the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the data query method in Figure 1 above.
  • this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logical unit, and may also be hardware or logic device.
  • PLD Programmable Logic Device
  • FPGA Field Programmable Gate Array
  • HDL Hardware Description Language
  • HDL High-Speed Integrated Circuit Hardware Description Language
  • ABEL Advanced Boolean Expression Language
  • AHDL Advanced Boolean Expression Language
  • Confluence CUPL
  • HDCal Component Description Language
  • JHDL Java Hardware Description Language
  • Lava Lava
  • Lola MyHDL
  • PALASM RHDL
  • VHDL Very-High-Speed Integrated Circuit Hardware Description Language
  • Verilog Verilog
  • the controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (eg, software or firmware) executable by the (micro)processor. , logic gates, switches, Application Specific Integrated Circuit (ASIC), programmable logic controllers and embedded microcontrollers.
  • controllers include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, For Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the memory's control logic.
  • the controller in addition to implementing the controller in the form of pure computer-readable program code, the controller can be completely programmed with logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded logic by logically programming the method steps. Microcontroller, etc. to achieve the same function. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be considered as structures within the hardware component. Or even, the means for implementing various functions can be considered as structures within hardware components as well as software modules implementing the methods.
  • a typical implementation device is a computer.
  • computer examples For example, it may be a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any of these devices. Any combination of equipment.
  • embodiments of the present specification may be provided as methods, systems, or computer program products.
  • the present description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment that combines software and hardware aspects.
  • the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk memory, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • These computer program instructions may also be stored in a computer-readable memory that causes a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction means, the instructions
  • the device implements the functions specified in a process or processes of the flowchart and/or a block or blocks of the block diagram.
  • These computer program instructions may also be loaded onto a computer or other programmable data processing device, causing a series of operating steps to be performed on the computer or other programmable device to produce computer-implemented processing, thereby executing on the computer or other programmable device.
  • Instructions provide steps for implementing the functions specified in a process or processes of a flowchart diagram and/or a block or blocks of a block diagram.
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • Memory may include non-permanent storage in computer-readable media, random access memory (RAM), and/or non-volatile memory in the form of read-only memory (ROM) or flash memory (flash RAM).
  • RAM random access memory
  • ROM read-only memory
  • flash RAM flash memory
  • Computer-readable media includes both persistent and non-volatile, removable and non-removable media that can be implemented by any method or technology for storage of information.
  • Information may be computer-readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), and read-only memory.
  • PRAM phase change memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • RAM random access memory
  • read-only memory read-only memory
  • ROM read-only memory
  • EEPROM electrically erasable programmable read-only memory
  • flash memory or other memory technology
  • compact disc read-only memory CD-ROM
  • DVD digital versatile disc
  • Magnetic tape cassettes tape magnetic disk storage or other magnetic storage devices or any other non-transmission medium can be used to store information that can be accessed by a computing device.
  • computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
  • embodiments of the present specification may be provided as methods, systems, or computer program products.
  • the present description may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment that combines software and hardware aspects.
  • the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk memory, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types.
  • the present description may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through communications networks.
  • program modules may be located in both local and remote computer storage media including storage devices.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Computational Linguistics (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Fuzzy Systems (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本说明书公开了一种数据查询方法、装置、存储介质及电子设备,可以根据查询语句被数据库执行时,生成的执行计划所涉及的查询操作执行的先后顺序,确定出在执行计划中哪些查询操作的查询结果进行去重,可以减少数据库执行后续的查询操作时的任务量,并对确定出的查询操作的查询结果进行去重,从而可以提高数据库查询数据的效率。

Description

一种数据查询方法、装置、存储介质及电子设备 技术领域
本说明书涉及计算机技术领域,尤其涉及一种数据查询方法、装置、存储介质及电子设备。
背景技术
图数据库是目前被广泛使用的一种数据库,可以用于存储诸如隐私数据、业务数据等。在图数据库中,数据以节点和边的形式存储,从而便于描述数据实体之间的关联关系,例如:假设需要保存某公司员工的信息,则可以将该公司中的每个员工的信息,保存到各节点中(一个员工的信息保存到一个节点中),而任意两个员工之间的关系(例如:同事关系,领导关系等),则可以通过这两个员工对应的两个节点之间的边来表示。
然而目前用户需要在图数据库中查询数据时,往往查询数据的效率较低。
发明内容
本说明书提供一种数据查询方法、装置、存储介质及电子设备,以解决相关技术存在的数据库查询数据效率低的问题。
本说明书采用下述技术方案:本说明书提供了一种数据查询方法,包括:获取用户输入的查询语句,所述查询语句用于从数据库中查询数据;根据所述查询语句,生成所述查询语句对应的执行计划;根据所述执行计划,确定所述执行计划中涉及的各查询操作以及各查询操作执行的先后顺序;根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作,所述目标操作是除所述各查询操作中最后执行的查询操作以外的操作;在执行所述执行计划时,将执行所述目标操作得到的查询结果中包含的重复结果进行去重,并基于去重后的查询结果,得到所述查询语句对应的查询数据。
可选地,根据所述查询语句,生成所述查询语句对应的执行计划,具体包括:对所述查询语句进行语法解析,得到所述查询语句对应的语法树;根据所述语法树,生成所述查询语句对应的执行计划。
可选地,根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作,具体包括:判断各历史执行计划中是否存在与所述执行计划相匹配的历史执行计划;若 否,则根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作。
可选地,所述方法还包括:若判断各历史执行计划中存在与所述执行计划相匹配的历史执行计划,则根据与所述执行计划相匹配的历史执行计划,从所述各查询操作中确定目标操作。
可选地,根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作,具体包括:针对所述执行计划中所涉及的每个查询操作,确定该查询操作所对应的查询对象;根据每个查询操作对应的查询对象之间的关联关系,以及所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作。
可选地,在执行所述执行计划时,将执行所述目标操作得到的查询结果中包含的重复结果进行去重之前,还包括:根据所述目标操作对应的操作指令在所述执行计划中的位置,确定在所述执行计划中插入去重操作的位置,作为目标位置;根据所述目标位置,在所述执行计划中插入去重操作指令,以生成优化后执行计划;在执行所述执行计划时,将执行所述目标操作得到的查询结果中包含的重复结果进行去重,具体包括:在执行所述优化后执行计划时,根据插入的所述去重操作指令,将执行所述目标操作后得到的查询结果中包含的重复结果进行去重。
可选地,根据所述目标位置,在所述执行计划中插入去重操作指令,具体包括:确定所述执行计划中已包含的去重操作指令;将所述已包含的去重操作指令添加到所述目标位置。
本说明书提供了一种数据查询装置,包括:获取模块,用于获取用户输入的查询语句,所述查询语句用于从数据库中查询数据;生成模块,用于根据所述查询语句,生成所述查询语句对应的执行计划;确定模块,用于根据所述执行计划,确定所述执行计划中涉及的各查询操作以及各查询操作执行的先后顺序;优化模块,用于根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作,所述目标操作是除所述各查询操作中最后执行的查询操作以外的操作;查询模块,用于在执行所述执行计划时,将执行所述目标操作得到的查询结果中包含的重复结果进行去重,并基于去重后的查询结果,得到所述查询语句对应的查询数据。
本说明书提供了一种计算机可读存储介质,所述存储介质存储有计算机程序,所述计算机程序被处理器执行时实现上述数据查询方法。
本说明书提供了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理 器上运行的计算机程序,所述处理器执行所述程序时实现上述数据查询方法。
本说明书采用的上述至少一个技术方案能够达到以下有益效果:在本说明书提供的数据查询方法,首先获取用户输入的查询语句,查询语句用于从数据库中查询数据,根据查询语句,生成查询语句对应的执行计划,根据执行计划,确定执行计划中涉及的各查询操作以及各查询操作执行的先后顺序,根据各查询操作执行的先后顺序,从各查询操作中确定目标操作,其中,目标操作是除所述各查询操作中最后执行的查询操作以外的操作,在执行该执行计划时,将执行目标操作得到的查询结果中包含的重复结果进行去重,并基于去重后的查询结果,得到查询语句对应的查询数据。
从上述方法中可以看出,可以根据查询语句被数据库执行时,生成的执行计划所涉及的查询操作执行的先后顺序,确定出在执行计划中对哪些查询操作的查询结果进行去重,可以减少数据库执行后续的查询操作时的任务量,并对确定出的查询操作的查询结果进行去重,从而可以提高数据库查询数据的效率。
附图说明
此处所说明的附图用来提供对本说明书的进一步理解,构成本说明书的一部分,本说明书的示意性实施例及其说明用于解释本说明书,并不构成对本说明书的不当限定。在附图中:
图1为本说明书中提供的一种数据查询方法的流程示意图;
图2为本说明书中提供的数据库执行查询语句的过程示意图;
图3为本说明书提供的一种数据查询装置的示意图;
图4为本说明书提供的一种对应于图1的电子设备的示意图。
具体实施方式
为使本说明书的目的、技术方案和优点更加清楚,下面将结合本说明书具体实施例及相应的附图对本说明书技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本说明书保护的范围。
以下结合附图,详细说明本说明书各实施例提供的技术方案。
图1为本说明书中提供的一种数据查询方法的流程示意图,包括以下步骤S100至S108。
S100:获取用户输入的查询语句,所述查询语句用于从数据库中查询数据。
在实际应用中,数据库可以获取用户输入的查询语句,并根据用户输入的查询语句,生成执行计划,然后根据生成的执行计划,查询相应的数据,其中,查询语句可以是用户通过用户所使用的终端设备输入的查询语句。
在本说明书中,用于实现数据的查询方法的执行主体,可以是指部署有数据库的终端设备,诸如:台式电脑、笔记本电脑等终端设备,也可以是指服务器等指定设备,为了便于描述,下面仅以服务器是执行主体为例,对本说明书提供的数据的查询方法进行说明。
S102:根据所述查询语句,生成所述查询语句对应的执行计划。
S104:根据所述执行计划,确定所述执行计划中涉及的各查询操作以及各查询操作执行的先后顺序。
服务器在获取到用户输入的查询语句后,可以对查询语句进行语法解析,以得到所述查询语句对应的语法树(即,根据查询语句的句型进行句意推导的推导结果),然后通过执行计划生成器(数据库中的一个组件),根据解析出的语法树,生成查询语句对应的执行计划,其中,执行计划用于表示数据库在执行查询语句时的涉及的各查询操作以及各查询操作执行的先后顺序等。
例如:假设查询语句为“查询名称为A的用户的朋友的朋友所读过的书的名称”,数据库会先查询名称为A的用户的朋友有哪些,假设查询结果为B,C,然后数据库会继续查询B,C的朋友有哪些,进而图查询出读过的书名称为A的用户的朋友的朋友所读过的书有哪些,最终得到这些书的名称,这里的数据库执行这些查询操作,以及执行这些查询操作的先后顺序,即为一个执行计划。
需要说明的是,执行计划除了用于表示数据库在执行查询语句时的涉及的各查询操作以及各查询操作执行的先后顺序之外,还可以用于表示数据库执行这些查询操作的路径,以及执行这些查询操作的方法,例如:是否根据索引查询数据等。
从上述内容中可以看出,服务器在生成查询语句对应的执行计划后,可以确定出执行计划中涉及的各查询操作,以及各查询操作执行的先后顺序。
S106:根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作,所述目标操作是除所述各查询操作中最后执行的查询操作以外的操作。
服务器可以在根据执行计划,确定执行计划中涉及的各查询操作以及各查询操作执行的先后顺序之后,可以根据各查询操作执行的先后顺序,从各查询操作中确定出目标操作,其中,目标操作是执行计划中所涉及的除各查询操作中最后执行的查询操作以外的操作。
具体地,服务器可以针对执行计划中所涉及的每个查询操作,确定该查询操作所对应的查询对象,根据每个查询操作对应的查询对象之间的关联关系,以及各查询操作执行的先后顺序,从各查询操作中确定目标操作。
在上述内容中,根据每个查询操作对应的查询对象之间的关联关系,以及各查询操作执行的先后顺序,从各查询操作中确定目标操作的方法可以是,针对执行计划中所涉及的每个查询操作,根据各查询操作执行的先后顺序,确定出在执行该查询操作之前执行的上一个查询操作,判断该查询操作的查询对象是否直接依赖于上述的上一个查询操作的查询对象,例如:假设查询语句为“查询名称为A的人的朋友的朋友读过的书有哪些”时,涉及的查询操作有三个,第一个是“查询名称为A的人的朋友有哪些”,第二个是“名称为A的人的每个朋友的朋友有哪些”,第三个是“查询名称为A的人的每个朋友的朋友读过的书有哪些”,其中,名称为A的人的朋友的朋友读过的书有哪些是完全取决于名称为A的人的朋友的朋友有哪些的,因此,可以认为第三个查询操作完全依赖于第二个查询操作,即第一个查询操与第二个查询操作存在上述内容中的直接依赖关系,则此时可以认为第二个查询操作,即为目标操作。
上述内容中,服务器判断该查询操作的查询对象是否直接依赖于上述的上一个查询操作的查询对象的方法可以有很多,例如:服务器可以按照预先配置的条件,判断该查询操作是否满足于预设的条件,若是,则认为该查询操作的查询对象直接依赖于上述的上一个查询操作的查询对象,再例如:服务器可以通过对该查询操作的查询对象、以及上述的上一个查询操作的查询对象进行词法分析,进而可以确定出该查询操作的查询对象是否直接依赖于上述的上一个查询操作的查询对象。
除此之外,服务器还可以确定在执行计划中已包含的去重操作,根据每个查询操作对应的查询对象之间的关联关系,以及各查询操作执行的先后顺序,判断在各查询操作执行的先后顺序中在上述的已包含的去重操作对应的查询操作之前执行的上一个查询操作的查询对象,和上述的已包含的去重操作对应的查询操作的查询对象之间的关联关 系,确定在各查询操作执行的先后顺序中在上述的已包含的去重操作对应的查询操作之前执行的上一个查询操作,是否为目标操作。
从上述内容中可以看出,服务器可以对执行计划中所涉及的除各查询操作中最后执行的查询操作之前的查询操作的查询结果进行去重,从而可以基于去重后的查询结果,继续进行查询,以得到查询语句对应的查询数据,进而可以减少数据库执行查询语句时的任务量,提升数据执行查询语句的效率。
S108:在执行所述执行计划时,将执行所述目标操作得到的查询结果中包含的重复结果进行去重,并基于去重后的查询结果,得到所述查询语句对应的查询数据。
服务器在确定出目标操作后,可以在执行所述执行计划时,将执行目标操作得到的查询结果中包含的重复结果进行去重,并基于去重后的查询结果,得到查询语句对应的查询数据。
具体地,服务器在确定出目标操作后,可以根据目标操作对应的操作指令在执行计划中的位置,确定在执行计划中插入去重操作的位置,作为目标位置,进而可以根据目标位置,在执行计划中插入去重操作指令,以生成优化后执行计划,并将优化后执行计划保存到历史执行计划中,在执行优化后执行计划时,可以根据插入的去重操作指令,将执行目标操作后得到的查询结果中包含的重复结果进行去重。
其中,服务器在执行计划中插入去重操作指令的方法可以是,确定在执行计划中已包含的对查询操作的查询结果进行去重的去重操作是否为有效操作,可以理解为,若是,则将在执行计划中已包含的去重操作复制到目标位置中,若否,则将在执行计划中已包含的去重操作调整到目标位置中。
另外,为了利用对执行计划优化的历史信息,以进一步的提升数据库执行查询语句的查询效率,数据库在确定目标操作之前,可以先判断各历史执行计划中是否存在与执行计划相匹配的历史执行计划,若否,再根据各查询操作执行的先后顺序,从各查询操作中确定目标操作,若判断各历史执行计划中存在与执行计划相匹配的历史执行计划,则根据与执行计划相匹配的历史执行计划,从执行计划中涉及的各查询操作中确定目标操作。
在上述内容中,判断各历史执行计划中是否存在与该执行计划相匹配的历史执行计划的方法可以是,将该执行计划中的参数去除,进而可以判断在各历史执行计划中是否存在与去除参数后的执行计划一致的历史执行计划,若是,则认为与去除参数后的执行 计划一致的历史执行计划为与该执行计划相匹配的执行计划。
例如:假设执行计划为查询名称为A的用户的朋友,则去除参数后的执行计划为查询某用户的朋友,进而从各历史执行计划中,查找是否存在“查询某用户的朋友”,若存在,则认为这个历史执行计划与执行计划相匹配。
为了便于理解,本说明书还提供了执行计划的优化过程示意图,如图2所示。
图2为本说明书中提供的数据库执行查询语句的过程示意图。
从图2中可以看出,数据库在获取到用户输入的查询语句后,可以根据查询语句,生成该查询语句对应的执行计划,然后判断各历史执行计划中是否存在与生成的执行计划相匹配的历史执行计划,若是,则根据历史执行计划,确定需要进行去重操作的查询操作,作为目标操作,若否,则根据执行计划所涉及的各查询操作执行的先后顺序,确定在执行计划中需要进行去重操作的查询操作,作为目标操作,进而可以根据目标操作对应的操作指令在执行计划中的位置,确定在执行计划中插入去重操作的位置,进而可以在执行计划中插入去重操作指令,以生成优化后执行计划,并将优化后的执行计划保存到历史执行计划中,以在执行优化后的执行计划时,可以根据插入的去重操作指令,将执行所述目标操作后得到的查询结果中包含的重复结果进行去重,并根据执行去重后的查询结果,从数据库中得到所述查询语句对应的查询数据。
从上述内容中可以看出,服务器可以根据查询语句被数据库执行时,生成的执行计划所涉及的查询操作执行的先后顺序,以及根据历史执行计划,确定出在用户输入的查询语句对应的执行计划中哪些查询操作的查询结果进行去重,可以减少数据库执行后续的查询操作时的任务量,并对确定出的查询操作的查询结果进行去重,从而可以提高数据库查询数据的效率。
以上为本说明书的一个或多个实施例提供的数据查询方法,基于同样的思路,本说明书还提供了相应的数据查询装置,如图3所示。
图3为本说明书提供的一种数据查询装置的示意图,包括:获取模块301,用于获取用户输入的查询语句,所述查询语句用于从数据库中查询数据;生成模块302,用于根据所述查询语句,生成所述查询语句对应的执行计划;第一确定模块303,用于根据所述执行计划,确定所述执行计划中涉及的各查询操作以及各查询操作执行的先后顺序;第二确定模块304,用于根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作,所述目标操作是除所述各查询操作中最后执行的查询操作以外的操作;查 询模块305,用于在执行所述执行计划时,将执行所述目标操作得到的查询结果中包含的重复结果进行去重,并基于去重后的查询结果,得到所述查询语句对应的查询数据。
可选地,生成模块302具体用于,对所述查询语句进行语法解析,得到所述查询语句对应的语法树;根据所述语法树,生成所述查询语句对应的执行计划。
可选地,第二确定模块304具体用于,判断各历史执行计划中是否存在与所述执行计划相匹配的历史执行计划;若否,则根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作。
可选地,第二确定模块304具体用于,若判断各历史执行计划中存在与所述执行计划相匹配的历史执行计划,则根据与所述执行计划相匹配的历史执行计划,从所述各查询操作中确定目标操作。
可选地,第二确定模块304具体用于,针对所述执行计划中所涉及的每个查询操作,确定该查询操作所对应的查询对象;根据每个查询操作对应的查询对象之间的关联关系,以及所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作。
可选地,查询模块305具体用于,根据所述目标操作对应的操作指令在所述执行计划中的位置,确定在所述执行计划中插入去重操作的位置,作为目标位置;根据所述目标位置,在所述执行计划中插入去重操作指令,以生成优化后执行计划;在执行所述优化后执行计划时,根据插入的所述去重操作指令,将执行所述目标操作后得到的查询结果中包含的重复结果进行去重。
可选地,查询模块305具体用于,确定所述执行计划中已包含的去重操作指令;将所述已包含的去重操作指令添加到所述目标位置。
本说明书还提供了一种计算机可读存储介质,该存储介质存储有计算机程序,计算机程序可用于执行上述图1提供的一种数据查询方法。
本说明书还提供了图4所示的一种对应于图1的电子设备的示意结构图。如图4,在硬件层面,该电子设备包括处理器、内部总线、网络接口、内存以及非易失性存储器,当然还可能包括其他业务所需要的硬件。处理器从非易失性存储器中读取对应的计算机程序到内存中然后运行,以实现上述图1的数据查询方法。当然,除了软件实现方式之外,本说明书并不排除其他实现方式,比如逻辑器件抑或软硬件结合的方式等等,也就是说以下处理流程的执行主体并不限定于各个逻辑单元,也可以是硬件或逻辑器件。
在20世纪90年代,对于一个技术的改进可以很明显地区分是硬件上的改进(例如, 对二极管、晶体管、开关等电路结构的改进)还是软件上的改进(对于方法流程的改进)。然而,随着技术的发展,当今的很多方法流程的改进已经可以视为硬件电路结构的直接改进。设计人员几乎都通过将改进的方法流程编程到硬件电路中来得到相应的硬件电路结构。因此,不能说一个方法流程的改进就不能用硬件实体模块来实现。例如,可编程逻辑器件(Programmable Logic Device,PLD)(例如现场可编程门阵列(Field Programmable Gate Array,FPGA))就是这样一种集成电路,其逻辑功能由用户对器件编程来确定。由设计人员自行编程来把一个数字系统“集成”在一片PLD上,而不需要请芯片制造厂商来设计和制作专用的集成电路芯片。而且,如今,取代手工地制作集成电路芯片,这种编程也多半改用“逻辑编译器(logic compiler)”软件来实现,它与程序开发撰写时所用的软件编译器相类似,而要编译之前的原始代码也得用特定的编程语言来撰写,此称之为硬件描述语言(Hardware Description Language,HDL),而HDL也并非仅有一种,而是有许多种,如ABEL(Advanced Boolean Expression Language)、AHDL(Altera Hardware Description Language)、Confluence、CUPL(Cornell University Programming Language)、HDCal、JHDL(Java Hardware Description Language)、Lava、Lola、MyHDL、PALASM、RHDL(Ruby Hardware Description Language)等,目前最普遍使用的是VHDL(Very-High-Speed Integrated Circuit Hardware Description Language)与Verilog。本领域技术人员也应该清楚,只需要将方法流程用上述几种硬件描述语言稍作逻辑编程并编程到集成电路中,就可以很容易得到实现该逻辑方法流程的硬件电路。
控制器可以按任何适当的方式实现,例如,控制器可以采取例如微处理器或处理器以及存储可由该(微)处理器执行的计算机可读程序代码(例如软件或固件)的计算机可读介质、逻辑门、开关、专用集成电路(Application Specific Integrated Circuit,ASIC)、可编程逻辑控制器和嵌入微控制器的形式,控制器的例子包括但不限于以下微控制器:ARC 625D、Atmel AT91SAM、Microchip PIC18F26K20以及Silicone Labs C8051F320,存储器控制器还可以被实现为存储器的控制逻辑的一部分。本领域技术人员也知道,除了以纯计算机可读程序代码方式实现控制器以外,完全可以通过将方法步骤进行逻辑编程来使得控制器以逻辑门、开关、专用集成电路、可编程逻辑控制器和嵌入微控制器等的形式来实现相同功能。因此这种控制器可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置也可以视为硬件部件内的结构。或者甚至,可以将用于实现各种功能的装置视为既可以是实现方法的软件模块又可以是硬件部件内的结构。
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例 如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。
为了描述的方便,描述以上装置时以功能分为各种单元分别描述。当然,在实施本说明书时可以把各单元的功能在同一个或多个软件和/或硬件中实现。
本领域内的技术人员应明白,本说明书的实施例可提供为方法、系统、或计算机程序产品。因此,本说明书可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本说明书可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本说明书是参照根据本说明书实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的 示例。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括要素的过程、方法、商品或者设备中还存在另外的相同要素。
本领域技术人员应明白,本说明书的实施例可提供为方法、系统或计算机程序产品。因此,本说明书可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本说明书可以在由计算机执行的计算机可执行指令的一般上下文中描述,例如程序模块。一般地,程序模块包括执行特定任务或实现特定抽象数据类型的例程、程序、对象、组件、数据结构等等。也可以在分布式计算环境中实践本说明书,在这些分布式计算环境中,由通过通信网络而被连接的远程处理设备来执行任务。在分布式计算环境中,程序模块可以位于包括存储设备在内的本地和远程计算机存储介质中。
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
以上仅为本说明书的实施例而已,并不用于限制本说明书。对于本领域技术人员来说,本说明书可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本说明书的权利要求范围之内。

Claims (10)

  1. 一种数据查询方法,包括:
    获取用户输入的查询语句,所述查询语句用于从数据库中查询数据;
    根据所述查询语句,生成所述查询语句对应的执行计划;
    根据所述执行计划,确定所述执行计划中涉及的各查询操作以及各查询操作执行的先后顺序;
    根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作,所述目标操作是除所述各查询操作中最后执行的查询操作以外的操作;
    在执行所述执行计划时,将执行所述目标操作得到的查询结果中包含的重复结果进行去重,并基于去重后的查询结果,得到所述查询语句对应的查询数据。
  2. 如权利要求1所述的方法,根据所述查询语句,生成所述查询语句对应的执行计划,包括:
    对所述查询语句进行语法解析,得到所述查询语句对应的语法树;
    根据所述语法树,生成所述查询语句对应的执行计划。
  3. 如权利要求1所述的方法,根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作,包括:
    判断各历史执行计划中是否存在与所述执行计划相匹配的历史执行计划;
    若否,则根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作。
  4. 如权利要求3所述的方法,还包括:
    若判断各历史执行计划中存在与所述执行计划相匹配的历史执行计划,则根据与所述执行计划相匹配的历史执行计划,从所述各查询操作中确定目标操作。
  5. 如权利要求1所述的方法,根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作,包括:
    针对所述执行计划中所涉及的每个查询操作,确定该查询操作所对应的查询对象;
    根据每个查询操作对应的查询对象之间的关联关系,以及所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作。
  6. 如权利要求1所述的方法,在执行所述执行计划时,将执行所述目标操作得到的查询结果中包含的重复结果进行去重之前,还包括:
    根据所述目标操作对应的操作指令在所述执行计划中的位置,确定在所述执行计划中插入去重操作的位置,作为目标位置;
    根据所述目标位置,在所述执行计划中插入去重操作指令,以生成优化后执行计划;
    在执行所述执行计划时,将执行所述目标操作得到的查询结果中包含的重复结果进行去重,包括:
    在执行所述优化后执行计划时,根据插入的所述去重操作指令,将执行所述目标操作后得到的查询结果中包含的重复结果进行去重。
  7. 如权利要求6所述的方法,根据所述目标位置,在所述执行计划中插入去重操作指令,包括:
    确定所述执行计划中已包含的去重操作指令;
    将所述已包含的去重操作指令添加到所述目标位置。
  8. 一种数据查询装置,包括:
    获取模块,用于获取用户输入的查询语句,所述查询语句用于从数据库中查询数据;
    生成模块,用于根据所述查询语句,生成所述查询语句对应的执行计划;
    确定模块,用于根据所述执行计划,确定所述执行计划中涉及的各查询操作以及各查询操作执行的先后顺序;
    优化模块,用于根据所述各查询操作执行的先后顺序,从所述各查询操作中确定目标操作,所述目标操作是除所述各查询操作中最后执行的查询操作以外的操作;
    查询模块,用于在执行所述执行计划时,将执行所述目标操作得到的查询结果中包含的重复结果进行去重,并基于去重后的查询结果,得到所述查询语句对应的查询数据。
  9. 一种计算机可读存储介质,所述存储介质存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1~7任一项所述的方法。
  10. 一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现权利要求1~7任一项所述的方法。
PCT/CN2023/110634 2022-08-29 2023-08-01 一种数据查询方法、装置、存储介质及电子设备 WO2024046015A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211043590.7A CN115391426A (zh) 2022-08-29 2022-08-29 一种数据查询方法、装置、存储介质及电子设备
CN202211043590.7 2022-08-29

Publications (1)

Publication Number Publication Date
WO2024046015A1 true WO2024046015A1 (zh) 2024-03-07

Family

ID=84122487

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/110634 WO2024046015A1 (zh) 2022-08-29 2023-08-01 一种数据查询方法、装置、存储介质及电子设备

Country Status (2)

Country Link
CN (1) CN115391426A (zh)
WO (1) WO2024046015A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115391426A (zh) * 2022-08-29 2022-11-25 支付宝(杭州)信息技术有限公司 一种数据查询方法、装置、存储介质及电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111190924A (zh) * 2019-12-18 2020-05-22 中思博安科技(北京)有限公司 跨域的数据查询方法及装置
CN112860730A (zh) * 2021-03-29 2021-05-28 中信银行股份有限公司 Sql语句的处理方法、装置、电子设备及可读存储介质
CN113535753A (zh) * 2021-07-19 2021-10-22 北京人大金仓信息技术股份有限公司 一种基于并行遍历算法的sql语句执行计划定位方法和装置
US20220043817A1 (en) * 2020-08-06 2022-02-10 International Business Machines Corporation Multiplexing data operation
CN115391426A (zh) * 2022-08-29 2022-11-25 支付宝(杭州)信息技术有限公司 一种数据查询方法、装置、存储介质及电子设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111190924A (zh) * 2019-12-18 2020-05-22 中思博安科技(北京)有限公司 跨域的数据查询方法及装置
US20220043817A1 (en) * 2020-08-06 2022-02-10 International Business Machines Corporation Multiplexing data operation
CN112860730A (zh) * 2021-03-29 2021-05-28 中信银行股份有限公司 Sql语句的处理方法、装置、电子设备及可读存储介质
CN113535753A (zh) * 2021-07-19 2021-10-22 北京人大金仓信息技术股份有限公司 一种基于并行遍历算法的sql语句执行计划定位方法和装置
CN115391426A (zh) * 2022-08-29 2022-11-25 支付宝(杭州)信息技术有限公司 一种数据查询方法、装置、存储介质及电子设备

Also Published As

Publication number Publication date
CN115391426A (zh) 2022-11-25

Similar Documents

Publication Publication Date Title
US11314754B2 (en) Data processing method, apparatus, and device
TWI718375B (zh) 基於區塊鏈的資料處理方法及設備
CN107526777B (zh) 一种基于版本号对文件进行处理的方法及设备
US10169471B2 (en) Generating and executing query language statements from natural language
TWI706259B (zh) 資料的查詢方法及查詢裝置
US20180232438A1 (en) Title display method and apparatus
US20150161211A1 (en) Predictive query result computation
WO2020042804A1 (zh) 一种数据库查询优化方法、装置、及计算机设备
US20130110496A1 (en) Calculating Term Similarity Using A Meta-Model Semantic Network
WO2024046015A1 (zh) 一种数据查询方法、装置、存储介质及电子设备
WO2019085601A1 (zh) 一种任务执行的方法及装置
WO2024082787A1 (zh) 一种创建表空间的方法、装置、存储介质及电子设备
US9183065B1 (en) Providing access to an application programming interface through a named pipe
US20240126465A1 (en) Data storage methods, apparatuses, devices, and storage media
CN110245002A (zh) 系统交互方法、装置、设备及存储介质
WO2023151436A1 (zh) Sql语句风险检测
CN109656946B (zh) 一种多表关联查询方法、装置及设备
US20140280393A1 (en) Cached data validity
CN106156050B (zh) 一种数据处理方法及装置
KR102066330B1 (ko) 카테고리 디렉토리를 결정하기 위한 방법 및 디바이스와, 자동 분류 방법 및 디바이스
US20220300503A1 (en) Querying distributed databases
WO2024041301A1 (zh) 一种生成统一抽象语法树与程序分析的方法和装置
CN116521705A (zh) 一种数据查询方法、装置、存储介质及电子设备
CN111177141A (zh) 利用MySQL并行复制恢复数据方法、设备及系统
CN110008237B (zh) 一种相似查询识别方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23859050

Country of ref document: EP

Kind code of ref document: A1