CN116303574A - Database operation statement optimization and database operation method, equipment and medium - Google Patents
Database operation statement optimization and database operation method, equipment and medium Download PDFInfo
- Publication number
- CN116303574A CN116303574A CN202310252269.8A CN202310252269A CN116303574A CN 116303574 A CN116303574 A CN 116303574A CN 202310252269 A CN202310252269 A CN 202310252269A CN 116303574 A CN116303574 A CN 116303574A
- Authority
- CN
- China
- Prior art keywords
- expression
- sub
- execution
- common
- database operation
- 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.)
- Pending
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
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2453—Query optimisation
- G06F16/24534—Query rewriting; Transformation
- G06F16/24542—Plan optimisation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Operations Research (AREA)
- Mathematical Physics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
技术领域technical field
本申请涉及数据库技术领域,尤其涉及一种数据库操作语句优化及数据库操作方法、设备及介质。The present application relates to the field of database technology, in particular to a database operation statement optimization and database operation method, device and medium.
背景技术Background technique
各种关系数据库系统支持使用SQL(Structured Query Language,结构化查询语言)进行数据查询。具体而言,客户端向关系数据库系统的服务器提交SQL语句,服务器将SQL语句解析为AST(abstract syntax code,抽象语法树),以及基于AST生成逻辑执行计划,根据逻辑执行计划执行诸如数据查询、数据更新、数据删除或数据插入等数据库操作,并将数据库操作结果返回给客户端。Various relational database systems support data query using SQL (Structured Query Language, Structured Query Language). Specifically, the client submits an SQL statement to the server of the relational database system, and the server parses the SQL statement into an AST (abstract syntax code, abstract syntax tree), and generates a logical execution plan based on the AST, and executes such as data query, Database operations such as data update, data deletion or data insertion, and return the database operation results to the client.
通常,逻辑执行计划包括多个逻辑算子,多个逻辑算子中诸如Projection(投影)算子、filter(过滤)算子等逻辑算子需要对SQL语句中的表达式进行计算。当SQL语句包括多个表达式时,多个表达式中出现重复的子表达式的概率较大,对重复的子表达式进行重复计算,计算效率较低,造成计算资源的浪费,影响关系数据库系统的查询性能。Usually, the logical execution plan includes multiple logical operators, among which logical operators such as Projection (projection) operator and filter (filter) operator need to calculate the expression in the SQL statement. When the SQL statement includes multiple expressions, the probability of repeated sub-expressions in multiple expressions is high, and repeated calculations for repeated sub-expressions result in low calculation efficiency, resulting in waste of computing resources and affecting relational databases. System query performance.
发明内容Contents of the invention
本申请的多个方面提供一种数据库操作语句优化及数据库操作方法、设备及介质,用以优化数据库操作语句,提高数据库系统的查询性能。Various aspects of the present application provide a database operation statement optimization and a database operation method, device and medium, which are used to optimize the database operation statement and improve the query performance of the database system.
本申请实施例提供一种数据库操作语句优化方法,包括:构建数据库操作语句中的至少一个表达式对应的抽象语法树;利用至少一个抽象语法树,从至少一个子表达式中选择公共子表达式,至少一个子表达式来源于至少一个表达式;将至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化数据库操作语句,公共子表达式的执行结果标记用于指示在代码执行阶段复用运行公共子表达式对应的子执行代码得到的执行结果。An embodiment of the present application provides a method for optimizing a database operation statement, including: constructing an abstract syntax tree corresponding to at least one expression in the database operation statement; using at least one abstract syntax tree to select a common subexpression from at least one subexpression , at least one subexpression is derived from at least one expression; the common subexpression in at least one expression is replaced by the execution result mark of the common subexpression to optimize the database operation statement, and the execution result mark of the common subexpression is denoted by Indicates the execution result obtained by reusing the sub-execution code corresponding to the common sub-expression in the code execution phase.
本申请实施例还提供一种数据库操作方法,包括:根据数据库操作语句的第一抽象语法树生成逻辑执行计划,逻辑执行计划中的至少一个逻辑算子各自包括数据库操作语句中的部分表达式;针对至少一个逻辑算子对应的至少一个表达式,构建至少一个表达式对应的第二抽象语法树;利用至少一个第二抽象语法树,从至少一个子表达式中选择公共子表达式,至少一个子表达式来源于至少一个表达式;将至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化至少一个逻辑算子;根据优化后的至少一个逻辑算子和公共子表达式生成执行代码;运行执行代码以获取数据库操作语句的操作结果,其中,在运行执行代码过程中,根据公共子表达式的执行结果标记复用运行公共子表达式对应的子执行代码得到的执行结果。The embodiment of the present application also provides a database operation method, including: generating a logical execution plan according to the first abstract syntax tree of the database operation statement, at least one logical operator in the logical execution plan each includes a partial expression in the database operation statement; For at least one expression corresponding to at least one logical operator, construct a second abstract syntax tree corresponding to at least one expression; use at least one second abstract syntax tree to select a common subexpression from at least one subexpression, at least one The subexpression is derived from at least one expression; the common subexpression in at least one expression is replaced with the execution result mark of the common subexpression to optimize at least one logical operator; according to the optimized at least one logical operator and The common subexpression generates execution code; run the execution code to obtain the operation result of the database operation statement, wherein, in the process of running the execution code, the sub execution code corresponding to the common subexpression is reused according to the execution result mark of the common subexpression The obtained execution result.
本申请实施例还提供一种电子设备,包括:存储器和处理器;存储器,用于存储计算机程序;处理器耦合至存储器,用于执行计算机程序以用于执行上述方法中的步骤。An embodiment of the present application also provides an electronic device, including: a memory and a processor; the memory is used to store a computer program; the processor is coupled to the memory and used to execute the computer program to perform the steps in the above method.
本申请实施例还提供一种存储有计算机程序的计算机可读存储介质,当计算机程序被处理器执行时,致使处理器能够实现上述方法中的的步骤。The embodiment of the present application also provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the processor can implement the steps in the above method.
在本申请实施例中,基于数据库操作语句中的至少一个表达式对应的抽象语法树,从至少一个子表达式中选择公共子表达式,至少一个子表达式来源于至少一个表达式,并将至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化数据库操作语句。这样,在代码执行阶段,只需执行公共子表达式对应的子执行代码一次即可,在执行到代码中包括公共子表达式的执行结果标记时,复用执行公共子表达式对应的子执行代码所得到的执行结果,进而无需对重复的子表达式进行重复计算,提高了计算效率,节约了计算资源,提升了数据库系统的查询性能。In this embodiment of the present application, based on the abstract syntax tree corresponding to at least one expression in the database operation statement, a common subexpression is selected from at least one subexpression, at least one subexpression is derived from at least one expression, and The common subexpression in at least one expression is replaced with the execution result flag of the common subexpression to optimize the database operation statement. In this way, in the code execution stage, it is only necessary to execute the sub-execution code corresponding to the common sub-expression once, and when the execution result mark of the common sub-expression is included in the code, the sub-execution corresponding to the common sub-expression is reused The execution results obtained by the code do not need to perform repeated calculations on repeated sub-expressions, which improves calculation efficiency, saves calculation resources, and improves the query performance of the database system.
附图说明Description of drawings
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described here are used to provide a further understanding of the application and constitute a part of the application. The schematic embodiments and descriptions of the application are used to explain the application and do not constitute an improper limitation to the application. In the attached picture:
图1为一种示例性的数据库系统的系统架构图;Fig. 1 is a system architecture diagram of an exemplary database system;
图2为本申请实施例提供的一种数据库操作语句优化方法的流程图;Fig. 2 is a flow chart of a method for optimizing a database operation statement provided by an embodiment of the present application;
图3为本申请实施例提供的一种数据库操作方法的流程图;FIG. 3 is a flow chart of a database operation method provided by an embodiment of the present application;
图4为本申请提供的一种数据库操作语句优化装置的结构示意图;Fig. 4 is a schematic structural diagram of a database operation statement optimization device provided by the present application;
图5为本申请提供的一种数据库操作装置的结构示意图;FIG. 5 is a schematic structural diagram of a database operating device provided by the present application;
图6为本申请实施例提供的一种电子设备的结构示意图。FIG. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案和优点更加清楚,下面将结合本申请具体实施例及相应的附图对本申请技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with specific embodiments of the present application and corresponding drawings. Apparently, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the scope of protection of this application.
在本申请的实施例中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的访问关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况,其中A,B可以是单数或者复数。在本申请的文字描述中,字符“/”一般表示前后关联对象是一种“或”的关系。此外,在本申请实施例中,“第一”、“第二”、“第三”、等只是为了区分不同对象的内容而已,并无其它特殊含义。In the embodiments of the present application, "at least one" means one or more, and "multiple" means two or more. "And/or", which describes the access relationship of associated objects, means that there can be three kinds of relationships, for example, A and/or B, which can mean: A exists alone, A and B exist at the same time, and B exists alone. A, B can be singular or plural. In the text description of this application, the character "/" generally indicates that the contextual objects are an "or" relationship. In addition, in the embodiment of the present application, "first", "second", "third", etc. are only used to distinguish the contents of different objects, and have no other special meanings.
通常,逻辑执行计划包括多个逻辑算子,多个逻辑算子中诸如Projection(投影)算子、filter(过滤)算子等逻辑算子需要对SQL语句中的表达式进行计算。当SQL语句包括多个表达式时,多个表达式中出现重复的子表达式的概率较大,对重复的子表达式进行重复计算,计算效率较低,造成计算资源的浪费,影响关系数据库系统的查询性能。Usually, the logical execution plan includes multiple logical operators, among which logical operators such as Projection (projection) operator and filter (filter) operator need to calculate the expression in the SQL statement. When the SQL statement includes multiple expressions, the probability of repeated sub-expressions in multiple expressions is high, and repeated calculations for repeated sub-expressions result in low calculation efficiency, resulting in waste of computing resources and affecting relational databases. System query performance.
基于上述,本申请实施例提供一种数据库操作语句优化及数据库操作方法、设备及介质。在本申请实施例中,基于数据库操作语句中的至少一个表达式对应的抽象语法树,从至少一个子表达式中选择公共子表达式,至少一个子表达式来源于至少一个表达式,并将至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化数据库操作语句。这样,在代码执行阶段,只需执行公共子表达式对应的子执行代码一次即可,在执行到代码中包括公共子表达式的执行结果标记时,复用执行公共子表达式对应的子执行代码所得到的执行结果,进而无需对重复的子表达式进行重复计算,提高了计算效率,节约了计算资源,提升了数据库系统的查询性能。Based on the foregoing, embodiments of the present application provide a database operation statement optimization and database operation method, device, and medium. In this embodiment of the present application, based on the abstract syntax tree corresponding to at least one expression in the database operation statement, a common subexpression is selected from at least one subexpression, at least one subexpression is derived from at least one expression, and The common subexpression in at least one expression is replaced with the execution result flag of the common subexpression to optimize the database operation statement. In this way, in the code execution stage, it is only necessary to execute the sub-execution code corresponding to the common sub-expression once, and when the execution result mark of the common sub-expression is included in the code, the sub-execution corresponding to the common sub-expression is reused The execution results obtained by the code do not need to perform repeated calculations on repeated sub-expressions, which improves calculation efficiency, saves calculation resources, and improves the query performance of the database system.
以下结合附图,详细说明本申请各实施例提供的技术方案。The technical solutions provided by various embodiments of the present application will be described in detail below in conjunction with the accompanying drawings.
图1为一种示例性的数据库系统的系统架构图。参见图1,客户端向数据库系统中的服务器发送诸如SQL语句等各种数据库操作语句,服务器中的管理节点对数据库操作语句进行语法解析,以构建数据库操作语句的抽象语法树,管理节点还基于数据库操作语句的抽象语法树生成逻辑执行计划,逻辑执行计划通常包括多个逻辑算子,诸如Projection(投影)算子、filter(过滤)算子等逻辑算子需要对数据库操作语句中的表达式进行计算。另外,管理节点还负责逻辑执行计划的分配,也即将逻辑执行计划中的各个逻辑算子分配到服务器中的计算节点。计算节点执行所分配到的逻辑算子以对数据库中的数据进行查询、修改或删除等各种操作。FIG. 1 is a system architecture diagram of an exemplary database system. Referring to Figure 1, the client sends various database operation statements such as SQL statements to the server in the database system, and the management node in the server performs syntax analysis on the database operation statement to construct an abstract syntax tree of the database operation statement. The management node is also based on The abstract syntax tree of the database operation statement generates a logical execution plan, and the logical execution plan usually includes multiple logical operators, such as the projection (projection) operator, filter (filter) operator and other logical operators need to understand the expressions in the database operation statement Calculation. In addition, the management node is also responsible for the allocation of the logical execution plan, that is, assigning each logical operator in the logical execution plan to the computing nodes in the server. Computing nodes execute assigned logical operators to perform various operations such as querying, modifying, or deleting data in the database.
表达式是一个或多个值、运算符或函数的组合。以数据库操作语句为SQL语句为例,SQL语句有三种不同类型的SQL表达式,分别为:布尔表达式、数字表达式和日期表达式。SQL布尔表达式基于匹配单个值来获取数据;数字表达式用于在任何查询中执行数学运算;日期表达式返回当前系统日期和时间值。实际应用中,一个表达式可能包括若干个子表达式,子表达式可以理解为表达式中所包含的表达式。数据库操作语句出现重复的子表达式的概率较大,计算节点对重复的子表达式进行重复计算,计算效率较低,造成计算资源的浪费,影响数据库系统的查询性能。为此,很有必要优化数据库操作语句。An expression is a combination of one or more values, operators, or functions. Taking the database operation statement as an SQL statement as an example, the SQL statement has three different types of SQL expressions, namely: Boolean expression, number expression and date expression. SQL Boolean expressions are based on matching a single value to fetch data; Numeric expressions are used to perform mathematical operations in any query; Date expressions return the current system date and time value. In practical applications, an expression may include several sub-expressions, and sub-expressions can be understood as expressions contained in an expression. The probability of repeated sub-expressions in database operation statements is relatively high, and the calculation nodes perform repeated calculations on repeated sub-expressions, resulting in low calculation efficiency, resulting in waste of computing resources and affecting the query performance of the database system. For this reason, it is necessary to optimize the database operation statement.
在本实施例中,客户端、管理节点或计算节点等可以由软件和/或硬件组成。在实现形态上,客户端、管理节点或计算节点等可以是终端设备或服务器。其中,终端设备或服务器可以是硬件也可以是软件。当终端设备为硬件时,终端设备例如为手机、平板电脑、台式计算机、可穿戴式智能设备、智能家居设备等。当终端设备为软件时,其可以安装在上述列举的硬件设备中,此时,终端设备例如为多个软件模块或单个软件模块等,本申请实施例并不限制。服务器可以是硬件也可以是软件。当服务器为硬件时,该服务器为单个服务器或多个服务器组成的分布式服务器集群。当服务器为软件时,可以为多个软件模块或单个软件模块等,本申请实施例并不限制。In this embodiment, the client, the management node, or the computing node may be composed of software and/or hardware. In terms of implementation, the client, management node, or computing node can be a terminal device or a server. Wherein, the terminal device or the server may be hardware or software. When the terminal device is hardware, the terminal device is, for example, a mobile phone, a tablet computer, a desktop computer, a wearable smart device, a smart home device, and the like. When the terminal device is software, it can be installed in the hardware devices listed above. In this case, the terminal device is, for example, multiple software modules or a single software module, which is not limited in this embodiment of the present application. Servers can be hardware or software. When the server is hardware, the server is a single server or a distributed server cluster composed of multiple servers. When the server is software, it may be multiple software modules or a single software module, which is not limited in this embodiment of the present application.
图2为本申请实施例提供的一种数据库操作语句优化方法的流程图。参见图2,该方法可以包括以下步骤:FIG. 2 is a flow chart of a method for optimizing a database operation statement provided by an embodiment of the present application. Referring to Figure 2, the method may include the following steps:
201、构建数据库操作语句中的至少一个表达式对应的抽象语法树。201. Build an abstract syntax tree corresponding to at least one expression in the database operation statement.
202、利用至少一个抽象语法树,从至少一个子表达式中选择公共子表达式,至少一个子表达式来源于至少一个表达式。202. Using at least one abstract syntax tree, select a common subexpression from at least one subexpression, where at least one subexpression originates from at least one expression.
203、将至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化数据库操作语句,公共子表达式的执行结果标记用于指示在代码执行阶段复用运行公共子表达式对应的子执行代码得到的执行结果。203. Replace the common subexpression in at least one expression with the execution result mark of the common subexpression to optimize the database operation statement, and the execution result mark of the common subexpression is used to indicate that the common subexpression can be reused in the code execution stage The execution result obtained by the sub-execution code corresponding to the expression.
在本实施例中,数据库操作语句是指对数据库进行诸如查询表、创建表、修改表等各种操作的语句,对此不做限制。数据库操作语句例如包括但不限于SQL语句。In this embodiment, the database operation statement refers to a statement for performing various operations on the database, such as querying a table, creating a table, modifying a table, etc., and there is no limitation on this. Database operation statements include but not limited to SQL statements, for example.
在本实施例中,待优化的数据库操作语句中的表达式的数量可能为一个或多个,针对数据库操作语句中每个表达式,对该表达式进行语法解析,以构建该表达式的抽象语法树。In this embodiment, the number of expressions in the database operation statement to be optimized may be one or more, and for each expression in the database operation statement, the expression is parsed to construct an abstraction of the expression syntax tree.
在本实施例中,利用数据库操作语句对应的一个或多个抽象语法树,针对数据库操作语句中出现的至少一个表达式,从至少一个表达式所包括的至少一个子表达式中找出公共子表达式,公共子表达式可以理解为在数据库操作语句中多次出现的子表达式。举例来说,出现在同一个SQL语句中的有以下两条表达式:json_extract_0(json_parse(content),'user')user,和json_extract_0(json_parse(content),'action')action,这两条表达式中的公共子表达式为json_parse(content)。In this embodiment, using one or more abstract syntax trees corresponding to the database operation statement, for at least one expression appearing in the database operation statement, a common subexpression is found from at least one subexpression included in the at least one expression. Expressions, common subexpressions can be understood as subexpressions that appear multiple times in database operation statements. For example, the following two expressions appear in the same SQL statement: json_extract_0(json_parse(content),'user')user, and json_extract_0(json_parse(content),'action')action, these two expressions The common subexpression in the formula is json_parse(content).
进一步可选的,为了更加准确地找出公共子表达式,可以抽象语法树中的层级从低到高的顺序遍历抽象语法树中的各个层级,并在遍历过程中更新记录至少一个层级各自对应的至少一个子表达式的映射关系表和记录各个子表达式的引用次数的引用次数记录表,在遍历完全部的抽象语法树后,根据引用次数记录表从多个子表达式中找出引用次数较多的公共子表达式。Further optionally, in order to find out common subexpressions more accurately, each level in the abstract syntax tree can be traversed in order from low to high in the level of the abstract syntax tree, and at least one level corresponding to each level can be updated during the traversal process. The mapping relationship table of at least one sub-expression and the reference count record table that records the reference count of each sub-expression, after traversing the entire abstract syntax tree, find out the reference count from multiple sub-expressions according to the reference count record table More common subexpressions.
示例性的,抽象语法树中的叶子节点的层级最低,以及父节点的层级比子节点的层级高一个层级。相应地,利用至少一个抽象语法树,从至少一个子表达式中选择公共子表达式的一种实现方式为:针对至少一个抽象语法树中的任意抽象语法树,按照层级从低到高的顺序遍历抽象语法树中的各个层级,并针对遍历到的当前层级中节点对应的第一子表达式,根据当前层级和第一子表达式查询映射关系表,其中,映射关系表包括至少一个层级各自对应的至少一个子表达式;根据映射关系表的查询结果,更新映射关系表和用于记录各个子表达式的引用次数的引用次数记录表;在至少一个抽象语法树全部处理完毕后,根据引用次数记录表中各个子表达式的引用次数从至少一个子表达式中选择公共子表达式。Exemplarily, the level of the leaf nodes in the abstract syntax tree is the lowest, and the level of the parent node is one level higher than that of the child nodes. Correspondingly, using at least one abstract syntax tree, an implementation manner of selecting a common subexpression from at least one subexpression is: for any abstract syntax tree in the at least one abstract syntax tree, according to the order of the hierarchy from low to high Traverse each level in the abstract syntax tree, and for the first subexpression corresponding to the node in the current level traversed, query the mapping relationship table according to the current level and the first subexpression, wherein the mapping relationship table includes at least one level. Corresponding at least one sub-expression; according to the query result of the mapping relation table, update the mapping relation table and the reference number recording table used to record the reference times of each sub-expression; after at least one abstract syntax tree is all processed, according to the reference The number of references of each subexpression in the count record table selects a common subexpression from at least one subexpression.
实际应用中,在遍历至少一个抽象语法树中时,可以从未被选择过的至少一个抽象语法树中选择当前抽象语法树;按照层级从低到高的顺序遍历当前抽象语法树中的各个层级,并针对遍历到的当前层级中节点对应的第一子表达式,根据当前层级和第一子表达式查询映射关系表,映射关系表包括至少一个层级各自对应的至少一个子表达式;根据映射关系表的查询结果,更新映射关系表和用于记录各个子表达式的引用次数的引用次数记录表,并重复上述步骤直至至少一个抽象语法树均被选择过为止。In practical applications, when traversing at least one abstract syntax tree, the current abstract syntax tree can be selected from at least one abstract syntax tree that has not been selected; each level in the current abstract syntax tree can be traversed in order of levels from low to high , and for the first subexpression corresponding to the node in the current level traversed, query the mapping relationship table according to the current level and the first subexpression, the mapping relationship table includes at least one subexpression corresponding to at least one level; according to the mapping For the query result of the relational table, update the mapping relational table and the reference count recording table for recording the reference count of each subexpression, and repeat the above steps until at least one abstract syntax tree is selected.
示例性的,为了准确找出公共子表达式,根据映射关系表的查询结果,更新映射关系表和用于记录各个子表达式的引用次数的引用次数记录表时,若在映射关系表中查询到当前层级包括第一子表达式,则将引用次数记录表中记录的第一子表达式的引用次数加1;若在映射关系表中未查询到当前层级包括第一子表达式,则将当前层级及第一子表达式关联存储至映射关系表中,并在引用次数记录表记录第一子表达式的引用次数为1。Exemplarily, in order to accurately find out the common subexpression, when updating the mapping relation table and the reference count recording table used to record the reference counts of each subexpression according to the query result of the mapping relation table, if querying in the mapping relation table When the current level includes the first subexpression, add 1 to the reference count of the first subexpression recorded in the reference count record table; if it is not found in the mapping table that the current level includes the first subexpression, then add The current level and the first sub-expression are associated and stored in the mapping relationship table, and the reference count of the first sub-expression is recorded as 1 in the reference count recording table.
在本实施例中,在至少一个抽象语法树全部处理完毕后,可以将引用次数记录表中引用次数大于1的子表达式作为公共子表达式。In this embodiment, after at least one abstract syntax tree is completely processed, a subexpression with a reference count greater than 1 in the reference count recording table may be used as a common subexpression.
进一步可选的,为了更好地优化数据库操作语句,根据引用次数记录表中各个子表达式的引用次数从至少一个子表达式中选择公共子表达式的一种实现方式为:若引用次数记录表中第二子表达式的引用次数和第三子表达式的引用次数相同,则确定第三子表达式为一个公共子表达式,其中,第二子表达式为至少一个子表达式中任一个,第三子表达式对应的节点是第二子表达式对应的节点的父节点。Further optionally, in order to better optimize the database operation statement, an implementation method of selecting a common subexpression from at least one subexpression according to the reference times of each subexpression in the reference count record table is: if the reference count record If the number of references of the second subexpression in the table is the same as that of the third subexpression, it is determined that the third subexpression is a common subexpression, wherein the second subexpression is any of at least one subexpression One, the node corresponding to the third subexpression is the parent node of the node corresponding to the second subexpression.
举例而言,表达式mul(add(add(a,b),c),10)和表达式mul(add(add(a,b),c),20)中的候选公共子表达式有两种,分别为add(a,b)和add(add(a,b),c)。由于子节点对应的add(a,b)的引用次数为2,父节点对应的add(add(a,b),c)的引用次数为2,说明add(a,b)完全嵌套在add(add(a,b),c)中,add(add(a,b),c)是最终的公共子表达式。For example, there are two candidate common subexpressions in the expression mul(add(add(a,b),c),10) and the expression mul(add(add(a,b),c),20). species, respectively add(a,b) and add(add(a,b),c). Since the reference count of add(a,b) corresponding to the child node is 2, and the reference count of add(add(a,b),c) corresponding to the parent node is 2, it means that add(a,b) is completely nested in add (add(a,b),c), add(add(a,b),c) is the final common subexpression.
举例而言,表达式mul(add(add(a,b),c),10)、表达式mul(add(add(a,b),c),20)和表达式mul(add(add(a,b),d),20)。For example, the expressions mul(add(add(a,b),c),10), the expressions mul(add(add(a,b),c),20), and the expressions mul(add(add( a, b), d), 20).
子节点对应的add(a,b)的引用次数为3,父节点1对应的(add(add(a,b),c)的引用次数为2,表示add(a,b)不是完全嵌套在add(add(a,b),c)中,此时无法确定add(a,b)还是(add(add(a,b),c)属于公共子表达式。The reference count of add(a, b) corresponding to the child node is 3, and the reference count of (add(add(a, b), c) corresponding to parent node 1 is 2, indicating that add(a, b) is not completely nested In add(add(a,b),c), it is impossible to determine whether add(a,b) or (add(add(a,b),c) belongs to the common subexpression at this time.
子节点对应的add(a,b)的引用次数为3,父节点2对应的add(add(a,b),d)的引用次数为1,表示add(a,b)不是完全嵌套在add(add(a,b),d)中,此时无法确定add(a,b)还是add(add(a,b),d)属于公共子表达式。The reference count of add(a,b) corresponding to the child node is 3, and the reference count of add(add(a,b),d) corresponding to the parent node 2 is 1, indicating that add(a,b) is not completely nested in In add(add(a,b),d), it is impossible to determine whether add(a,b) or add(add(a,b),d) belongs to the common subexpression at this time.
实际应用中,表达式中可能复杂函数,复杂函数不利于准确找出更多的公共子表达式。进一步可选的,为了准确找出更多的公共子表达式,在利用至少一个抽象语法树,从至少一个表达式包括的至少一个子表达式中选择公共子表达式之前,若第四子表达式中包括复杂函数,第四子表达式是至少一个表达式包括的至少一个子表达式中任一个,则将第四子表达式中的复杂函数替换成复合函数,复合函数能够实现复杂函数的功能,由对复杂函数分解得到的多个简单函数组成。In practical applications, there may be complex functions in expressions, and complex functions are not conducive to accurately finding out more common subexpressions. Further optionally, in order to accurately find out more common subexpressions, before using at least one abstract syntax tree to select a common subexpression from at least one subexpression included in at least one expression, if the fourth subexpression The complex function is included in the formula, and the fourth subexpression is any one of at least one subexpression included in at least one expression, then the complex function in the fourth subexpression is replaced with a composite function, and the composite function can realize the complex function Functions are composed of multiple simple functions obtained by decomposing complex functions.
具体而言,复杂函数往往包含多个子功能,将复杂函数拆分为多个实现子功能的简单函数组成的复合函数。常见的复杂函数包含字符串数据类型操作函数和诸如array(数组)、map、Json(JavaScript Object Notation,JS对象简谱)等复杂数据类型的操作函数。map是key-value(键-值)对格式的数据类型。Specifically, a complex function often includes multiple sub-functions, and the complex function is split into a composite function composed of multiple simple functions that implement the sub-functions. Common complex functions include string data type operation functions and complex data type operation functions such as array (array), map, and Json (JavaScript Object Notation, JS Object Notation). map is a data type in key-value (key-value) pair format.
例如,诸如url_extract_host()、url_extract_path()和url_extract_port()等网络链接处理函数,均需要将字符串转换为URL(Universal Resource Locator,统一资源定位符URL)对象,对这些复杂函数可以拆分为复合函数。其中,url_extract_host()函数从URL中提取Host(主机)信息。url_extract_path()函数从URL中提取访问路径信息。url_extract_port()函数从URL中提取端口信息。For example, network link processing functions such as url_extract_host(), url_extract_path(), and url_extract_port() all need to convert strings into URL (Universal Resource Locator, Uniform Resource Locator URL) objects, and these complex functions can be split into composite function. Among them, the url_extract_host() function extracts the Host (host) information from the URL. The url_extract_path() function extracts the access path information from the URL. The url_extract_port() function extracts port information from a URL.
又例如,json_extract()函数用于提取原始Json字符串中的值,json_extract()函数需要将字符串转换为Json对象,对这样的复杂函数可以拆分为复合函数。以具体的json_extract(content,'user')函数为例,该函数在执行时,需要先把content(字符串)转换为json格式,然后再从json格式的数据中取出user,For another example, the json_extract() function is used to extract the value in the original Json string. The json_extract() function needs to convert the string into a Json object. Such complex functions can be split into composite functions. Take the specific json_extract(content,'user') function as an example. When this function is executed, it needs to convert the content (string) into json format first, and then extract user from the data in json format.
该复杂函数可以拆分为json_extract_0(json_parse(content),'user')user,其中,json_parse(content)表示把content(字符串)转换为json格式。This complex function can be split into json_extract_0(json_parse(content),'user')user, where json_parse(content) means converting content (string) into json format.
又例如,某些函数的返回值是数组类型,提取数组的特定下标元素做一个新字段,这样的下标操作函数执行前均需要构建统一的Array(数组)对象,对这样的复杂函数可以拆分为复合函数。For another example, the return value of some functions is an array type, and the specific subscript elements of the array are extracted to make a new field. Before such subscript operation functions are executed, a unified Array (array) object needs to be constructed. For such complex functions, it is possible to Split into composite functions.
在本实施例中,在从数据库操作语句的至少一个子表达式中找出公共子表达式之后,将至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化数据库操作语句,公共子表达式的执行结果标记用于指示在代码执行阶段复用运行公共子表达式对应的子执行代码得到的执行结果。In this embodiment, after the common subexpression is found out from at least one subexpression of the database operation statement, the common subexpression in at least one expression is replaced with the execution result mark of the common subexpression to optimize In the database operation statement, the execution result flag of the common subexpression is used to indicate the execution result obtained by reusing the sub-execution code corresponding to the common subexpression in the code execution phase.
举例来说,针对表达式json_extract_0(json_parse(content),'user')user,以及表达式json_extract_0(json_parse(content),'action')action。其中,json_parse(content)为公共子表达式。假设公共子表达式标记为cse_exression,该公共子表达式的执行结果标记标记为cse_exression_result。则表达式json_extract_0(json_parse(content),'user')user优化为json_extract_0(cse_exression_result,'user')user,表达式json_extract_0(json_parse(content),'action')action 优化为json_extract_0(cse_exression_result,'action')action。For example, for the expression json_extract_0(json_parse(content),'user')user, and the expression json_extract_0(json_parse(content),'action')action. Among them, json_parse(content) is a common subexpression. Suppose the common subexpression is marked as cse_exression, and the execution result of the common subexpression is marked as cse_exression_result. The expression json_extract_0(json_parse(content),'user')user is optimized to json_extract_0(cse_exression_result,'user')user, and the expression json_extract_0(json_parse(content),'action')action is optimized to json_extract_0(cse_exression_result,'action' ) action.
本申请实施例提供的技术方案,基于数据库操作语句中的至少一个表达式对应的抽象语法树,从至少一个子表达式中选择公共子表达式,至少一个子表达式来源于至少一个表达式,并将至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化数据库操作语句。这样,在代码执行阶段,只需执行公共子表达式对应的子执行代码一次即可,在执行到代码中包括公共子表达式的执行结果标记时,复用执行公共子表达式对应的子执行代码所得到的执行结果,进而无需对重复的子表达式进行重复计算,提高了计算效率,节约了计算资源,提升了数据库系统的查询性能。In the technical solution provided by the embodiment of the present application, based on the abstract syntax tree corresponding to at least one expression in the database operation statement, a common subexpression is selected from at least one subexpression, at least one subexpression is derived from at least one expression, And replace the common subexpression in at least one expression with the execution result flag of the common subexpression, so as to optimize the database operation statement. In this way, in the code execution stage, it is only necessary to execute the sub-execution code corresponding to the common sub-expression once, and when the execution result mark of the common sub-expression is included in the code, the sub-execution corresponding to the common sub-expression is reused The execution results obtained by the code do not need to perform repeated calculations on repeated sub-expressions, which improves calculation efficiency, saves calculation resources, and improves the query performance of the database system.
图3为本申请实施例提供的一种数据库操作方法的流程图。参见图3,该方法可以包括以下步骤:FIG. 3 is a flow chart of a database operation method provided by an embodiment of the present application. Referring to Figure 3, the method may include the following steps:
301、根据数据库操作语句的第一抽象语法树生成逻辑执行计划,逻辑执行计划中的至少一个逻辑算子各自包括数据库操作语句中的部分表达式。301. Generate a logical execution plan according to the first abstract syntax tree of the database operation statement, where at least one logical operator in the logical execution plan includes a partial expression in the database operation statement.
302、针对至少一个逻辑算子对应的至少一个表达式,构建至少一个表达式对应的第二抽象语法树。302. For at least one expression corresponding to at least one logical operator, construct a second abstract syntax tree corresponding to the at least one expression.
303、利用至少一个第二抽象语法树,从至少一个子表达式中选择公共子表达式,至少一个子表达式来源于至少一个表达式。303. Using at least one second abstract syntax tree, select a common subexpression from at least one subexpression, where at least one subexpression originates from at least one expression.
304、将至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化至少一个逻辑算子。304. Replace the common subexpression in the at least one expression with the execution result flag of the common subexpression, so as to optimize at least one logical operator.
305、根据优化后的至少一个逻辑算子和公共子表达式生成执行代码。305. Generate execution code according to the optimized at least one logical operator and common subexpression.
306、运行执行代码以获取数据库操作语句的操作结果,其中,在运行执行代码过程中,根据公共子表达式的执行结果标记复用运行公共子表达式对应的子执行代码得到的执行结果。306. Run the execution code to obtain the operation result of the database operation statement, wherein, during the execution code execution process, multiplex the execution result obtained by running the sub-execution code corresponding to the common sub-expression according to the execution result flag of the common sub-expression.
在本实施例中,对待执行的数据库操作语句进行语法解析,得到数据库操作语句的抽象语法树,在此将数据库操作语句的抽象语法树称作为第一抽象语法树。根据数据库操作语句的第一抽象语法树生成逻辑执行计划。逻辑执行计划包括若干个逻辑算子,诸如Projection(投影)算子、filter(过滤)算子等逻辑算子包括数据库操作语句中的若干个表达式。In this embodiment, the database operation statement to be executed is parsed to obtain an abstract syntax tree of the database operation statement. Here, the abstract syntax tree of the database operation statement is referred to as the first abstract syntax tree. A logical execution plan is generated according to the first abstract syntax tree of the database operation statement. The logical execution plan includes several logical operators, such as Projection (projection) operator, filter (filter) operator, etc., including several expressions in the database operation statement.
例如,SQL语句为select json_extract(content,'user')user,json_extract(content,'action')action from log where json_extract(content,'id')='xiaowang'。For example, the SQL statement is select json_extract(content,'user')user,json_extract(content,'action')action from log where json_extract(content,'id')='xiaowang'.
其中,Projection算子包括:json_extract(content,'user')user,以及json_extract(content,'action')action等表达式。扫描(scan)算子包括from log。过滤算子包括json_extract(content,'id')='xiaowang'等表达式。Among them, the Projection operator includes expressions such as: json_extract(content,'user')user, and json_extract(content,'action')action. The scan operator includes from log. Filter operators include expressions such as json_extract(content,'id')='xiaowang'.
进一步可选的,为了准确找出公共子表达式,还可以对逻辑算子包括的表达式中的复杂函数进行拆分。也即针对表达式中的子表达式,若该子表达式包括复杂函数,将子表达式中的复杂函数替换成复合函数,复合函数能够实现复杂函数的功能,由对复杂函数分解得到的多个简单函数组成。Further optionally, in order to accurately find common subexpressions, complex functions in expressions included in logical operators may also be split. That is, for the sub-expression in the expression, if the sub-expression includes a complex function, replace the complex function in the sub-expression with a compound function. The compound function can realize the function of the complex function. composed of simple functions.
例如,复杂函数json_extract()拆分为json_extract_0(json_parse(),)。于是,For example, the complex function json_extract() is split into json_extract_0(json_parse(),). then,
投影算子中的表达式json_extract(content,'user')user替换为json_extract_0(json_parse(content),'user')user。投影算子中的表达式json_extract(content,'action')action替换为json_extract_0(json_parse(content),'action')action。过滤算子中的表达式json_extract(content,'id')='xiaowang'替换为json_extract_0(json_parse(content),'id')='xiaowang'。The expression json_extract(content,'user')user in the projection operator is replaced with json_extract_0(json_parse(content),'user')user. The expression json_extract(content,'action')action in the projection operator is replaced by json_extract_0(json_parse(content),'action')action. The expression json_extract(content,'id')='xiaowang' in the filter operator is replaced by json_extract_0(json_parse(content),'id')='xiaowang'.
在本实施例中,针对至少一个逻辑算子对应的至少一个表达式,构建至少一个表达式各自对应的抽象语法树,在此将表达式对应的抽象语法树称作为第二抽象语法树。关于基于至少一个表达式各自对应的抽象语法树从至少一个子表达式中选择公共子表达式的方式可以参见前述实施例的相关介绍,在此不再赘述。In this embodiment, for at least one expression corresponding to at least one logical operator, an abstract syntax tree corresponding to at least one expression is constructed, and the abstract syntax tree corresponding to the expression is referred to as a second abstract syntax tree herein. Regarding the manner of selecting a common subexpression from at least one subexpression based on the abstract syntax tree corresponding to each of the at least one expression, reference may be made to relevant introductions in the foregoing embodiments, and details are not repeated here.
在本实施例中,在找出公共子表达式后,将逻辑算子包括的至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化至少一个逻辑算子。例如,假设公共子表达式的json_parse(content)记为cse_exression,该公共子表达式的执行结果标记标记为cse_exression_result。In this embodiment, after the common subexpression is found, the common subexpression in at least one expression included in the logical operator is replaced with the execution result flag of the common subexpression, so as to optimize at least one logical operator. For example, assuming that the json_parse(content) of the common subexpression is recorded as cse_exression, the execution result of the common subexpression is marked as cse_exression_result.
于是,投影算子中的表达式json_extract_0(json_parse(content),'user')user替换为json_extract_0(cse_exression_result,'user')user。投影算子中的表达式json_extract_0(json_parse(content),'action')action 替换为json_extract_0(cse_exression_result,'action')action 。过滤算子中的表达式json_extract_0(json_parse(content),'id')='xiaowang' 替换为json_extract_0(cse_exression_result,'id')='xiaowang'。Therefore, the expression json_extract_0(json_parse(content),'user')user in the projection operator is replaced by json_extract_0(cse_exression_result,'user')user. The expression json_extract_0(json_parse(content),'action')action in the projection operator is replaced by json_extract_0(cse_exression_result,'action')action. The expression json_extract_0(json_parse(content),'id')='xiaowang' in the filter operator is replaced by json_extract_0(cse_exression_result,'id')='xiaowang'.
在本实施例中,在优化至少一个逻辑算子,可以根据优化后的至少一个逻辑算子和公共子表达式生成执行代码。进一步可选的,可以采用诸如ASM等字节码生成技术对优化后的至少一个逻辑算子中替换后的至少一个表达式和公共子表达式进行编译,得到字节码,在虚拟机的内存中加载字节码,以及将字节码转化为执行代码。其中,ASM是一个功能比较齐全的java字节码操作与分析框架,通过ASM框架,可以动态的生成类或者增强已有类的功能。In this embodiment, after optimizing at least one logical operator, an execution code may be generated according to the optimized at least one logical operator and the common subexpression. Further optionally, a bytecode generation technology such as ASM can be used to compile at least one expression and a common subexpression replaced in at least one logical operator after optimization to obtain a bytecode, which is stored in the memory of the virtual machine Load bytecode in and convert bytecode into executable code. Among them, ASM is a relatively complete java bytecode operation and analysis framework. Through the ASM framework, classes can be dynamically generated or the functions of existing classes can be enhanced.
具体而言,采用字节码模式将字节码动态加载到虚拟机中,有效地避免了虚函数调用,无需整体编译打包,满足了客户需求的实时性。Specifically, the bytecode mode is used to dynamically load the bytecode into the virtual machine, which effectively avoids virtual function calls, does not require overall compilation and packaging, and meets the real-time requirements of customers.
进一步可选的,对字节码定时缓存,在保证内存占用率的前提下,避免了表达式的重复编译和加载,保证了数据库系统的实时性。Optionally, the bytecode is periodically cached, on the premise of ensuring the memory usage rate, avoiding repeated compilation and loading of expressions, and ensuring the real-time performance of the database system.
进一步可选的,在生成字节码时,公共子表达式对应的函数和变量单独生成,并且这些函数和变量采用懒加载的方式在真正使用时动态生成,能够更有效保证公共子表达式对应的子执行代码只执行一次。这样,在存在公共子表达式对应的执行结果的情况下,复用已有的公共子表达式对应的执行结果即可。Optionally, when generating bytecodes, the functions and variables corresponding to public subexpressions are generated separately, and these functions and variables are dynamically generated when they are actually used in a lazy loading manner, which can more effectively ensure that public subexpressions correspond to The sub-execution code is executed only once. In this way, if there is an execution result corresponding to the common subexpression, it is sufficient to reuse the existing execution result corresponding to the common subexpression.
进一步可选的,为了充分应用数据库系统的硬件资源,按照数据源的分片规则,根据公共子表达式所需输入的数据对应的数据源以及优化后的逻辑算子中各个子表达式所需输入的数据对应的数据源,将公共子表达式以及优化后的逻辑算子中各个子表达式分别调度至靠近各自数据源的计算节点执行。在全部的计算节点中,有些计算节点以数据源提供的数据作为输入数据,这样的计算节点可以称作为局部计算阶段的计算节点;有些计算节点以其他计算节点的输出结果作为输入数据,这样的计算节点可以称作为全局计算阶段的计算节点。这样,可以避免所有数据均在同一个计算节点上处理,在保证正确性的前提下,尽量提升并行性。Optionally, in order to make full use of the hardware resources of the database system, according to the sharding rules of the data source, according to the data source corresponding to the input data required by the common sub-expression and the data required by each sub-expression in the optimized logical operator The data source corresponding to the input data dispatches the common sub-expressions and each sub-expression in the optimized logical operator to the computing nodes close to the respective data sources for execution. Among all computing nodes, some computing nodes use the data provided by the data source as input data, such computing nodes can be called computing nodes in the local computing stage; some computing nodes use the output results of other computing nodes as input data, such Computing nodes may be referred to as computing nodes of the global computing stage. In this way, all data can be prevented from being processed on the same computing node, and parallelism can be improved as much as possible under the premise of ensuring correctness.
在本实施例中,在得到数据库操作语句对应的执行代码后,运行执行代码以获取数据库操作语句的操作结果,其中,在运行执行代码过程中,根据公共子表达式的执行结果标记复用运行公共子表达式对应的子执行代码得到的执行结果。举例而言,公共子表达式json_parse(content)对应的子执行代码只需要执行一次,原来需要执行3次。在代码执行阶段,根据json_parse(content)对应的执行结果标记cse_exression_result复用公共子表达式json_parse(content)对应的子执行代码运行一次所得到的执行结果。In this embodiment, after obtaining the execution code corresponding to the database operation statement, run the execution code to obtain the operation result of the database operation statement, wherein, in the process of running the execution code, mark the multiplexing operation according to the execution result of the common subexpression The execution result obtained by the sub-execution code corresponding to the common sub-expression. For example, the sub-execution code corresponding to the common sub-expression json_parse(content) only needs to be executed once, instead of 3 times. In the code execution stage, according to the execution result flag cse_exression_result corresponding to json_parse(content), the execution result obtained by running the sub-execution code corresponding to the common subexpression json_parse(content) once is reused.
本申请实施例提供的技术方案,基于数据库操作语句中的至少一个表达式对应的抽象语法树,从至少一个子表达式中选择公共子表达式,至少一个子表达式来源于至少一个表达式,并将至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化数据库操作语句。这样,在代码执行阶段,只需执行公共子表达式对应的子执行代码一次即可,在执行到代码中包括公共子表达式的执行结果标记时,复用执行公共子表达式对应的子执行代码所得到的执行结果,进而无需对重复的子表达式进行重复计算,提高了计算效率,节约了计算资源,提升了数据库系统的查询性能。In the technical solution provided by the embodiment of the present application, based on the abstract syntax tree corresponding to at least one expression in the database operation statement, a common subexpression is selected from at least one subexpression, at least one subexpression is derived from at least one expression, And replace the common subexpression in at least one expression with the execution result flag of the common subexpression, so as to optimize the database operation statement. In this way, in the code execution stage, it is only necessary to execute the sub-execution code corresponding to the common sub-expression once, and when the execution result mark of the common sub-expression is included in the code, the sub-execution corresponding to the common sub-expression is reused The execution results obtained by the code do not need to perform repeated calculations on repeated sub-expressions, which improves calculation efficiency, saves calculation resources, and improves the query performance of the database system.
图4为本申请提供的一种数据库操作语句优化装置的结构示意图。参见图4,该装置可以包括:FIG. 4 is a schematic structural diagram of a database operation statement optimization device provided by the present application. Referring to Figure 4, the device may include:
构建模块41,用于构建数据库操作语句中的至少一个表达式对应的抽象语法树;A
选择模块42,用于利用至少一个抽象语法树,从至少一个子表达式中选择公共子表达式,至少一个子表达式来源于至少一个表达式;A
替换模块43,用于将至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化数据库操作语句,公共子表达式的执行结果标记用于指示在代码执行阶段复用运行公共子表达式对应的子执行代码得到的执行结果。The
进一步可选的,抽象语法树中的叶子节点的层级最低,以及父节点的层级比子节点的层级高一个层级;相应地,选择模块42利用至少一个抽象语法树,从至少一个子表达式中选择公共子表达式时,具体用于:针对至少一个抽象语法树中的任意抽象语法树,按照层级从低到高的顺序遍历抽象语法树中的各个层级,并针对遍历到的当前层级中节点对应的第一子表达式,根据当前层级和第一子表达式查询映射关系表,其中,映射关系表包括至少一个层级各自对应的至少一个子表达式;根据映射关系表的查询结果,更新映射关系表和用于记录各个子表达式的引用次数的引用次数记录表;在至少一个抽象语法树全部处理完毕后,根据引用次数记录表中各个子表达式的引用次数从至少一个子表达式中选择公共子表达式。Further optionally, the level of the leaf node in the abstract syntax tree is the lowest, and the level of the parent node is one level higher than that of the child node; correspondingly, the
进一步可选的,选择模块42根据引用次数记录表中各个子表达式的引用次数从至少一个子表达式中选择公共子表达式时,具体用于:若引用次数记录表中第二子表达式的引用次数和第三子表达式的引用次数相同,则确定第三子表达式为一个公共子表达式,其中,第二子表达式为至少一个子表达式中任一个,第三子表达式对应的节点是第二子表达式对应的节点的父节点。Further optionally, when the
进一步可选的,选择模块42根据映射关系表的查询结果,更新映射关系表和用于记录各个子表达式的引用次数的引用次数记录表时,具体用于:若在映射关系表中查询到当前层级包括第一子表达式,则将引用次数记录表中记录的第一子表达式的引用次数加1;若在映射关系表中未查询到当前层级包括第一子表达式,则将当前层级及第一子表达式关联存储至映射关系表中,并在引用次数记录表记录第一子表达式的引用次数为1。Further optionally, when the
进一步可选的,上述装置还包括复杂函数拆分模块,用于:若第四子表达式中包括复杂函数,第四子表达式是至少一个表达式包括的至少一个子表达式中任一个,则将第四子表达式中的复杂函数替换成复合函数,复合函数由对复杂函数分解得到的多个简单函数组成。Further optionally, the above device further includes a complex function splitting module, configured to: if the fourth sub-expression includes a complex function, the fourth sub-expression is any one of at least one sub-expression included in at least one expression, Then the complex function in the fourth sub-expression is replaced with a compound function, and the compound function is composed of multiple simple functions obtained by decomposing the complex function.
图4所示的装置可以执行图2所示实施例所示的方法,其实现原理和技术效果不再赘述。对于上述实施例中的图4所示的装置其中各个模块、单元执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。The device shown in FIG. 4 can execute the method shown in the embodiment shown in FIG. 2 , and its implementation principles and technical effects will not be repeated here. The specific manner of performing operations of each module and unit in the device shown in FIG. 4 in the above embodiment has been described in detail in the embodiment of the method, and will not be described in detail here.
图5为本申请提供的一种数据库操作装置的结构示意图。参见图5,该装置可以包括:FIG. 5 is a schematic structural diagram of a database operating device provided by the present application. Referring to Figure 5, the device may include:
第一生成模块51,用于根据数据库操作语句的第一抽象语法树生成逻辑执行计划,逻辑执行计划中的至少一个逻辑算子各自包括数据库操作语句中的部分表达式;The
构建模块52,用于针对至少一个逻辑算子对应的至少一个表达式,构建至少一个表达式对应的第二抽象语法树;A
选择模块53,用于利用至少一个第二抽象语法树,从至少一个子表达式中选择公共子表达式,至少一个子表达式来源于至少一个表达式;A
替换模块54,用于将至少一个表达式中的公共子表达式替换为公共子表达式的执行结果标记,以优化至少一个逻辑算子;A
第二生成模块55,用于根据优化后的至少一个逻辑算子和公共子表达式生成执行代码;The
运行模块55,用于运行执行代码以获取数据库操作语句的操作结果,其中,在运行执行代码过程中,根据公共子表达式的执行结果标记复用运行公共子表达式对应的子执行代码得到的执行结果。The running
进一步可选的,第二生成模块55根据优化后的至少一个逻辑算子和公共子表达式生成执行代码时,具体用于:对优化后的至少一个逻辑算子中替换后的表达式和公共子表达式进行编译,得到字节码;在虚拟机的内存中加载字节码,并将字节码转化为执行代码。Further optionally, when the
进一步可选的,上述装置还包括复杂函数拆分模块,用于:针对至少一个表达式中的任意子表达式,若子表达式包括复杂函数,将子表达式中的复杂函数替换成复合函数,复合函数由对复杂函数分解得到的多个简单函数组成。Further optionally, the above device also includes a complex function splitting module, configured to: for any subexpression in at least one expression, if the subexpression includes a complex function, replace the complex function in the subexpression with a composite function, Composite functions are composed of multiple simple functions obtained by decomposing complex functions.
图5所示的装置可以执行图3所示实施例所示的方法,其实现原理和技术效果不再赘述。对于上述实施例中的图3所示的装置其中各个模块、单元执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。The device shown in FIG. 5 can execute the method shown in the embodiment shown in FIG. 3 , and its implementation principles and technical effects will not be described again. The specific manner of performing operations of each module and unit in the apparatus shown in FIG. 3 in the above embodiment has been described in detail in the embodiment of the method, and will not be described in detail here.
需要说明的是,上述实施例所提供方法的各步骤的执行主体均可以是同一设备,或者,该方法也由不同设备作为执行主体。比如,步骤201至步骤203的执行主体可以为设备A;又比如,步骤201和202的执行主体可以为设备A,步骤203的执行主体可以为设备B;等等。It should be noted that the subject of execution of each step of the method provided in the foregoing embodiments may be the same device, or the method may also be executed by different devices. For example, the execution subject of
另外,在上述实施例及附图中的描述的一些流程中,包含了按照特定顺序出现的多个操作,但是应该清楚了解,这些操作可以不按照其在本文中出现的顺序来执行或并行执行,操作的序号如201、202等,仅仅是用于区分开各个不同的操作,序号本身不代表任何的执行顺序。另外,这些流程可以包括更多或更少的操作,并且这些操作可以按顺序执行或并行执行。需要说明的是,本文中的“第一”、“第二”等描述,是用于区分不同的消息、设备、模块等,不代表先后顺序,也不限定“第一”和“第二”是不同的类型。In addition, in some of the processes described in the above embodiments and accompanying drawings, multiple operations appearing in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear herein or executed in parallel , the serial numbers of the operations, such as 201, 202, etc., are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. Additionally, these processes can include more or fewer operations, and these operations can be performed sequentially or in parallel. It should be noted that the descriptions of "first" and "second" in this article are used to distinguish different messages, devices, modules, etc. are different types.
需要说明的是,本申请所涉及的用户信息(包括但不限于用户设备信息、用户个人信息等)和数据(包括但不限于用于分析的数据、存储的数据、展示的数据等),均为经用户授权或者经过各方充分授权的信息和数据,并且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准,并提供有相应的操作入口,供用户选择授权或者拒绝。It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all It is information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose authorization or reject.
图6为本申请实施例提供的一种电子设备的结构示意图。如图6所示,该电子设备包括:存储器61和处理器62;FIG. 6 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As shown in FIG. 6, the electronic device includes: a
存储器61,用于存储计算机程序,并可被配置为存储其它各种数据以支持在计算平台上的操作。这些数据的示例包括用于在计算平台上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。The
存储器61可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(Static Random-AccessMemory,SRAM),电可擦除可编程只读存储器(Electrically Erasable Programmable read only memory,EEPROM),可擦除可编程只读存储器(Erasable Programmable Read Only Memory,EPROM),可编程只读存储器(Programmable read-only memory,PROM),只读存储器(Read-Only Memory,ROM),磁存储器,快闪存储器,磁盘或光盘。
处理器62,与存储器61耦合,用于执行存储器61中的计算机程序,以用于:执行数据库操作语句优化方法或数据库操作方法中的步骤。The
进一步,如图6所示,该电子设备还包括:通信组件63、显示器64、电源组件65、音频组件66等其它组件。图6中仅示意性给出部分组件,并不意味着电子设备只包括图6所示组件。另外,图6中虚线框内的组件为可选组件,而非必选组件,具体可视电子设备的产品形态而定。本实施例的电子设备可以实现为台式电脑、笔记本电脑、智能手机或IOT(物联网,Internet of things)设备等终端设备,也可以是常规服务器、云服务器或服务器阵列等服务端设备。若本实施例的电子设备实现为台式电脑、笔记本电脑、智能手机等终端设备,可以包含图6中虚线框内的组件;若本实施例的电子设备实现为常规服务器、云服务器或服务器阵列等服务端设备,则可以不包含图6中虚线框内的组件。Further, as shown in FIG. 6 , the electronic device further includes: a
关于处理器执行各动作的详细实施过程可参见前述方法实施例或设备实施例中的相关描述,在此不再赘述。For the detailed implementation process of the actions performed by the processor, reference may be made to the relevant descriptions in the foregoing method embodiments or device embodiments, and details are not repeated here.
相应地,本申请实施例还提供一种存储有计算机程序的计算机可读存储介质,计算机程序被执行时能够实现上述方法实施例中可由电子设备执行的各步骤。Correspondingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program. When the computer program is executed, the steps that can be executed by the electronic device in the above method embodiments can be implemented.
相应地,本申请实施例还提供一种计算机程序产品,包括计算机程序/指令,当计算机程序/指令被处理器执行时,致使处理器能够实现上述方法实施例中可由电子设备执行的各步骤。Correspondingly, the embodiments of the present application also provide a computer program product, including computer programs/instructions, which, when executed by a processor, cause the processor to implement the steps executable by the electronic device in the above method embodiments.
上述通信组件被配置为便于通信组件所在设备和其他设备之间有线或无线方式的通信。通信组件所在设备可以接入基于通信标准的无线网络,如WiFi,2G、3G、4G/LTE、5G等移动通信网络,或它们的组合。在一个示例性实施例中,通信组件经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,通信组件还包括近场通信(Near Field Communication,NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(Radio Frequency Identification,RFID)技术,红外数据协会(The InfraredData Association,IrDA)技术,超宽带(Ultra Wide Band,UWB)技术,蓝牙(Bluetooth,BT)技术和其他技术来实现。The above-mentioned communication component is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on communication standards, such as WiFi, 2G, 3G, 4G/LTE, 5G and other mobile communication networks, or a combination thereof. In one exemplary embodiment, the communication component receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be based on Radio Frequency Identification (RFID) technology, Infrared Data Association (The InfraredData Association, IrDA) technology, Ultra Wide Band (Ultra Wide Band, UWB) technology, Bluetooth (Bluetooth, BT) technology and other technology to achieve.
上述显示器包括屏幕,其屏幕可以包括液晶显示器(Liquid Crystal Display,LCD)和触摸面板(touch panel,TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与触摸或滑动操作相关的持续时间和压力。The above-mentioned display includes a screen, and the screen may include a liquid crystal display (Liquid Crystal Display, LCD) and a touch panel (touch panel, TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may not only sense a boundary of a touch or a swipe action, but also detect duration and pressure associated with the touch or swipe operation.
上述电源组件,为电源组件所在设备的各种组件提供电力。电源组件可以包括电源管理系统,一个或多个电源,及其他与为电源组件所在设备生成、管理和分配电力相关联的组件。The above-mentioned power supply component provides power for various components of the equipment where the power supply component is located. A power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply component resides.
上述音频组件,可被配置为输出和/或输入音频信号。例如,音频组件包括一个麦克风(microphone,MIC),当音频组件所在设备处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器或经由通信组件发送。在一些实施例中,音频组件还包括一个扬声器,用于输出音频信号。The aforementioned audio components may be configured to output and/or input audio signals. For example, the audio component includes a microphone (microphone, MIC). When the device where the audio component is located is in an operation mode, such as a calling mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal may be further stored in a memory or sent via a communication component. In some embodiments, the audio component further includes a speaker for outputting audio signals.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可读存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowcharts and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.
在一个典型的配置中,计算设备包括一个或多个处理器(central processingunit,CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more central processing units (CPUs), input/output interfaces, network interfaces, and memory.
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RandomAccess Memory,RAM)和/或非易失性内存等形式,如只读存储器(Read Only Memory,ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。Memory may include non-permanent memory in computer-readable media, random access memory (Random Access Memory, RAM) and/or non-volatile memory, such as read-only memory (Read Only Memory, ROM) or flash memory (flash RAM). Memory is an example of computer readable media.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变化内存(Phase Change RAM,PRAM)、静态随机存取存储器(Static Random-Access Memory,SRAM)、动态随机存取存储器(DynamicRandom Access Memory,DRAM)、其他类型的随机存取存储器(Random Access Memory,RAM)、只读存储器(Read Only Memory,ROM)、电可擦除可编程只读存储器(Electrically-Erasable Programmable Read-Only Memory,EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(Digital versatile disc,DVD)或其他光学存储、磁盒式磁带,磁带磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information. Information may be computer readable instructions, data structures, modules of a program, or other data. The example of the storage medium of computer includes, but not limited to Phase Change RAM (Phase Change RAM, PRAM), Static Random-Access Memory (Static Random-Access Memory, SRAM), Dynamic Random-Access Memory (Dynamic Random-Access Memory, DRAM), Other types of random access memory (Random Access Memory, RAM), read-only memory (Read Only Memory, ROM), electrically erasable programmable read-only memory (Electrically-Erasable Programmable Read-Only Memory, EEPROM), flash RAM or other memory technology, CD-ROM, Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any Other non-transmission media that may be used to store information that can be accessed by a computing device. As defined herein, computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus comprising a set of elements includes not only those elements, but also includes Other elements not expressly listed, or elements inherent in the process, method, commodity, or apparatus are also included. Without further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article or apparatus comprising said element.
以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The above descriptions are only examples of the present application, and are not intended to limit the present application. For those skilled in the art, various modifications and changes may occur in this application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310252269.8A CN116303574A (en) | 2023-03-10 | 2023-03-10 | Database operation statement optimization and database operation method, equipment and medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310252269.8A CN116303574A (en) | 2023-03-10 | 2023-03-10 | Database operation statement optimization and database operation method, equipment and medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN116303574A true CN116303574A (en) | 2023-06-23 |
Family
ID=86797409
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202310252269.8A Pending CN116303574A (en) | 2023-03-10 | 2023-03-10 | Database operation statement optimization and database operation method, equipment and medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN116303574A (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN117493375A (en) * | 2023-11-30 | 2024-02-02 | 北京火山引擎科技有限公司 | A structured query sentence similarity detection method, device and equipment |
| WO2025177076A1 (en) * | 2024-02-22 | 2025-08-28 | 云智能资产控股(新加坡)私人股份有限公司 | Data processing method and apparatus, log query method and apparatus, and electronic device |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101984439A (en) * | 2010-12-09 | 2011-03-09 | 上海市共进通信技术有限公司 | Method for realizing optimization of data source extensive makeup language (XML) query system based on sub-queries |
| CN107798025A (en) * | 2016-09-05 | 2018-03-13 | 华为技术有限公司 | Operation, Compilation Method, device and the Database Systems of storing process |
| CN110704437A (en) * | 2019-09-26 | 2020-01-17 | 上海达梦数据库有限公司 | Method, device, equipment and storage medium for modifying database query statement |
| US20210157814A1 (en) * | 2019-11-21 | 2021-05-27 | Sap Se | Complex query rewriting |
-
2023
- 2023-03-10 CN CN202310252269.8A patent/CN116303574A/en active Pending
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101984439A (en) * | 2010-12-09 | 2011-03-09 | 上海市共进通信技术有限公司 | Method for realizing optimization of data source extensive makeup language (XML) query system based on sub-queries |
| CN107798025A (en) * | 2016-09-05 | 2018-03-13 | 华为技术有限公司 | Operation, Compilation Method, device and the Database Systems of storing process |
| CN110704437A (en) * | 2019-09-26 | 2020-01-17 | 上海达梦数据库有限公司 | Method, device, equipment and storage medium for modifying database query statement |
| US20210157814A1 (en) * | 2019-11-21 | 2021-05-27 | Sap Se | Complex query rewriting |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN117493375A (en) * | 2023-11-30 | 2024-02-02 | 北京火山引擎科技有限公司 | A structured query sentence similarity detection method, device and equipment |
| WO2025177076A1 (en) * | 2024-02-22 | 2025-08-28 | 云智能资产控股(新加坡)私人股份有限公司 | Data processing method and apparatus, log query method and apparatus, and electronic device |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN103164249B (en) | Extension mechanism for script compiler | |
| US9830341B2 (en) | Resource name generation and derivation utilizing attribute space monikers and their associated context | |
| US8959106B2 (en) | Class loading using java data cartridges | |
| US8447744B2 (en) | Extensibility platform using data cartridges | |
| US11068244B2 (en) | Optimized transpilation | |
| CN114281842B (en) | A method and device for querying database partition tables | |
| CN112685433A (en) | Metadata updating method and device, electronic equipment and computer-readable storage medium | |
| CN109492053B (en) | Method and apparatus for accessing data | |
| CN114356964A (en) | Data blood margin construction method and device, storage medium and electronic equipment | |
| CN115599386A (en) | Code generation method, device, equipment and storage medium | |
| CN116303574A (en) | Database operation statement optimization and database operation method, equipment and medium | |
| US12541514B2 (en) | Query processing system for slot-based execution of queries | |
| KR102622018B1 (en) | Apparatus for processing cyber security data, method thereof, and a storage storing a computer-implementable program processing cyber security data | |
| CN110968594B (en) | Database query optimization method, engine and storage medium | |
| CN110928896A (en) | Data query method and device | |
| US20250363106A1 (en) | Database instance processing method and apparatus, electronic device, computer-readable storage medium, and computer program product | |
| WO2023164294A1 (en) | Query splitter for an inverted index datastore | |
| CN113157726B (en) | Database processing method and device | |
| CN117010358A (en) | Message card generation method, device, computer equipment and storage medium | |
| CN114238358A (en) | Data processing method, apparatus, electronic apparatus and medium | |
| US11449461B2 (en) | Metadata-driven distributed dynamic reader and writer | |
| CN115952203B (en) | Data query method, device, system and storage medium | |
| CN118672560A (en) | Language operation method and program product of heterogeneous database | |
| CN115794858A (en) | Query statement processing method, device, equipment and storage medium | |
| CN118132597A (en) | SQL syntax conversion method, device, storage medium and electronic device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |