WO2015188315A1 - Data query method, device and system - Google Patents
Data query method, device and system Download PDFInfo
- Publication number
- WO2015188315A1 WO2015188315A1 PCT/CN2014/079607 CN2014079607W WO2015188315A1 WO 2015188315 A1 WO2015188315 A1 WO 2015188315A1 CN 2014079607 W CN2014079607 W CN 2014079607W WO 2015188315 A1 WO2015188315 A1 WO 2015188315A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- relationship
- relationship tree
- tree
- query
- execution function
- Prior art date
- Legal status (The legal status 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 status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
Definitions
- the present invention relates to the field of computer technologies, and in particular, to a data query method, apparatus, and system.
- the current database query method is generally based on structured query language (English: Structured Query Language, referred to as: SQL) for query, the execution process of the query is: SQL query request
- SQL Structured Query Language
- the database system first converts the SQL query request into a relationship through syntax analysis. Tree, the raw data is obtained in the database through the relation tree, for example, table A, table B, Table C and Table D, through the relationship tree to determine the need to query data in Table A and Table B, then the table will be A and Table B are retrieved from the database as raw data.
- the execution function corresponding to the node queries the required query result in the original data.
- the existing SQL-based database query execution methods mainly include volcano model engine and column number According to the execution engine.
- the volcano model execution process is shown in Figure 1, and its query mode is to perform the relationship.
- the next function is called once, thus executing
- the execution function on a node until the execution function on the last relational node is executed
- the query results are finally obtained in the original data.
- the column data query engine execution process is shown in Figure 2.
- the database system receives the SQL query. After the request, the SQL query request is converted into a relation tree through syntax analysis, and the structure of the relationship tree is as shown in FIG. 2
- the process of executing the query is: first, the execution function on the first relation node in the relationship tree is retrieved. To perform a basetable operation, so as to filter out a column data and b column data in the database, for column a
- the data is subjected to a select operation to obtain the qualified a' column data, and the number of eligible a' columns is determined.
- the embodiment of the invention provides a data query method, device and system, which are used to solve the current problem The problem of slower query data in the database.
- a first aspect of the embodiments of the present invention provides a data query method, including:
- the pre-stored relationship tree set Determining a relationship tree that matches the query relationship tree, including:
- Traversing the pre-stored relationship tree set with the determined node locations of the relationship nodes and the relationship nodes Before the type matches the relationship tree it also includes:
- the total number of relationship nodes in the pre-stored relationship tree set is equal to the total number of determined relationship nodes.
- the filtered relationship tree is used as a pre-stored set of relationship trees to be traversed.
- determining in a pre-stored relationship tree set A relationship tree matching the query relationship tree including:
- the hash value is determined
- the obtained relationship tree of the query relationship tree has the same hash value as the matching relationship with the query relationship tree. Tie the tree.
- the execution function corresponding to the execution function template of the database is executed for the database Number, including:
- the database determines the raw data, which is the number that is not executed by the execution function template according to;
- the execution function module is retrieved. Determining an execution function template corresponding to the data feature in the board, and
- a second aspect of the embodiments of the present invention provides a data query apparatus, including:
- An obtaining module configured to obtain a query request for querying data in a database
- a conversion module configured to convert the query request into a corresponding query relationship tree, and pre-stored A relationship tree that matches the query relationship tree is determined in the relationship tree set, and the pre-stored relationship tree set
- the combination includes different relational trees obtained by converting different query requests
- a determining module configured to determine and describe according to a correspondence between a relationship tree and a relationship tree type The relationship tree type corresponding to the matching relationship tree;
- Retrieving a module for retrieving a correspondence between a relationship tree type and an execution function template An execution function template corresponding to the determined relationship tree type, wherein the execution function template includes An execution function for querying data on each relationship node in a relation tree of a corresponding type;
- An execution module configured to perform execution of the retrieved execution function template for the database Function, get the query result.
- the converting module includes:
- a determining unit configured to determine a node location of each relationship node in the query relationship tree, and each The type of the relationship node;
- a query unit configured to traverse the node bits of the pre-stored relationship tree set and the determined relationship nodes And a relationship tree matching the types of the relationship nodes, as a match with the query relationship tree Tie the tree.
- the conversion module further includes:
- a screening unit configured to traverse the pre-stored relationship tree set in the query unit with the determined relationship section
- the node location of the point and the relationship tree of the type of each relationship node match before the query relationship tree Determine the total number of relationship nodes, and filter out the total number of relationship nodes in the pre-stored relationship tree set and determine The relationship tree with the same total number of relational nodes, and the filtered relationship tree as the pre-stored traversal Tie tree collection.
- the determining module is specifically configured to Performing a hash calculation on the query relationship tree to obtain a hash value corresponding to the query relationship tree, and pre-storing In the correspondence between the relationship tree and the hash value corresponding to the relationship tree, the hash value and the obtained query are determined.
- the execution module is specifically configured to perform a retrieval on the database.
- the execution function corresponding to the function template is executed, the original data is determined in the database, the original The data is data that is not executed by the execution function template, and the number used to represent the original data is obtained.
- the data characteristics of the size according to the correspondence between the data features and the execution function template, Determining an execution function template corresponding to the data feature in the extracted execution function template, and for The original data executes an execution function corresponding to the execution function template corresponding to the data feature.
- a third aspect of the embodiments of the present invention provides a data query system, including:
- a memory for storing an execution function template and a database
- a processor for obtaining a query request for querying data in a database stored in the memory, Converting the query request into a corresponding query relationship tree, and determining in the pre-stored relationship tree set a relationship tree matching the query relationship tree, according to a correspondence between the relationship tree and the relationship tree type, Determining a relationship tree type corresponding to the matched relationship tree, according to the relationship tree type and the execution function module
- the correspondence between the boards, the execution function module corresponding to the determined relationship tree type is retrieved in the memory a board, executing an execution function corresponding to the execution function template for the database stored in the memory Number, get the query result.
- the processor is specifically configured to be used Determining the node position of each relation node in the query relationship tree, and the type of each relationship node, traversing The location of the node in the pre-stored relationship tree set and the determined relationship nodes and the type of each relationship node A matching relationship tree as a relationship tree that matches the query relationship tree.
- the processor is further configured to traverse the nodes of the determined relationship nodes in the pre-stored relationship tree set Before determining the location and the relationship tree of the types of the relationship nodes, determining in the query relationship tree The total number of relationship nodes is selected, and the total number of relationship nodes and the determined relationship are filtered out in the pre-stored relationship tree set. A relationship tree with the same number of nodes, and the filtered relationship tree as the pre-stored relationship tree set to be traversed Hehe.
- the processor is specifically used to
- the query relationship tree performs hash calculation, and obtains a hash value corresponding to the query relationship tree, which is pre-stored.
- the hash value is determined and the obtained check is obtained.
- the relationship tree of the relationship tree having the same hash value is used as a relationship tree matching the query relationship tree.
- the processor is specifically configured to perform a retrieval on the database.
- the row function template corresponds to the execution function
- the original data is determined in the database, the original number Acquiring data for characterizing the original data according to data that is not executed by the execution function template
- the size of the data feature according to the correspondence between the data characteristics and the execution function template, in the retrieval Determining an execution function template corresponding to the data feature in an execution function template, and for the original
- the start data executes an execution function corresponding to the execution function template corresponding to the data feature.
- the embodiment of the invention provides a data query method, in which the database system acquires After querying the query request for the data, determining the query relationship tree corresponding to the query request, and the query The type corresponding to the relationship tree, and finally the corresponding execution function module is retrieved according to the type of the query relationship tree.
- a board in the embodiment of the present invention, because the corresponding function tree is included in the execution function template The execution function used to query the data on each relational node, so as long as the execution function template is determined, The final query result can be obtained by executing the execution function corresponding to the execution function template, thereby It avoids the problem that the query speed is slow due to repeated call of the execution function in the existing data query process. This improves the speed of data queries and also saves network resources.
- FIG. 1 is a schematic diagram of a SQL data query mode in the prior art
- FIG. 2 is a schematic diagram of another SQL data query mode in the prior art
- FIG. 3 is a flowchart of a data query method according to an embodiment of the present invention.
- 4a is a schematic structural diagram of a relationship tree according to an embodiment of the present invention.
- 4b is a second schematic structural diagram of a relationship tree according to an embodiment of the present invention.
- 4c is a third schematic structural diagram of a relationship tree according to an embodiment of the present invention.
- 4d is a fourth schematic structural diagram of a relationship tree according to an embodiment of the present invention.
- 4e is a fifth structural diagram of a relationship tree according to an embodiment of the present invention.
- FIG. 5 is a schematic structural diagram of a data query apparatus according to an embodiment of the present invention.
- FIG. 6 is a schematic structural diagram of a conversion module according to an embodiment of the present invention.
- FIG. 7 is a schematic structural diagram of a data query system according to an embodiment of the present invention.
- a data query method in which a query request is After parsing, the relationship tree corresponding to the query request is obtained, and the class corresponding to the relationship tree is determined. Type, and then determine the execution function template corresponding to the type of the relationship tree, and finally determine the execution by execution.
- the row function template gets the final query result. This can correspond to a complete query request into a Execution function template, in which the node pair on the relationship tree of the corresponding type is included in the execution function template Should execute the function, thus avoiding the signaling that is caused by repeated calls to the execution function during the query process. Sales, increasing the speed of data queries.
- FIG. 3 is a flowchart of a data query method according to an embodiment of the present invention, where the method includes:
- the corresponding type of relationship tree is included in the relationship tree for querying The execution function of the data.
- the type corresponding to the tree for example, the relationship tree type corresponding to the relationship tree shown in Figure 4a is of the Select type.
- the relationship tree type corresponding to the relationship tree shown in Figure 4b is a Group type, and the relationship tree class shown in Figure 4c
- the type is a TOPN type
- the relationship tree type corresponding to the relationship tree shown in FIG. 4d is a TOPN_Group type.
- the relationship tree type corresponding to the relationship tree shown in Figure 4e is of the TOPN_NO_Group type, and the above five
- the relationship tree type is determined by the relationship node in the relationship tree, and of course not in the embodiment of the present invention.
- the definition can only define the relationship tree type through the relationship node. In the actual application, other types can be used.
- the implementation method to define the relationship tree type corresponding to the relationship tree is not exhaustive here.
- the database system When the database system receives the query request input by the user, the database system will request the query. Semantic analysis is performed to obtain a query relationship tree corresponding to the query request.
- the query request received by the database system is "from the table T, the number of columns is greater than 5 Data"
- you can get the SQL statement namely: Select A from T, where A>5.
- each relationship section in the relationship tree can be obtained.
- Point, and each relationship node performs filtering according to the corresponding execution function, firstly Basetable
- the relational node and the execution filtering operation corresponding to the Basetable relational node are to find the table T from the database. Since the table T has not undergone any processing, the table T is the original data, and the need to explain here is:
- the initial data is extracted from the database, and the table T is not sorted by data, data filtered, data Update and other processing.
- the Select relationship node the corresponding filtering operation corresponding to the Select relationship node is in the table T Filter out the data with column number greater than 5; finally, the function of Project relationship node and Project relationship node Is to get the final query result, according to these relationship nodes can get the corresponding query of the query request
- the relationship tree is consulted, and the query relationship tree is the relationship tree shown in Figure 4a.
- the relationship nodes correspond to their own types.
- the database system After obtaining the query relationship tree, the database system will analyze the tree structure of the query relationship tree.
- the structural feature characterizes the type of each relational node in the query relationship tree and the relationship node is inspected. Ask for the location of the node in the relationship tree.
- the relationship tree corresponding to the query request is the query relationship tree shown in FIG. 4a
- the query relationship is
- the relation node corresponding to the tree head in the tree is the "Basetable” relation node, and the tree header represents “Basetable”
- the location of the relational node in the query relationship tree, "Basetable” represents the type of the relational node
- the relationship node in the tree after the "Basetable” relationship node is the "Select” relationship node, "Select” Represents the type of relational node
- the relational node corresponding to the end of the tree is the "Project" relational node, "Project” Characterizes the type of the relational node, by querying the relationship node in the query relationship tree in the query relationship tree
- the location and the type of each relationship node can be used to obtain the tree structure feature corresponding to the query relationship tree.
- the system After the system gets the tree structure feature of the query relationship tree, the system will get the query relationship tree.
- the tree structure features are matched with the tree structure features of the pre-stored relationship tree in the system.
- the tree structure feature matching of the phylogenetic tree is the type of the relational node and the node location in the query relationship tree. Match the type of each relationship node in the pre-stored relationship tree set with the node location.
- the relationship node of the tree head of the query relationship tree is queried.
- the relationship node after the tree header is Select
- the tree tail node is Project
- the database system is The system will determine whether to save the tree with the query relationship tree shown in Figure 4a in the pre-stored relationship tree set.
- a relational tree with the same structural characteristics if there is a tree structure with a query relationship tree in the database system If the relationship tree has the same characteristics, the database system determines that the relationship tree type corresponding to the relationship tree is The Select type, that is, the relation tree type of the query relationship tree is of the Select type.
- the data The library system can pass the total number of relational nodes in the relationship tree before performing tree structure feature matching.
- a part of the relationship tree is initially selected in the pre-stored relationship tree set.
- the total number of nodes in the pre-stored relationship tree set is equal to the total number of relationship nodes in the query relationship tree.
- the phylogenetic tree for example, the total number of relational nodes in the query relationship tree is three, and the database system will be pre-stored.
- the relationship tree the relationship tree with 3 total number of relation nodes is traversed.
- the filtered relationship tree is preliminary. The filtered relationship tree cannot be used as a relationship tree that matches the query relationship tree.
- the node locations of the relationship nodes of the query relationship tree are filtered out. And a relationship tree in which the types of the relationship nodes match. This way you can avoid having to query the relationship tree
- the node location of the relational node and the type of each relational node and each relationship in the pre-stored relational tree set The node position of the tree and the type of the relationship node are matched, thereby reducing the number of matches and improving The speed and efficiency of data queries.
- each type of relationship tree is pre-stored in the database system, such as Select. Type relationship tree, Group type relationship tree, TOPN type relationship tree, etc.
- a type of relationship tree performs hash calculation to obtain a hash value corresponding to each type of relationship tree, After saving each type of relationship tree in the database system and corresponding to each type of relationship tree Hash value.
- the query relationship tree corresponding to the query request After obtaining the query relationship tree corresponding to the query request, performing a hash calculation on the query relationship tree, Thereby obtaining a hash value corresponding to the query relationship tree, and then according to the hash value of the query relationship tree and the advance
- the stored hash value is matched, if there is a hash value in the database system and the query relationship tree
- the type of the relation tree corresponding to the hash value is used as the type of the query relationship tree.
- the correspondence between the relationship tree type and the hash value shown in Table 1 is stored in the database system:
- Hash value Relationship tree type a Select type b Group type c TOPN type
- the query relationship tree The type is the Select type, and the relation tree corresponding to the Select type is the relationship tree shown in Figure 4a. If the hash value of the query relationship tree is b, the type of the query relationship tree is the Group type, and the group The relationship tree corresponding to the type is the relationship tree shown in Figure 4b. If the hash value of the query relationship tree is c, Then, the type of the query relationship tree is the TOPN type, and the relationship tree corresponding to the TOPN type is as shown in FIG. 4c. The relationship tree shown.
- the hash value of the query relationship tree and the hash value pre-stored in the database system are When there is a hash conflict between them, it is also necessary to determine the query based on the tree structure characteristics of the query relationship tree. The type corresponding to the tree.
- the query relationship tree is hashed after the hash function is calculated and the hash in Table 1. If the value a has a hash conflict, then the relationship tree corresponding to the hash value a is determined, and then the tree of the relationship tree is queried. The structural feature of the shape is matched with the tree structure feature of the relation tree corresponding to the hash value a, if the query is off. The tree structure characteristic of the relationship tree corresponding to the hash value a is matched, and the relation tree corresponding to the hash value a The type of the query relationship tree, if it does not match, it is determined that the query relationship tree has no match. Relationship tree.
- the system will retrieve the pre-stored relationship tree.
- the correspondence between the type and the execution function template specifically, pre-stored in the database system a correspondence table between each type of relationship tree and an execution function template, the correspondence table may But not limited to Table 2:
- the database system After determining the execution function template, the database system will execute the determined execution function template Corresponding execution function, so as to query the required query result in the database.
- the board contains the execution function corresponding to each node in the relation tree of the corresponding type, that is, executed.
- the determined execution function template is equivalent to executing each node on the corresponding type of relationship tree. Executing the function, so in the embodiment of the present invention, therefore, the data query process no longer needs to be repeated. Retrieve the execution function, which improves the speed and efficiency of data query, and also saves system resources source.
- a type of relationship tree may correspond to multiple execution function modules. Board, so if you can't accurately determine an execution function template by the type of the relationship tree, then The execution function template can be further determined in conjunction with the data characteristics of the original data, where the original number is According to the data that is not executed by the function template found in the database, such as query request To "query data from column T with columns greater than 5", in response to the query request, the first is the number According to the table T found in the library, when the table T is found, the database system does not have a table T Do any processing, so the table T is the original data.
- the data characteristics include at least the amount of data of the original data, and the column data to be searched in the original data.
- Type one of the attributes of the column data to be searched in the original data, or a plurality of numbers
- the attributes of the column data represent whether the column data in the original data is sorted or Whether the column data in the original data is a loop data or the like.
- the amount of data of the original data is used, that is, the query relationship
- the data size of the original data is determined, and then pre-stored according to the data.
- determining the amount of data corresponding to the original data Execution function template is used.
- the relationship tree of the Group type corresponds to 3 different execution function templates, and 3 types are not.
- There is a correspondence between the same execution function template and the data size of the original data namely: the original number
- the execution function template corresponding to the data size of 1 byte, 2 bytes, and 3 bytes is Do_bte_group, do_sht_group, do_hash_group; therefore, the query relationship tree is determined to be a Group Type
- the database system will further determine the amount of data of the original data, if it is the original number
- the execution function template is do_bte_group, if it is the number of original data.
- the execution function template is do_sht_group.
- the type of the relationship tree cannot be accurately determined by executing the function template, it can be further based on The amount of data of the original data to determine the execution function template, and finally further determined by execution
- the execution function corresponding to the execution function template accurately queries the result of the query.
- an embodiment of the present invention further provides a The device for querying data, as shown in FIG. 5 is a structural diagram of a data query device according to an embodiment of the present invention. Intended, the device includes:
- An obtaining module 501 configured to acquire a query request for querying data in a database
- the conversion module 502 is configured to convert the query request into a corresponding query relationship tree, and pre-store Determining a relationship tree matching the query relationship tree in the relationship tree set, the pre-stored relationship tree
- the set includes different relation trees obtained by converting different query requests;
- a determining module 503 configured to determine, according to a correspondence between the relationship tree and the relationship tree type, The relationship tree type corresponding to the matching relationship tree;
- the calling module 504 is configured to adjust according to the correspondence between the relationship tree type and the execution function template Taking an execution function template corresponding to the determined relationship tree type, wherein the execution function template includes a package An execution function for querying data on each relational node in the relation tree of the corresponding type;
- An execution module 505 configured to execute the retrieved execution function template for the database The line function gets the result of the query.
- the conversion module 502 includes:
- a determining unit 601 configured to determine a node location of each relationship node in the query relationship tree, and The type of each relationship node;
- the query unit 602 is configured to traverse the nodes of the pre-stored relationship tree set and the determined relationship nodes a relationship tree matching the location and the type of each relationship node as a match with the query relationship tree Relationship tree.
- the conversion module 502 further includes:
- the screening module 603 is disposed between the determining module 601 and the query module 602, and is configured to perform the check Determine the total number of relationship nodes in the query relationship tree, and filter out the total relationship nodes in the pre-stored relationship tree set.
- a relationship tree whose number is equal to the total number of determined relationship nodes, and the filtered relationship tree is used as the traversal Pre-stored relationship tree collection.
- the determining module 503 in the device is further configured to perform a hash calculation on the query relationship tree. Calculating, obtaining a hash value corresponding to the query relationship tree, corresponding to the pre-stored relationship tree and the relationship tree In the correspondence between the hash values, a relationship tree having the same hash value as the hash value of the query relationship tree is determined, As a relationship tree that matches the query relationship tree.
- the execution module 505 in the device is specifically configured to perform the retrieval on the database.
- the execution function corresponding to the execution function template is executed, the original data is determined in the database, The raw data is data that is not executed by the execution function template, and is acquired to represent the original data.
- the data characteristics of the data size according to the correspondence between the data characteristics and the execution function template, Determining an execution function template corresponding to the data feature in the retrieved execution function template, and targeting The original data executes an execution function corresponding to the execution function template corresponding to the data feature.
- a data query system is further provided, as shown in FIG. Schematic diagram of the system, the system includes:
- a memory 701 configured to store an execution function template and data to be queried
- the processor 702 is configured to obtain a query request for querying data in a database, where the query is The request is converted into a corresponding query relationship tree, and the query is determined in the pre-stored relationship tree set The relationship tree matched by the relationship tree is determined according to the correspondence between the relationship tree and the relationship tree type.
- the relationship tree type corresponding to the matching relationship tree, according to the relationship between the relationship tree type and the execution function template Corresponding relationship, extracting an execution function template corresponding to the determined relationship tree type, for the database Execute the execution function corresponding to the executed execution function template to obtain the query result.
- the processor 702 is specifically configured to determine a section of each relationship node in the query relationship tree. Point location, and the type of each relationship node, traversing the pre-existing relationship tree set with the determined relationships The node location of the node and the relationship tree of the types of the relationship nodes match as the query A tree that matches the tree.
- the processor 702 is further configured to determine a total number of relationship nodes in the query relationship tree.
- the total number of relationship nodes is selected to be equal to the total number of determined relationship nodes.
- the tree is used to use the filtered relationship tree as a pre-stored set of relationship trees to be traversed.
- the processor 702 is further configured to perform hash calculation on the query relationship tree to obtain a The hash value corresponding to the query relationship tree, and the correspondence between the pre-stored relationship tree and the hash value corresponding to the relationship tree In the relationship, a relationship tree having the same hash value as the hash value of the query relationship tree is determined as the context The relationship tree in which the query relationship tree is matched.
- the processor 702 is specifically configured to execute an execution function for the database.
- the execution function corresponding to the template When the execution function corresponding to the template is used, the original data is determined in the database, and the original data is The data that is not executed by the execution function template acquires a large amount of data used to represent the original data. Small data features, according to the correspondence between the data features and the execution function template, are retrieved Determining an execution function template corresponding to the data feature in an execution function template, and for the original number The execution function corresponding to the execution function template corresponding to the data feature is executed.
- the present invention is directed to a method, apparatus (system), and computer program according to an embodiment of the present invention.
- the flow chart and/or block diagram of the product is described. It should be understood that the flow chart can be implemented by computer program instructions And/or each flow and/or block in the block diagram, and the flow in the flowchart and/or block diagram And/or a combination of boxes.
- These computer program instructions can be provided to a general purpose computer, a special purpose computer, An embedded processor or processor of another programmable data processing device to generate a machine Instructions executed by a processor of a computer or other programmable data processing device are generated for implementation in the stream a process or a process and/or a block diagram of a function specified in a box or blocks Device.
- These computer program instructions can also be stored in a bootable computer or other programmable data processing device.
- a computer readable memory that operates in a particular manner such that it is stored in the computer readable memory
- the instruction in the production includes an article of manufacture of the instruction device, the instruction device being implemented in a flow of the flowchart or Multiple processes and/or block diagrams The functions specified in one or more boxes.
- These computer program instructions can also be loaded onto a computer or other programmable data processing device. Enabling a series of operational steps on a computer or other programmable device to produce a computer implemented Processing instructions that are executed on a computer or other programmable device are provided for implementation in the flowchart a step in a process or multiple processes and/or block diagrams of a function specified in a box or blocks Step.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
本发明涉及计算机技术领域,尤其涉及一种数据查询方法、装置及系统。 The present invention relates to the field of computer technologies, and in particular, to a data query method, apparatus, and system.
当前,在数据仓库与在线联机分析处理(英文:Online Analytical Processing,简称:OLPA)领域来讲,数据的查询速度尤为重要。在OLAP领 域,数据库查询过程需要遍历较大的数据量才能完成查询,在如此大的数据 量下,若还需要数据库查询有较快的响应,这样就对数据库处理性能提出很 大挑战。 Currently, in data warehousing and online online analytical processing (English: Online Analytical Processing, referred to as: OLPA), the speed of data query is particularly important. At the OLAP collar Domain, the database query process needs to traverse a large amount of data to complete the query, in such a large data Under the amount, if you need a database query to have a faster response, this will be very good for database processing performance. Big challenge.
当前的数据库查询方式一般都是基于结构化查询语言(英文:Structured Query Language,简称:SQL)进行查询,查询的执行过程为:SQL查询请求 进入数据库系统后,数据库系统先将SQL查询请求通过语法分析后转换成关系 树,通过关系树在数据库中得到原始数据,比如说数据库中存在表A、表B、 表C以及表D,通过关系树中确定出需要在表A和表B中查询数据,此时就将表 A和表B从数据库中调取出来作为原始数据。 The current database query method is generally based on structured query language (English: Structured Query Language, referred to as: SQL) for query, the execution process of the query is: SQL query request After entering the database system, the database system first converts the SQL query request into a relationship through syntax analysis. Tree, the raw data is obtained in the database through the relation tree, for example, table A, table B, Table C and Table D, through the relationship tree to determine the need to query data in Table A and Table B, then the table will be A and Table B are retrieved from the database as raw data.
再通过调用关系树上关系节点对应的执行函数,最后按照次序执行关系 节点对应的执行函数在原始数据中查询出需要的查询结果。 Then by calling the execution function corresponding to the relational node on the relation tree, and finally executing the relationship in order The execution function corresponding to the node queries the required query result in the original data.
现有的基于SQL的数据库查询的执行方式主要有火山模型引擎与列式数 据执行引擎。其中,火山模型执行过程如图1所示,其查询模式为执行了关系 树上的一个关系节点对应的执行函数之后,将调用一次next函数,从而执行下 一个节点上的执行函数,直至最后一个关系节点上的执行函数被执行完毕为 止,最后在原始数据中得到查询结果。这样在关系树上的关系节点较多时, 依次调用各个关系节点上的执行函数,使得调用开销将非常大,查询速度较 慢。 The existing SQL-based database query execution methods mainly include volcano model engine and column number According to the execution engine. Among them, the volcano model execution process is shown in Figure 1, and its query mode is to perform the relationship. After the execution function corresponding to a relational node on the tree, the next function is called once, thus executing The execution function on a node until the execution function on the last relational node is executed Finally, the query results are finally obtained in the original data. Thus, when there are more relationship nodes in the relationship tree, Calling the execution function on each relational node in turn, the call overhead will be very large, and the query speed is higher. slow.
列式数据查询引擎执行过程如图2所示,数据库系统接收到SQL查询请 求后,经过语法解析将SQL查询请求转换成关系树,关系树的结构如图2所 示,执行查询的过程为:首先调取关系树中第一个关系节点上的执行函数, 来执行basetable操作,从而在数据库中筛选出a列数据和b列数据,对a列 数据进行select操作,从而得到符合条件的a’列数据,并将符合条件的a’列数 据暂时保存在缓存中;然后进入下一个关系节点,调取并执行该节点上的执 行函数,以将符合条件的a’列数据与b列数据进行fetchjoin操作获得符合条 件的b’列数据,将符合条件的b’列数据暂时保存在缓存中;然后再进入下一 个关系节点,调取并执行该节点上的执行函数,以将符合条件的a’列数据与 符合条件的b’列数据进行group聚集操作得出查询结果。这种列式数据查询 引擎执行方式的主要缺点为:要分别调取每一个关系节点上的执行函数,并 且将执行每个执行函数得到的符合条件的列数据都会在内存中进行缓存,这 样不仅导致了查询速度较慢,并且会占用大量的内存。 The column data query engine execution process is shown in Figure 2. The database system receives the SQL query. After the request, the SQL query request is converted into a relation tree through syntax analysis, and the structure of the relationship tree is as shown in FIG. 2 The process of executing the query is: first, the execution function on the first relation node in the relationship tree is retrieved. To perform a basetable operation, so as to filter out a column data and b column data in the database, for column a The data is subjected to a select operation to obtain the qualified a' column data, and the number of eligible a' columns is determined. Temporarily saved in the cache; then enter the next relational node, retrieve and execute the execution on the node Row function to fetchjoin operation of the qualified a' column data and b column data to obtain a matching bar The b' column data of the piece temporarily stores the eligible b' column data in the cache; then proceeds to the next Relational nodes, retrieve and execute the execution function on the node to match the qualified a' column data with The qualified b' column data is subjected to a group aggregation operation to obtain a query result. This columnar data query The main disadvantage of the engine execution mode is that you need to retrieve the execution function on each relational node separately, and And the eligible column data obtained by executing each execution function will be cached in memory. Not only does it cause slower queries, but it also consumes a lot of memory.
所以不管使用火山模型执行引擎或者是列式数据执行引擎都存在数据查 询速度较慢的问题。 So whether you use the volcano model execution engine or the column data execution engine, there is data check. Ask for a slower question.
发明内容Summary of the invention
本发明实施例提供了一种数据查询方法、装置及系统,用以解决当前在 数据库中查询数据速度较慢的问题。 The embodiment of the invention provides a data query method, device and system, which are used to solve the current problem The problem of slower query data in the database.
其具体的技术方案如下: The specific technical solutions are as follows:
本发明实施例第一方面提供了一种数据查询方法,包括: A first aspect of the embodiments of the present invention provides a data query method, including:
获取用于在数据库中查询数据的查询请求; Obtain a query request for querying data in the database;
将所述查询请求转换为对应的查询关系树,并在预存的关系树集合中确 定出与所述查询关系树匹配的关系树,所述预存的关系树集合中包括对不同 查询请求转换得到的不同关系树; Converting the query request into a corresponding query relationship tree, and in the pre-stored relationship tree set Determining a relationship tree matching the query relationship tree, where the pre-stored relationship tree set includes different pairs Query the different relationship trees obtained by the request conversion;
根据关系树与关系树类型之间的对应关系,确定与所述匹配的关系树对 应关系树类型; Determining a relationship tree pair with the matching according to a correspondence between the relationship tree and the relationship tree type Should be related to the tree type;
根据关系树类型与执行函数模板之间的对应关系,调取与确定的关系树 类型对应的执行函数模板,其中,所述执行函数模板中包含了对应类型的关 系树中各关系节点上用于查询数据的执行函数; Retrieving and determining the relationship tree according to the correspondence between the relationship tree type and the execution function template An execution function template corresponding to the type, wherein the execution function template includes a corresponding type of An execution function for querying data on each relationship node in the system tree;
针对所述数据库执行调取出的执行函数模板对应的执行函数,得到查询 结果。 Executing an execution function corresponding to the execution function template of the retrieved database for the database, and obtaining a query result.
结合第一方面,在第一种可能的实现方式中,在预存的关系树集合中确 定出与所述查询关系树匹配的关系树,包括: In combination with the first aspect, in the first possible implementation, in the pre-stored relationship tree set Determining a relationship tree that matches the query relationship tree, including:
确定所述查询关系树中各关系节点的节点位置,以及各关系节点的类型; Determining a node location of each relationship node in the query relationship tree, and a type of each relationship node;
遍历预存的关系树集合中与确定的各关系节点的节点位置以及各关系节 点的类型相匹配的关系树,作为与所述查询关系树匹配的关系树。 Traversing the node locations of the pre-stored relationship tree sets and the determined relationship nodes and the relationship sections A relationship tree in which the types of points match, as a relationship tree matching the query relationship tree.
结合第一方面中的第一种可能的实现方式,在第二种可能的实现方式中, 在遍历预存的关系树集合中与确定的各关系节点的节点位置以及各关系节点 的类型相匹配的关系树前,还包括: In conjunction with the first possible implementation in the first aspect, in a second possible implementation, Traversing the pre-stored relationship tree set with the determined node locations of the relationship nodes and the relationship nodes Before the type matches the relationship tree, it also includes:
在所述查询关系树中确定出关系节点总数; Determining the total number of relationship nodes in the query relationship tree;
在预存的关系树集合中筛选出关系节点总数与确定的关系节点总数相等 的关系树; The total number of relationship nodes in the pre-stored relationship tree set is equal to the total number of determined relationship nodes. Relationship tree
将筛选出的关系树,作为要遍历的预存的关系树集合。 The filtered relationship tree is used as a pre-stored set of relationship trees to be traversed.
结合第一方面,第三种可能的实现方式中,在预存的关系树集合中确定 出与所述查询关系树匹配的关系树,包括: In combination with the first aspect, in a third possible implementation manner, determining in a pre-stored relationship tree set A relationship tree matching the query relationship tree, including:
对所述查询关系树进行哈希计算,得到所述查询关系树对应的哈希值; Performing a hash calculation on the query relationship tree to obtain a hash value corresponding to the query relationship tree;
在预存的关系树与关系树对应的哈希值的对应关系中,确定出哈希值与 得到的查询关系树的哈希值相同的关系树,作为与所述查询关系树匹配的关 系树。 In the correspondence between the pre-stored relationship tree and the hash value corresponding to the relationship tree, the hash value is determined The obtained relationship tree of the query relationship tree has the same hash value as the matching relationship with the query relationship tree. Tie the tree.
结合第一方面或者第一方面中的第一种可能的实现方式或者第一方面中 第二种可能的实现方式或者第一方面中第三种可能的实现方式,在第四种可 能的实现方式中,针对所述数据库执行调取出的执行函数模板对应的执行函 数,包括: Combining the first aspect or the first possible implementation of the first aspect or the first aspect The second possible implementation or the third possible implementation of the first aspect, in the fourth In an implementation manner, the execution function corresponding to the execution function template of the database is executed for the database Number, including:
在针对所述数据库执行调取出的执行函数模板对应的执行函数时,在所 述数据库确定出原始数据,所述原始数据为未被所述执行函数模板执行的数 据; When performing an execution function corresponding to the execution function template of the retrieved database for the database, The database determines the raw data, which is the number that is not executed by the execution function template according to;
获取用以表征所述原始数据的数据量大小的数据特征; Obtaining data features for characterizing the amount of data of the original data;
根据数据特征与执行函数模板之间的对应关系,在调取出的执行函数模 板中确定出所述数据特征对应的执行函数模板,并 According to the correspondence between the data features and the execution function template, the execution function module is retrieved. Determining an execution function template corresponding to the data feature in the board, and
针对所述原始数据执行所述数据特征对应的执行函数模板对应的执行函 数。 Executing an execution function corresponding to the execution function template corresponding to the data feature for the original data number.
本发明实施例第二方面提供了一种数据查询装置,包括: A second aspect of the embodiments of the present invention provides a data query apparatus, including:
获取模块,用于获取用于在数据库中查询数据的查询请求; An obtaining module, configured to obtain a query request for querying data in a database;
转换模块,用于将所述查询请求转换为对应的查询关系树,并在预存的 关系树集合中确定出与所述查询关系树匹配的关系树,所述预存的关系树集 合中包括对不同的查询请求转换得到的不同关系树; a conversion module, configured to convert the query request into a corresponding query relationship tree, and pre-stored A relationship tree that matches the query relationship tree is determined in the relationship tree set, and the pre-stored relationship tree set The combination includes different relational trees obtained by converting different query requests;
确定模块,用于根据关系树与关系树类型之间的对应关系,确定与所述 匹配的关系树对应的关系树类型; a determining module, configured to determine and describe according to a correspondence between a relationship tree and a relationship tree type The relationship tree type corresponding to the matching relationship tree;
调取模块,用于根据关系树类型与执行函数模板之间的对应关系,调取 与确定的关系树类型对应的执行函数模板,其中,所述执行函数模板中包含 了对应类型的关系树中各关系节点上用于查询数据的执行函数; Retrieving a module for retrieving a correspondence between a relationship tree type and an execution function template An execution function template corresponding to the determined relationship tree type, wherein the execution function template includes An execution function for querying data on each relationship node in a relation tree of a corresponding type;
执行模块,用于针对所述数据库执行调取出的执行函数模板对应的执行 函数,得到查询结果。 An execution module, configured to perform execution of the retrieved execution function template for the database Function, get the query result.
结合第二方面,在第一种可能的实现方式中,所述转换模块,包括: With reference to the second aspect, in a first possible implementation, the converting module includes:
确定单元,用于确定所述查询关系树中各关系节点的节点位置,以及各 关系节点的类型; a determining unit, configured to determine a node location of each relationship node in the query relationship tree, and each The type of the relationship node;
查询单元,用于遍历预存的关系树集合中与确定的各关系节点的节点位 置以及各关系节点的类型相匹配的关系树,作为与所述查询关系树匹配的关 系树。 a query unit, configured to traverse the node bits of the pre-stored relationship tree set and the determined relationship nodes And a relationship tree matching the types of the relationship nodes, as a match with the query relationship tree Tie the tree.
结合第二方面中的第一种可能的实现方式,在第二种可能的实现方式中, 所述转换模块,还包括: In conjunction with the first possible implementation in the second aspect, in a second possible implementation, The conversion module further includes:
筛选单元,用于在查询单元遍历预存的关系树集合中与确定的各关系节 点的节点位置以及各关系节点的类型相匹配的关系树前,在所述查询关系树 中确定出关系节点总数,在预存的关系树集合中筛选出关系节点总数与确定 的关系节点总数相等的关系树,将筛选出的关系树,作为要遍历的预存的关 系树集合。 a screening unit, configured to traverse the pre-stored relationship tree set in the query unit with the determined relationship section The node location of the point and the relationship tree of the type of each relationship node match before the query relationship tree Determine the total number of relationship nodes, and filter out the total number of relationship nodes in the pre-stored relationship tree set and determine The relationship tree with the same total number of relational nodes, and the filtered relationship tree as the pre-stored traversal Tie tree collection.
结合第二方面,第三种可能的实现方式中,所述确定模块,具体用于对 所述查询关系树进行哈希计算,得到所述查询关系树对应的哈希值,在预存 的关系树与关系树对应的哈希值的对应关系中,确定出哈希值与得到的查询 关系树的哈希值相同的关系树,作为与所述查询关系树匹配的关系树。 With reference to the second aspect, in a third possible implementation manner, the determining module is specifically configured to Performing a hash calculation on the query relationship tree to obtain a hash value corresponding to the query relationship tree, and pre-storing In the correspondence between the relationship tree and the hash value corresponding to the relationship tree, the hash value and the obtained query are determined. A relationship tree with the same hash value of the relationship tree as a relationship tree matching the query relationship tree.
结合第二方面或者第二方面中的第一种可能的实现方式或者第二方面中 第二种可能的实现方式或者第二方面中第三种可能的实现方式,在第四种可 能的实现方式中,所述执行模块,具体用于在针对所述数据库执行调取出的 执行函数模板对应的执行函数时,在所述数据库确定出原始数据,所述原始 数据为未被所述执行函数模板执行的数据,获取用以表征所述原始数据的数 据量大小的数据特征,根据数据特征与执行函数模板之间的对应关系,在调 取出的执行函数模板中确定所述数据特征对应的执行函数模板,并针对所述 原始数据执行所述数据特征对应的执行函数模板对应的执行函数。 Combining the second aspect or the first possible implementation of the second aspect or the second aspect The second possible implementation or the third possible implementation of the second aspect, in the fourth In an implementation manner, the execution module is specifically configured to perform a retrieval on the database. When the execution function corresponding to the function template is executed, the original data is determined in the database, the original The data is data that is not executed by the execution function template, and the number used to represent the original data is obtained. According to the data characteristics of the size, according to the correspondence between the data features and the execution function template, Determining an execution function template corresponding to the data feature in the extracted execution function template, and for The original data executes an execution function corresponding to the execution function template corresponding to the data feature.
本发明实施例第三方面提供了一种数据查询系统,包括: A third aspect of the embodiments of the present invention provides a data query system, including:
存储器,用于存储执行函数模板以及数据库; a memory for storing an execution function template and a database;
处理器,用于获取用于在存储器存储的数据库中查询数据的查询请求, 将所述查询请求转换为对应的查询关系树,并在预存的关系树集合中确定出 与所述查询关系树匹配的关系树,根据关系树与关系树类型之间的对应关系, 确定与所述匹配的关系树对应的关系树类型,根据关系树类型与执行函数模 板之间的对应关系,在存储器中调取与确定的关系树类型对应的执行函数模 板,针对存储器存储的所述数据库执行调取出的执行函数模板对应的执行函 数,得到查询结果。 a processor for obtaining a query request for querying data in a database stored in the memory, Converting the query request into a corresponding query relationship tree, and determining in the pre-stored relationship tree set a relationship tree matching the query relationship tree, according to a correspondence between the relationship tree and the relationship tree type, Determining a relationship tree type corresponding to the matched relationship tree, according to the relationship tree type and the execution function module The correspondence between the boards, the execution function module corresponding to the determined relationship tree type is retrieved in the memory a board, executing an execution function corresponding to the execution function template for the database stored in the memory Number, get the query result.
结合第三方面,在第一种可能的实现方式中,所述处理器,具体用于确 定所述查询关系树中各关系节点的节点位置,以及各关系节点的类型,遍历 预存的关系树集合中与确定的各关系节点的节点位置以及各关系节点的类型 相匹配的关系树,作为与所述查询关系树匹配的关系树。 In combination with the third aspect, in a first possible implementation manner, the processor is specifically configured to be used Determining the node position of each relation node in the query relationship tree, and the type of each relationship node, traversing The location of the node in the pre-stored relationship tree set and the determined relationship nodes and the type of each relationship node A matching relationship tree as a relationship tree that matches the query relationship tree.
结合第三方面中的第一种可能的实现方式,在第二种可能的实现方式中, 所述处理器,还用于在遍历预存的关系树集合中与确定的各关系节点的节点 位置以及各关系节点的类型相匹配的关系树之前,在所述查询关系树中确定 出关系节点总数,在预存的关系树集合中筛选出关系节点总数与确定的关系 节点总数相等的关系树,将筛选出的关系树,作为要遍历的预存的关系树集 合。 In conjunction with the first possible implementation in the third aspect, in a second possible implementation, The processor is further configured to traverse the nodes of the determined relationship nodes in the pre-stored relationship tree set Before determining the location and the relationship tree of the types of the relationship nodes, determining in the query relationship tree The total number of relationship nodes is selected, and the total number of relationship nodes and the determined relationship are filtered out in the pre-stored relationship tree set. A relationship tree with the same number of nodes, and the filtered relationship tree as the pre-stored relationship tree set to be traversed Hehe.
结合第三方面,第三种可能的实现方式中,所述处理器,具体用于对所 述查询关系树进行哈希计算,得到所述查询关系树对应的哈希值,在预存的 关系树与关系树对应的哈希值的对应关系中,确定出哈希值与得到的所述查 询关系树的哈希值相同的关系树,作为与所述查询关系树匹配的关系树。 In combination with the third aspect, in a third possible implementation manner, the processor is specifically used to The query relationship tree performs hash calculation, and obtains a hash value corresponding to the query relationship tree, which is pre-stored. In the correspondence between the relationship tree and the hash value corresponding to the relationship tree, the hash value is determined and the obtained check is obtained. The relationship tree of the relationship tree having the same hash value is used as a relationship tree matching the query relationship tree.
结合第三方面或者第一方面中的第一种可能的实现方式或者第三方面中 第二种可能的实现方式或者第三方面中第三种可能的实现方式,在第四种可 能的实现方式中,所述处理器,具体用于在针对所述数据库执行调取出的执 行函数模板对应的执行函数时,在所述数据库确定出原始数据,所述原始数 据为未被所述执行函数模板执行的数据,获取用以表征所述原始数据的数据 量大小的数据特征,根据数据特征与执行函数模板之间的对应关系,在调取 出的执行函数模板中确定所述数据特征对应的执行函数模板,并针对所述原 始数据执行所述数据特征对应的执行函数模板对应的执行函数。 In combination with the third aspect or the first possible implementation of the first aspect or the third aspect The second possible implementation or the third possible implementation of the third aspect, in the fourth In an implementation manner, the processor is specifically configured to perform a retrieval on the database. When the row function template corresponds to the execution function, the original data is determined in the database, the original number Acquiring data for characterizing the original data according to data that is not executed by the execution function template The size of the data feature, according to the correspondence between the data characteristics and the execution function template, in the retrieval Determining an execution function template corresponding to the data feature in an execution function template, and for the original The start data executes an execution function corresponding to the execution function template corresponding to the data feature.
本发明实施例提供了一种数据查询方法,在该方法中,数据库系统获取 查询数据的查询请求之后,确定该查询请求对应的查询关系树,以及该查询 关系树对应的类型,最后根据查询关系树的类型,调取出对应的执行函数模 板,在本发明实施例中由于在该执行函数模板中包含了对应类型的关系树中 各关系节点上用于查询数据的执行函数,因此只要确定出执行函数模板之后, 通过执行该执行函数模板对应的执行函数就可以得到最终的查询结果,从而 避免了现有数据查询过程中反复调用执行函数而造成查询速度较慢的问题, 进而提升了数据查询的速度,并且也节约了网络资源。 The embodiment of the invention provides a data query method, in which the database system acquires After querying the query request for the data, determining the query relationship tree corresponding to the query request, and the query The type corresponding to the relationship tree, and finally the corresponding execution function module is retrieved according to the type of the query relationship tree. a board, in the embodiment of the present invention, because the corresponding function tree is included in the execution function template The execution function used to query the data on each relational node, so as long as the execution function template is determined, The final query result can be obtained by executing the execution function corresponding to the execution function template, thereby It avoids the problem that the query speed is slow due to repeated call of the execution function in the existing data query process. This improves the speed of data queries and also saves network resources.
图1为现有技术中的一种SQL数据查询方式示意图; 1 is a schematic diagram of a SQL data query mode in the prior art;
图2为现有技术中的另一种SQL数据查询方式示意图; 2 is a schematic diagram of another SQL data query mode in the prior art;
图3为本发明实施例中一种数据查询方法的流程图; 3 is a flowchart of a data query method according to an embodiment of the present invention;
图4a为本发明实施例中一种关系树的结构示意图之一; 4a is a schematic structural diagram of a relationship tree according to an embodiment of the present invention;
图4b为本发明实施例中一种关系树的结构示意图之二; 4b is a second schematic structural diagram of a relationship tree according to an embodiment of the present invention;
图4c为本发明实施例中一种关系树的结构示意图之三; 4c is a third schematic structural diagram of a relationship tree according to an embodiment of the present invention;
图4d为本发明实施例中一种关系树的结构示意图之四; 4d is a fourth schematic structural diagram of a relationship tree according to an embodiment of the present invention;
图4e为本发明实施例中一种关系树的结构示意图之五; 4e is a fifth structural diagram of a relationship tree according to an embodiment of the present invention;
图5为本发明实施例中一种数据查询装置的结构示意图; FIG. 5 is a schematic structural diagram of a data query apparatus according to an embodiment of the present invention;
图6为本发明实施例中转换模块的结构示意图; 6 is a schematic structural diagram of a conversion module according to an embodiment of the present invention;
图7为本发明实施例中一种数据查询系统的结构示意图。 FIG. 7 is a schematic structural diagram of a data query system according to an embodiment of the present invention.
本发明实施例中提供了一种数据查询方法,在该方法中通过对查询请求 进行语法分析之后,得到查询请求对应的关系树,确定该关系树所对应的类 型,再确定出关系树的类型对应的执行函数模板,最后通过执行确定出的执 行函数模板得到最终的查询结果。这样可以将一个完整的查询请求对应成一 个执行函数模板,在该执行函数模板中包含了对应类型的关系树上各节点对 应的执行函数,从而避免了查询过程中反复的调用执行函数所带来的信令开 销,提升了数据查询的速度。 In the embodiment of the present invention, a data query method is provided, in which a query request is After parsing, the relationship tree corresponding to the query request is obtained, and the class corresponding to the relationship tree is determined. Type, and then determine the execution function template corresponding to the type of the relationship tree, and finally determine the execution by execution. The row function template gets the final query result. This can correspond to a complete query request into a Execution function template, in which the node pair on the relationship tree of the corresponding type is included in the execution function template Should execute the function, thus avoiding the signaling that is caused by repeated calls to the execution function during the query process. Sales, increasing the speed of data queries.
下面通过附图以及具体实施例对本发明技术方案做详细的说明。 The technical solutions of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
如图3所示为本发明实施例中一种数据查询方法的流程图,该方法包括: FIG. 3 is a flowchart of a data query method according to an embodiment of the present invention, where the method includes:
S301,获取用于在数据库中查询数据的查询请求; S301. Acquire a query request for querying data in a database.
S302,将查询请求转换为对应的查询关系树,并在预存的关系树集合中 确定出与查询关系树匹配的关系树; S302. Convert the query request into a corresponding query relationship tree, and in the pre-stored relationship tree set. Determining a relationship tree that matches the query relationship tree;
在该关系树集合中包括不同查询请求转换得到的不同关系树。 Different relational trees obtained by different query request conversions are included in the relationship tree set.
S303,根据关系树与关系树类型之间的对应关系,确定与匹配的关系树 对应的关系树类型; S303. Determine a relationship tree according to the correspondence between the relationship tree and the relationship tree type. Corresponding relationship tree type;
在该执行函数模板中包含了对应类型的关系树中各关系节点上用于查询 数据的执行函数。 In the execution function template, the corresponding type of relationship tree is included in the relationship tree for querying The execution function of the data.
S304,根据关系树类型与执行函数模板之间的对应关系,调取与确定的 关系树类型对应的执行函数模板; S304. Retrieving and determining according to the correspondence between the relationship tree type and the execution function template. The execution function template corresponding to the relationship tree type;
S305,针对数据库执行调取出的执行函数模板对应的执行函数,得到查 询结果。 S305. Perform an execution function corresponding to the execution function template of the retrieved database for the database, and obtain the check function. Ask for results.
首先来讲,在本发明实施例的数据库系统中保存了不同关系树以及关系 树对应的类型,比如说图4a所示的关系树对应的关系树类型为Select类型, 图4b所示的关系树对应的关系树类型为Group类型,图4c所示的关系树类 型为TOPN类型,图4d所示的关系树对应的关系树类型为TOPN_Group类型, 图4e所示的关系树对应的关系树类型为TOPN_NO_Group类型,上述的五种 关系树类型是通过关系树中的关系节点来确定,当然在本发明实施例中并不 限定只能通过关系节点来定义关系树类型,在实际的应用中可以通过其他可 实现方式来定义关系树对应的关系树类型,此处就不再穷举。 First of all, different relational trees and relationships are stored in the database system of the embodiment of the present invention. The type corresponding to the tree, for example, the relationship tree type corresponding to the relationship tree shown in Figure 4a is of the Select type. The relationship tree type corresponding to the relationship tree shown in Figure 4b is a Group type, and the relationship tree class shown in Figure 4c The type is a TOPN type, and the relationship tree type corresponding to the relationship tree shown in FIG. 4d is a TOPN_Group type. The relationship tree type corresponding to the relationship tree shown in Figure 4e is of the TOPN_NO_Group type, and the above five The relationship tree type is determined by the relationship node in the relationship tree, and of course not in the embodiment of the present invention. The definition can only define the relationship tree type through the relationship node. In the actual application, other types can be used. The implementation method to define the relationship tree type corresponding to the relationship tree is not exhaustive here.
数据库系统在接收到用户输入的查询请求时,数据库系统将对查询请求 进行语义分析,从而得到查询请求对应的查询关系树。 When the database system receives the query request input by the user, the database system will request the query. Semantic analysis is performed to obtain a query relationship tree corresponding to the query request.
比如说数据库系统接收到的查询请求为“从表T中查询出列数大于5的 数据”,对该查询请求经过语言结构分析之后,可以得到SQL语句,即:Select A from T,where A>5。根据该SQL语句就可以得到关系树中的每个关系节 点,以及每个关系节点根据对应的执行函数来执行筛选操作,首先是Basetable 关系节点,Basetable关系节点对应的执行筛选操作是从数据库中查找出表T, 由于表T未经过任何的处理,所以表T为原始数据,这里需要说明的是:原 始数据为从数据库中提取出的,并且表T未经过数据排序、数据筛选、数据 更新等处理。 For example, the query request received by the database system is "from the table T, the number of columns is greater than 5 Data", after the query request has been analyzed by the language structure, you can get the SQL statement, namely: Select A from T, where A>5. According to the SQL statement, each relationship section in the relationship tree can be obtained. Point, and each relationship node performs filtering according to the corresponding execution function, firstly Basetable The relational node and the execution filtering operation corresponding to the Basetable relational node are to find the table T from the database. Since the table T has not undergone any processing, the table T is the original data, and the need to explain here is: The initial data is extracted from the database, and the table T is not sorted by data, data filtered, data Update and other processing.
然后是Select关系节点,Select关系节点对应的执行筛选操作是在表T中 筛选出列数大于5的数据;最后是Project关系节点,Project关系节点的功能 是得到最后的查询结果,根据这些关系节点就可以得到该查询请求对应的查 询关系树,该查询关系树即为图4a所示的关系树。在图4a所示的关系树中每 个关系节点对应自身的类型。 Then the Select relationship node, the corresponding filtering operation corresponding to the Select relationship node is in the table T Filter out the data with column number greater than 5; finally, the function of Project relationship node and Project relationship node Is to get the final query result, according to these relationship nodes can get the corresponding query of the query request The relationship tree is consulted, and the query relationship tree is the relationship tree shown in Figure 4a. In the relationship tree shown in Figure 4a The relationship nodes correspond to their own types.
在得到查询关系树之后,数据库系统将分析该查询关系树的树形结构特 征,该结构特征表征了查询关系树中每个关系节点的类型以及关系节点在查 询关系树中的节点位置。 After obtaining the query relationship tree, the database system will analyze the tree structure of the query relationship tree. The structural feature characterizes the type of each relational node in the query relationship tree and the relationship node is inspected. Ask for the location of the node in the relationship tree.
比如说查询请求对应的关系树为图4a所示的查询关系树,在该查询关系 树中树头对应的关系节点为“Basetable”关系节点,树头表征了“Basetable” 关系节点在查询关系树中的位置,“Basetable”表征了关系节点的类型; “Basetable”关系节点之后的树中的关系节点为“Select”关系节点,“Select” 表征了关系节点的类型;树尾对应的关系节点为“Project”关系节点,“Project” 表征了关系节点的类型,通过对查询关系树中的关系节点在查询关系树中的 位置以及各关系节点的类型,就可以得到查询关系树对应的树形结构特征。 For example, the relationship tree corresponding to the query request is the query relationship tree shown in FIG. 4a, and the query relationship is The relation node corresponding to the tree head in the tree is the "Basetable" relation node, and the tree header represents "Basetable" The location of the relational node in the query relationship tree, "Basetable" represents the type of the relational node; The relationship node in the tree after the "Basetable" relationship node is the "Select" relationship node, "Select" Represents the type of relational node; the relational node corresponding to the end of the tree is the "Project" relational node, "Project" Characterizes the type of the relational node, by querying the relationship node in the query relationship tree in the query relationship tree The location and the type of each relationship node can be used to obtain the tree structure feature corresponding to the query relationship tree.
在系统得到查询关系树的树形结构特征之后,系统将得到的查询关系树 的树形结构特征与系统中预存的关系树的树形结构特征进行匹配,此处的关 系树的树形结构特征匹配是将查询关系树中的关系节点的类型以及节点位置 与预存的关系树集合中的各关系节点的类型与节点位置进行匹配。 After the system gets the tree structure feature of the query relationship tree, the system will get the query relationship tree. The tree structure features are matched with the tree structure features of the pre-stored relationship tree in the system. The tree structure feature matching of the phylogenetic tree is the type of the relational node and the node location in the query relationship tree. Match the type of each relationship node in the pre-stored relationship tree set with the node location.
比如,查询关系树为图4a所示关系树时,查询关系树的树头的关系节点 为Basetable,树头之后的关系节点为Select,树尾节点为Project,数据库系 统将在预存的关系树集合中确定是否保存有与图4a所示的查询关系树的树形 结构特征相同的关系树,若是在数据库系统中存在与查询关系树的树形结构 特征相同的关系树,则数据库系统将确定出该关系树对应的关系树类型为 Select类型,即:查询关系树的关系树类型为Select类型。 For example, when the query relationship tree is the relationship tree shown in FIG. 4a, the relationship node of the tree head of the query relationship tree is queried. For Basetable, the relationship node after the tree header is Select, the tree tail node is Project, and the database system is The system will determine whether to save the tree with the query relationship tree shown in Figure 4a in the pre-stored relationship tree set. A relational tree with the same structural characteristics, if there is a tree structure with a query relationship tree in the database system If the relationship tree has the same characteristics, the database system determines that the relationship tree type corresponding to the relationship tree is The Select type, that is, the relation tree type of the query relationship tree is of the Select type.
可选的,为了减少关系树匹配筛选的次数,因此在发明实施例中,数据 库系统在进行树形结构特征匹配之前,可以通过关系树中的关系节点总数在 预存的关系树集合中初步筛选出一部分关系树。 Optionally, in order to reduce the number of times the relationship tree matches the screening, in the embodiment of the invention, the data The library system can pass the total number of relational nodes in the relationship tree before performing tree structure feature matching. A part of the relationship tree is initially selected in the pre-stored relationship tree set.
具体来讲,首先获取到查询关系树中的关系节点总数,数据库系统将在 预存的关系树集合中筛选出节点总数与查询关系树的关系节点总数相等的关 系树,比如说查询关系树中的关系节点总数为3个,数据库系统将在预存的 关系树中遍历出关系节点总数为3个的关系树,此时筛选出的关系树为初步 筛选出的关系树,并不能作为与查询关系树匹配的关系树。 Specifically, first obtain the total number of relational nodes in the query relationship tree, and the database system will The total number of nodes in the pre-stored relationship tree set is equal to the total number of relationship nodes in the query relationship tree. The phylogenetic tree, for example, the total number of relational nodes in the query relationship tree is three, and the database system will be pre-stored. In the relationship tree, the relationship tree with 3 total number of relation nodes is traversed. At this time, the filtered relationship tree is preliminary. The filtered relationship tree cannot be used as a relationship tree that matches the query relationship tree.
在预存的关系树中筛选出与查询关系树的节点总数相等的关系树之后, 再在初步筛选出的关系树在中筛选出与查询关系树的各关系节点的节点位置 以及各关系节点的类型相匹配的关系树。这样就可以避免将查询关系树的各 关系节点的节点位置以及各关系节点的类型与预存的关系树集合中每个关系 树的节点位置以及关系节点的类型进行匹配,从而减少了匹配的次数,提升 了数据查询的速度以及效率。 After filtering out the relationship tree equal to the total number of nodes in the query relationship tree in the pre-stored relationship tree, Then, in the initially selected relationship tree, the node locations of the relationship nodes of the query relationship tree are filtered out. And a relationship tree in which the types of the relationship nodes match. This way you can avoid having to query the relationship tree The node location of the relational node and the type of each relational node and each relationship in the pre-stored relational tree set The node position of the tree and the type of the relationship node are matched, thereby reducing the number of matches and improving The speed and efficiency of data queries.
可选的,在本发明实施例中除了通过节点位置以及节点类型的匹配来确 定查询关系树的类型之外,还可以通过计算查询关系树的哈希值来确定查询 关系树的类型。 Optionally, in the embodiment of the present invention, in addition to the matching of the node location and the node type, In addition to the type of the query relationship tree, you can also determine the query by calculating the hash value of the query relationship tree. The type of relationship tree.
具体来讲,在数据库系统中预先存储了每一种类型的关系树,比如Select 类型的关系树、Group类型的关系树、TOPN类型的关系树等,并且通过对每 一种类型的关系树进行哈希计算得到每一种类型的关系树对应的哈希值,然 后在数据库系统中保存每一种类型的关系树以及每一种类型的关系树对应的 哈希值。 Specifically, each type of relationship tree is pre-stored in the database system, such as Select. Type relationship tree, Group type relationship tree, TOPN type relationship tree, etc. A type of relationship tree performs hash calculation to obtain a hash value corresponding to each type of relationship tree, After saving each type of relationship tree in the database system and corresponding to each type of relationship tree Hash value.
在得到查询请求对应的查询关系树之后,对查询关系树进行哈希计算, 从而得到该查询关系树对应的哈希值,然后根据查询关系树的哈希值与预先 存储的哈希值进行匹配,若是在数据库系统中存在与查询关系树的哈希值相 同的哈希值时,则将该哈希值对应的关系树的类型作为查询关系树的类型, 比如数据库系统中保存了表1所示关系树类型与哈希值之间的对应关系: After obtaining the query relationship tree corresponding to the query request, performing a hash calculation on the query relationship tree, Thereby obtaining a hash value corresponding to the query relationship tree, and then according to the hash value of the query relationship tree and the advance The stored hash value is matched, if there is a hash value in the database system and the query relationship tree When the same hash value is used, the type of the relation tree corresponding to the hash value is used as the type of the query relationship tree. For example, the correspondence between the relationship tree type and the hash value shown in Table 1 is stored in the database system:
表1 Table 1
通过表1中可以得出,若是查询关系树的哈希值为a,则该查询关系树的 类型就为Select类型,该Select类型对应的关系树就为图4a所示的关系树, 若是查询关系树的哈希值为b,则查询关系树的类型就为Group类型,该Group 类型对应的关系树就为图4b所示的关系树,若是查询关系树的哈希值为c, 则查询关系树的类型就为TOPN类型,该TOPN类型对应的关系树为图4c所 示的关系树。 It can be concluded from Table 1 that if the hash value of the query relationship tree is a, then the query relationship tree The type is the Select type, and the relation tree corresponding to the Select type is the relationship tree shown in Figure 4a. If the hash value of the query relationship tree is b, the type of the query relationship tree is the Group type, and the group The relationship tree corresponding to the type is the relationship tree shown in Figure 4b. If the hash value of the query relationship tree is c, Then, the type of the query relationship tree is the TOPN type, and the relationship tree corresponding to the TOPN type is as shown in FIG. 4c. The relationship tree shown.
通过查询关系树的哈希值可以快速的定位出查询关系树的类型,即使查 询关系树的树形结构较为复杂,也可以通过哈希值快速的确定出查询关系树 的类型。 By querying the hash value of the relation tree, you can quickly locate the type of the query relationship tree, even if you check The tree structure of the query tree is more complicated, and the query relationship tree can be quickly determined by the hash value. type.
进一步,若是查询关系树的哈希值与数据库系统中预先存储的哈希值之 间存在哈希冲突时,则还需要根据查询关系树的树形结构特征来确定查询关 系树对应的类型。 Further, if the hash value of the query relationship tree and the hash value pre-stored in the database system are When there is a hash conflict between them, it is also necessary to determine the query based on the tree structure characteristics of the query relationship tree. The type corresponding to the tree.
比如说查询关系树经过哈希函数计算之后得到的哈希值与表1中的哈希 值a存在哈希冲突,则确定出哈希值a对应的关系树,然后将查询关系树的树 形结构特征与哈希值a对应的关系树的树形结构特征进行匹配,若是查询关 系树与哈希值a对应的关系树的树形结构特征匹配,则哈希值a对应的关系树 的类型作为查询关系树的类型,若是不匹配,则确定该查询关系树无匹配的 关系树。 For example, the query relationship tree is hashed after the hash function is calculated and the hash in Table 1. If the value a has a hash conflict, then the relationship tree corresponding to the hash value a is determined, and then the tree of the relationship tree is queried. The structural feature of the shape is matched with the tree structure feature of the relation tree corresponding to the hash value a, if the query is off The tree structure characteristic of the relationship tree corresponding to the hash value a is matched, and the relation tree corresponding to the hash value a The type of the query relationship tree, if it does not match, it is determined that the query relationship tree has no match. Relationship tree.
通过查询关系树的树形结构特征匹配或者是通过查询关系树对应的哈希 值进行匹配来得到查询关系树的类型之后,系统将调取出预先存储的关系树 类型与执行函数模板之间的对应关系,具体来讲,在数据库系统中预先存储 了每一种类型的关系树与执行函数模板之间的对应关系表,该对应关系表可 以但不限于表2所示: Matching the tree structure feature of the relation tree or by querying the hash corresponding to the relationship tree After the values are matched to get the type of the query relationship tree, the system will retrieve the pre-stored relationship tree. The correspondence between the type and the execution function template, specifically, pre-stored in the database system a correspondence table between each type of relationship tree and an execution function template, the correspondence table may But not limited to Table 2:
表2 Table 2
基于表2中的对应关系得出,只要确定出查询关系树的类型之后就可以 确定出对应的执行函数模板,比如说查询关系树的类型为Group类型时,则 查询关系树对应的执行函数模板为“模板2”,此处执行函数模板可以但不限 于以下的代码: Based on the correspondence in Table 2, as long as the type of the query relationship tree is determined, Determine the corresponding execution function template. For example, if the query relationship tree type is Group type, then The execution function template corresponding to the query relationship tree is "template 2", where the function template can be executed but not limited. In the following code:
在确定执行函数模板之后,该数据库系统将执行确定出的执行函数模板 对应的执行函数,从而在数据库中查询出需要的查询结果。在该执行函数模 板中包含了对应类型的关系树中每个节点对应的执行函数,也就是说执行了 确定出的执行函数模板就相当于执行了对应类型的关系树上每个节点对应的 执行函数,因此在本发明实施例中,因此在数据查询过程就不再需要重复的 调取执行函数,从而提升了数据查询的速度以及效率,并且也节约了系统资 源。 After determining the execution function template, the database system will execute the determined execution function template Corresponding execution function, so as to query the required query result in the database. In the execution function mode The board contains the execution function corresponding to each node in the relation tree of the corresponding type, that is, executed. The determined execution function template is equivalent to executing each node on the corresponding type of relationship tree. Executing the function, so in the embodiment of the present invention, therefore, the data query process no longer needs to be repeated. Retrieve the execution function, which improves the speed and efficiency of data query, and also saves system resources source.
进一步,在本发明实施例中一种类型的关系树可能对应多个执行函数模 板,因此通过关系树的类型还不能精确的确定出一个执行函数模板的话,则 可以结合原始数据的数据特征来进一步的确定执行函数模板,这里的原始数 据为从数据库中查找出来的未被执行函数模板执行的数据,比如说查询请求 为“从表T中查询出列数大于5的数据”,在响应该查询请求时,首先是在数 据库中查找到表T,这里的表T在被查找出来时,数据库系统并没有对表T 做任何的处理,所以表T就为原始数据。 Further, in the embodiment of the present invention, a type of relationship tree may correspond to multiple execution function modules. Board, so if you can't accurately determine an execution function template by the type of the relationship tree, then The execution function template can be further determined in conjunction with the data characteristics of the original data, where the original number is According to the data that is not executed by the function template found in the database, such as query request To "query data from column T with columns greater than 5", in response to the query request, the first is the number According to the table T found in the library, when the table T is found, the database system does not have a table T Do any processing, so the table T is the original data.
在得到原始数据之后,需要进一步的确定出原始数据的数据特征,这里 的数据特征至少包括了原始数据的数据量大小、原始数据中待查找的列数据 的类型、原始数据中待查找的列数据的属性中的一种数据特征或者是多种数 据特征的组合,其中,列数据的属性表征了原始数据中的列数据是否排序或 者是原始数据中的列数据是否为循环数据等属性。 After obtaining the original data, it is necessary to further determine the data characteristics of the original data, here The data characteristics include at least the amount of data of the original data, and the column data to be searched in the original data. Type, one of the attributes of the column data to be searched in the original data, or a plurality of numbers According to the combination of features, the attributes of the column data represent whether the column data in the original data is sorted or Whether the column data in the original data is a loop data or the like.
在本发明实施例中以原始数据的数据量大小来说明,也就是说查询关系 树对应多个执行函数模板时,则确定原始数据的数据量大小,然后根据预存 的数据量大小与执行函数模板之间的对应关系,确定原始数据的数据量对应 的执行函数模板。 In the embodiment of the present invention, the amount of data of the original data is used, that is, the query relationship When the tree corresponds to multiple execution function templates, the data size of the original data is determined, and then pre-stored according to the data. Correspondence between the amount of data and the execution function template, determining the amount of data corresponding to the original data Execution function template.
比如说Group类型的关系树对应了3种不同的执行函数模板,而3种不 同的执行函数模板与原始数据的数据量大小之间存在对应关系,即:原始数 据的数据量大小为1字节、2字节、3字节分别对应的执行函数模板为 do_bte_group、do_sht_group、do_hash_group;因此在确定出查询关系树为Group 类型时,则数据库系统还将进一步确定原始数据的数据量大小,若是原始数 据的数据量为1字节时,则执行函数模板为do_bte_group,若是原始数据的数 据量为2字节时,则执行函数模板为do_sht_group。通过此种方式可以在通过 关系树的类型不能精确的确定出执行函数模板的情况下,可以进一步的基于 原始数据的数据量大小来确定出执行函数模板,最后通过执行进一步确定出 的执行函数模板对应的执行函数,精确的查询出需要查询结果。 For example, the relationship tree of the Group type corresponds to 3 different execution function templates, and 3 types are not. There is a correspondence between the same execution function template and the data size of the original data, namely: the original number The execution function template corresponding to the data size of 1 byte, 2 bytes, and 3 bytes is Do_bte_group, do_sht_group, do_hash_group; therefore, the query relationship tree is determined to be a Group Type, the database system will further determine the amount of data of the original data, if it is the original number When the amount of data is 1 byte, the execution function template is do_bte_group, if it is the number of original data. When the data is 2 bytes, the execution function template is do_sht_group. In this way, you can pass If the type of the relationship tree cannot be accurately determined by executing the function template, it can be further based on The amount of data of the original data to determine the execution function template, and finally further determined by execution The execution function corresponding to the execution function template accurately queries the result of the query.
除了可以通过原始数据的数据量大小确定执行函数模板之外,还可以通 过原始数据中待查找的列数据的类型或者属性来建立与执行函数模板之间的 对应关系,此时就不再一一例举。 In addition to the execution of the function template by the amount of data of the original data, it is also possible to pass The type or attribute of the column data to be searched in the original data to establish and execute the function template The correspondence is no longer an example.
通过建立原始数据的数据特征与执行函数模板之间的对应关系,可以在 关系树对应的多个执行函数模板的情况下,通过原始数据的数据特征精确确 定出对应的执行函数模板来执行,从而提升了数据查询的速度以及准确性。 By establishing the correspondence between the data characteristics of the original data and the execution function template, In the case of multiple execution function templates corresponding to the relationship tree, the data characteristics of the original data are accurately determined The corresponding execution function template is determined to be executed, thereby improving the speed and accuracy of the data query.
对应上述实施例中的一种数据查询方法,本发明实施例中还提供了一种 数据查询的装置,如图5所示为本发明实施例中一种数据查询装置的结构示 意图,该装置包括: Corresponding to a data query method in the foregoing embodiment, an embodiment of the present invention further provides a The device for querying data, as shown in FIG. 5 is a structural diagram of a data query device according to an embodiment of the present invention. Intended, the device includes:
获取模块501,用于获取用于在数据库中查询数据的查询请求;
An obtaining
转换模块502,用于将所述查询请求转换为对应的查询关系树,并在预存
的关系树集合中确定出与所述查询关系树匹配的关系树,所述预存的关系树
集合中包括对不同的查询请求转换得到的不同关系树;
The
确定模块503,用于根据关系树与关系树类型之间的对应关系,确定与所
述匹配的关系树对应的关系树类型;
a determining
调取模块504,用于根据关系树类型与执行函数模板之间的对应关系,调
取与确定的关系树类型对应的执行函数模板,其中,所述执行函数模板中包
含了对应类型的关系树中各关系节点上用于查询数据的执行函数;
The calling
执行模块505,用于针对所述数据库执行调取出的执行函数模板对应的执
行函数,得到查询结果。
An
进一步,如图6所示,该转换模块502包括:
Further, as shown in FIG. 6, the
确定单元601,用于确定所述查询关系树中各关系节点的节点位置,以及
各关系节点的类型;
a determining
查询单元602,用于遍历预存的关系树集合中与确定的各关系节点的节点
位置以及各关系节点的类型相匹配的关系树,作为与所述查询关系树匹配的
关系树。
The
进一步,该转换模块502,还包括:
Further, the
筛选模块603,设置于确定模块601和查询模块602之间,用于在所述查
询关系树中确定出关系节点总数,在预存的关系树集合中筛选出关系节点总
数与确定的关系节点总数相等的关系树,将筛选出的关系树,作为要遍历的
预存的关系树集合。
The
进一步,该装置中的确定模块503,还用于对所述查询关系树进行哈希计
算,得到所述查询关系树对应的哈希值,在预存的关系树与关系树对应的哈
希值的对应关系中,确定出哈希值与所述查询关系树的哈希值相同的关系树,
作为与所述查询关系树匹配的关系树。
Further, the determining
进一步,该装置中的执行模块505,具体用于在针对所述数据库执行调取
出的执行函数模板对应的执行函数时,在所述数据库确定出原始数据,所述
原始数据为未被所述执行函数模板执行的数据,获取用以表征所述原始数据
的数据量大小的数据特征,根据数据特征与执行函数模板之间的对应关系,
在调取出的执行函数模板中确定所述数据特征对应的执行函数模板,并针对
所述原始数据执行所述数据特征对应的执行函数模板对应的执行函数。
Further, the
另外,在本发明实施例中还提供了一种数据查询系统,如图7所示为该 系统的结构示意图,该系统包括: In addition, in the embodiment of the present invention, a data query system is further provided, as shown in FIG. Schematic diagram of the system, the system includes:
存储器701,用于存储执行函数模板以及待查询的数据;
a
处理器702,用于获取用于在数据库中查询数据的查询请求,将所述查询
请求转换为对应的查询关系树,并在预存的关系树集合中确定出与所述查询
关系树匹配的关系树,根据关系树与关系树类型之间的对应关系,确定与所
述匹配的关系树对应的关系树类型,根据关系树类型与执行函数模板之间的
对应关系,调取与确定的关系树类型对应的执行函数模板,针对所述数据库
执行调取出的执行函数模板对应的执行函数,得到查询结果。
The
进一步,该处理器702,具体用于确定所述查询关系树中各关系节点的节
点位置,以及各关系节点的类型,遍历预存的关系树集合中与确定的各关系
节点的节点位置以及各关系节点的类型相匹配的关系树,作为与所述查询关
系树匹配的关系树。
Further, the
进一步,该处理器702,还用于在所述查询关系树中确定出关系节点总数,
在预存的关系树集合中筛选出关系节点总数与确定的关系节点总数相等的关
系树,将筛选出的关系树,作为要遍历的预存的关系树集合。
Further, the
进一步,该处理器702,还用于对所述查询关系树进行哈希计算,得到所
述查询关系树对应的哈希值,在预存的关系树与关系树对应的哈希值的对应
关系中,确定出哈希值与所述查询关系树的哈希值相同的关系树,作为与所
述查询关系树匹配的关系树。
Further, the
进一步,该处理器702,具体用于在针对所述数据库执行调取出的执行函
数模板对应的执行函数时,在所述数据库确定出原始数据,所述原始数据为
未被所述执行函数模板执行的数据,获取用以表征所述原始数据的数据量大
小的数据特征,根据数据特征与执行函数模板之间的对应关系,在调取出的
执行函数模板中确定所述数据特征对应的执行函数模板,并针对所述原始数
据执行所述数据特征对应的执行函数模板对应的执行函数。
Further, the
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产 品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图 和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程 和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、 嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通 过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流 程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的 装置。 The present invention is directed to a method, apparatus (system), and computer program according to an embodiment of the present invention. The flow chart and/or block diagram of the product is described. It should be understood that the flow chart can be implemented by computer program instructions And/or each flow and/or block in the block diagram, and the flow in the flowchart and/or block diagram And/or a combination of boxes. These computer program instructions can be provided to a general purpose computer, a special purpose computer, An embedded processor or processor of another programmable data processing device to generate a machine Instructions executed by a processor of a computer or other programmable data processing device are generated for implementation in the stream a process or a process and/or a block diagram of a function specified in a box or blocks Device.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设 备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器 中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或 多个流程和/或方框图一个方框或多个方框中指定的功能。 These computer program instructions can also be stored in a bootable computer or other programmable data processing device. In a computer readable memory that operates in a particular manner such that it is stored in the computer readable memory The instruction in the production includes an article of manufacture of the instruction device, the instruction device being implemented in a flow of the flowchart or Multiple processes and/or block diagrams The functions specified in one or more boxes.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上, 使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的 处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图 一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步 骤。 These computer program instructions can also be loaded onto a computer or other programmable data processing device. Enabling a series of operational steps on a computer or other programmable device to produce a computer implemented Processing instructions that are executed on a computer or other programmable device are provided for implementation in the flowchart a step in a process or multiple processes and/or block diagrams of a function specified in a box or blocks Step.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了 基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权 利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。 Although a preferred embodiment of the invention has been described, one of ordinary skill in the art will recognize Additional changes and modifications to these embodiments can be made in the basic inventive concept. Therefore, the right to attach All changes and modifications are intended to be included within the scope of the invention.
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本 发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要 求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。 Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the present invention. The spirit and scope of the invention. Thus, if such modifications and variations of the present invention are claimed in the present invention The invention is also intended to cover such modifications and variations within the scope of the invention.
Claims (15)
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2014/079607 WO2015188315A1 (en) | 2014-06-10 | 2014-06-10 | Data query method, device and system |
| CN201480036835.0A CN105378724B (en) | 2014-06-10 | 2014-06-10 | A data query method, device and system |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2014/079607 WO2015188315A1 (en) | 2014-06-10 | 2014-06-10 | Data query method, device and system |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2015188315A1 true WO2015188315A1 (en) | 2015-12-17 |
Family
ID=54832695
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2014/079607 Ceased WO2015188315A1 (en) | 2014-06-10 | 2014-06-10 | Data query method, device and system |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN105378724B (en) |
| WO (1) | WO2015188315A1 (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US12380075B2 (en) | 2021-07-09 | 2025-08-05 | Huawei Technologies Co., Ltd. | Data processing method and apparatus, and computing system |
| CN120434270A (en) * | 2025-05-15 | 2025-08-05 | 湖北大学 | Internet information service method and system based on cloud computing |
Families Citing this family (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN106874411B (en) * | 2017-01-22 | 2019-10-15 | 网易(杭州)网络有限公司 | A kind of searching method and search platform of table |
| CN108664488B (en) * | 2017-03-28 | 2020-11-10 | 华为技术有限公司 | Method and device for processing voice system index data |
| CN108334571A (en) * | 2018-01-19 | 2018-07-27 | 上海达梦数据库有限公司 | Method, apparatus, server and the storage medium of hierarchical query |
| CN112559717B (en) * | 2020-12-24 | 2024-08-30 | 北京百度网讯科技有限公司 | Search matching method, device, electronic equipment and storage medium |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101593180A (en) * | 2008-05-30 | 2009-12-02 | 国际商业机器公司 | The SPARQL inquiry is changed into the method and apparatus of SQL query |
| US8005828B2 (en) * | 2008-02-05 | 2011-08-23 | Yahoo! Inc. | Learning query rewrite policies |
| CN102576363A (en) * | 2009-09-29 | 2012-07-11 | 渣普控股有限公司 | A content based approach to extending the form and function of a business intelligence system |
| CN102693310A (en) * | 2012-05-28 | 2012-09-26 | 无锡成电科大科技发展有限公司 | Resource description framework querying method and system based on relational database |
| CN103177120A (en) * | 2013-04-12 | 2013-06-26 | 同方知网(北京)技术有限公司 | Index-based XPath query mode tree matching method |
-
2014
- 2014-06-10 CN CN201480036835.0A patent/CN105378724B/en active Active
- 2014-06-10 WO PCT/CN2014/079607 patent/WO2015188315A1/en not_active Ceased
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US8005828B2 (en) * | 2008-02-05 | 2011-08-23 | Yahoo! Inc. | Learning query rewrite policies |
| CN101593180A (en) * | 2008-05-30 | 2009-12-02 | 国际商业机器公司 | The SPARQL inquiry is changed into the method and apparatus of SQL query |
| CN102576363A (en) * | 2009-09-29 | 2012-07-11 | 渣普控股有限公司 | A content based approach to extending the form and function of a business intelligence system |
| CN102693310A (en) * | 2012-05-28 | 2012-09-26 | 无锡成电科大科技发展有限公司 | Resource description framework querying method and system based on relational database |
| CN103177120A (en) * | 2013-04-12 | 2013-06-26 | 同方知网(北京)技术有限公司 | Index-based XPath query mode tree matching method |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US12380075B2 (en) | 2021-07-09 | 2025-08-05 | Huawei Technologies Co., Ltd. | Data processing method and apparatus, and computing system |
| CN120434270A (en) * | 2025-05-15 | 2025-08-05 | 湖北大学 | Internet information service method and system based on cloud computing |
Also Published As
| Publication number | Publication date |
|---|---|
| CN105378724B (en) | 2019-02-05 |
| CN105378724A (en) | 2016-03-02 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN109739894B (en) | Method, device, equipment and storage medium for supplementing metadata description | |
| WO2021052177A1 (en) | Log parsing method and device, server and storage medium | |
| WO2015188315A1 (en) | Data query method, device and system | |
| CN104424269B (en) | data lineage analysis method and device | |
| US11157473B2 (en) | Multisource semantic partitioning | |
| US9773041B2 (en) | Methods and apparatus of shared expression evaluation across RDBMS and storage layer | |
| CN104123374B (en) | The method and device of aggregate query in distributed data base | |
| WO2018036549A1 (en) | Distributed database query method and device, and management system | |
| CN104572979A (en) | SQL (Structured Query Language) processing method and device | |
| WO2017096939A1 (en) | Method for establishing index on hdfs-based spark-sql big-data processing system | |
| CN105975617A (en) | Multi-partition-table inquiring and processing method and device | |
| JP2016517567A5 (en) | ||
| US11288266B2 (en) | Candidate projection enumeration based query response generation | |
| WO2019233117A1 (en) | Routing method, device and equipment for on-line analytical processing engine | |
| CN115292327B (en) | Multi-table association methods, apparatus, equipment and storage media | |
| WO2022253131A1 (en) | Data parsing method and apparatus, computer device, and storage medium | |
| CN114791927A (en) | Data analysis method and device | |
| CN115878661A (en) | Query method, query device, electronic equipment and storage medium | |
| TWI856916B (en) | Data lineage management system and data lineage managing method | |
| CN104123354A (en) | Query optimization method based on MySOL database | |
| CN104750806A (en) | Large data query method and system | |
| CN114090558A (en) | Data quality management method and device for database | |
| CN106777252A (en) | A kind of method and device of uncertain semantic Temporal query middleware | |
| CN119513123A (en) | Data query method and device, electronic device and storage medium | |
| CN116974845A (en) | Table blood edge relation analysis method, apparatus, device and computer readable storage medium |
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: 14894686 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 14894686 Country of ref document: EP Kind code of ref document: A1 |