Dynamic rebuilding of query execution trees and reselection of query execution operators

    公开(公告)号:US11720561B2

    公开(公告)日:2023-08-08

    申请号:US17719346

    申请日:2022-04-12

    摘要: A method dynamically selects query execution operators. A database engine receives a query, parses the query to form a query execution tree, and compiles the tree to form a first executable plan that includes in-memory operators. The database engine executes the first plan, including executing in-memory operators in parallel. While executing a first in-memory operator, insufficient memory is detected. In response, the database engine aborts the execution, and recompiles the query tree in two ways, forming a second executable plan that replaces the first in-memory operator with a first spooling operator. The first spooling operator executes within a fixed volatile memory budget and swaps to non-volatile memory according to the budget. A third executable plan retains the first in-memory operator, but schedules it to run serially. The database engine selects either the second plan or the third plan, and executes the selected plan to return results for the query.

    Elimination of query fragment duplication in complex database queries

    公开(公告)号:US11475005B2

    公开(公告)日:2022-10-18

    申请号:US17064490

    申请日:2020-10-06

    IPC分类号: G06F16/2453

    摘要: A database engine includes one or more computing devices, each having one or more processors and memory. The memory stores programs configured for execution by the processors. The database engine receives a database query from a client, and parses the database query to build a query operator tree. The query operator tree includes a plurality of query operators. The database engine performs one or more optimization passes on the query operator tree, including a deduplication optimization pass, to form an optimized execution plan. The deduplication optimization pass includes determining that a first query operator is equivalent to a second query operator during a traversal of the query operator tree, and replacing the second query operator with a link to reuse results from the first query operator. The database engine executes the optimized execution plan to retrieve a result set from the database and returns the result set to the client.

    Dynamic selection of query execution operators

    公开(公告)号:US10521430B1

    公开(公告)日:2019-12-31

    申请号:US15650658

    申请日:2017-07-14

    摘要: A method dynamically selects query execution operators for a database engine. The database engine receives a query and parses the query to form a query execution tree. The engine creates a first executable plan that includes in-memory operators, which execute within the volatile memory. While executing a first in-memory operator, the engine detects insufficient memory to complete the execution and aborts the execution. The engine then recompiles the query execution tree to form a second executable plan, which includes spooling operators. Each spooling operator executes within a fixed volatile memory budget. The engine executes the second executable plan, including the plurality of spooling operators, to identify a set of results from the database that is responsive to the query, and returns the results.

    Adaptive interpretation and compilation of database queries

    公开(公告)号:US11704347B2

    公开(公告)日:2023-07-18

    申请号:US17368767

    申请日:2021-07-06

    IPC分类号: G06F16/00 G06F16/33 G06F16/23

    摘要: A method executes at a computer system to retrieve data from a database. Upon receiving a database query, the computer system translates the query into an intermediate representation, and estimates a compilation time to compile the intermediate representation into machine executable code. The query execution time to retrieve a result set is also estimated. In accordance with a determination that the query execution time and compilation time satisfy an interpretation criterion, the computer system invokes a byte code interpreter to interpret the intermediate representation and retrieve the result set from the database. In accordance with a determination that the query execution and compilation times satisfy one of a plurality of compilation criteria, the computer system compiles the intermediate representation to form machine code and executes the machine code to retrieve the result set from the database. In some cases, the query intermediate representation is optimized prior to compilation.

    Computing domain cardinality estimates for optimizing database query execution

    公开(公告)号:US11514048B2

    公开(公告)日:2022-11-29

    申请号:US17088439

    申请日:2020-11-03

    IPC分类号: G06F16/2453 G06N3/08

    摘要: A method implements optimization of database queries by computing domain cardinality estimates. A client sends a database query to a server. The method parses the query to identify data columns. For each of the data columns, the method computes a lower bound and an upper bound of distinct data values using a pre-computed table size. The method also computes a patch factor by applying a pre-computed function to a ratio between a number of distinct data values that appear exactly once in a data sample and a number of distinct data values in the sample. Based on the patch factor, the lower bound, and the upper bound, the method computes an estimate of distinct values for each of the data columns. The method subsequently generates an execution plan for the query according to the computed estimates, executes the execution plan, and returns a result set to the client.

    Hybrid comparison for unicode text strings consisting primarily of ASCII characters

    公开(公告)号:US11211943B2

    公开(公告)日:2021-12-28

    申请号:US17037505

    申请日:2020-09-29

    摘要: A method compares text strings having Unicode encoding. The method receives a first string S=s1s2 . . . sn and a second string T=t1t2 . . . tm, where s1, s2, . . . , sn and t1, t2, . . . , tm are Unicode characters. The method computes a first string weight for the first string S according to a weight function ƒ. When S consists of ASCII characters, ƒ(S)=S. when S includes one or more non-replaceable non-ASCII characters, the first string weight ƒ(S) is a concatenation of an ASCII weight prefix ƒA(S) and a Unicode weight suffix ƒU(S). The method also computes a second string weight for the second text string T. Equality of the strings is tested using the string weights.

    Adaptive interpretation and compilation of database queries

    公开(公告)号:US11055331B1

    公开(公告)日:2021-07-06

    申请号:US15700023

    申请日:2017-09-08

    IPC分类号: G06F16/00 G06F16/33 G06F16/23

    摘要: A method executes at a computer system to retrieve data from a database. Upon receiving a database query, the computer system translates the query into an intermediate representation, and estimates a compilation time to compile the intermediate representation into machine executable code. The query execution time to retrieve a result set is also estimated. In accordance with a determination that the query execution time and compilation time satisfy an interpretation criterion, the computer system invokes a byte code interpreter to interpret the intermediate representation and retrieve the result set from the database. In accordance with a determination that the query execution and compilation times satisfy one of a plurality of compilation criteria, the computer system compiles the intermediate representation to form machine code and executes the machine code to retrieve the result set from the database. In some cases, the query intermediate representation is optimized prior to compilation.

    Computing Domain Cardinality Estimates for Optimizing Database Query Execution

    公开(公告)号:US20210049176A1

    公开(公告)日:2021-02-18

    申请号:US17088439

    申请日:2020-11-03

    IPC分类号: G06F16/2453 G06N3/08

    摘要: A method implements optimization of database queries by computing domain cardinality estimates. A client sends a database query to a server. The method parses the query to identify data columns. For each of the data columns, the method computes a lower bound and an upper bound of distinct data values using a pre-computed table size. The method also computes a patch factor by applying a pre-computed function to a ratio between a number of distinct data values that appear exactly once in a data sample and a number of distinct data values in the sample. Based on the patch factor, the lower bound, and the upper bound, the method computes an estimate of distinct values for each of the data columns. The method subsequently generates an execution plan for the query according to the computed estimates, executes the execution plan, and returns a result set to the client.

    Hybrid Comparison for Unicode Text Strings Consisting Primarily of ASCII Characters

    公开(公告)号:US20200134254A1

    公开(公告)日:2020-04-30

    申请号:US16726737

    申请日:2019-12-24

    摘要: A method compares text strings having Unicode encoding. The method receives a first string S=s1s2 . . . sn and a second string T=t1t2 . . . tm, where s1, s2, . . . , sn and t1, t2, . . . , tm are Unicode characters. The method computes a first string weight for the first string S according to a weight function ƒ. When S consists of ASCII characters, ƒ(S)=S. When S consists of ASCII characters and some accented ASCII characters that are replaceable by ASCII characters, ƒ(S)=g(s1)g(s2) . . . g(sn), where g(si)=si when si is an ASCII character and g(si)=s′i when si is an accented ASCII character that is replaceable by the corresponding ASCII character s′i. The method also computes a second string weight for the second text string T. Equality of the strings is tested using the string weights.