IP Library Granted Patent US 11,256,697
Granted Patent B2
US 11,256,697 · App. 17/084,840 · Granted Feb 22, 2022

Database query optimization methods, apparatuses, and computer devices

Inventors: Yingying Yao (Hangzhou, CN); Yi Xiao (Hangzhou, CN); Yang Li (Hangzhou, CN); Yi Pan (Hangzhou, CN); Zhiyong Jiang (Hangzhou, CN)
Assignee: Beijing OceanBase Technology Co., Ltd.
G06F16/24544G06F16/2445
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,256,697
App. No.
17/084,840
Granted
Feb 22, 2022
Kind
B2
Abstract

A database query optimization computer-implemented method, medium, and system are disclosed. In one computer-implemented method, a data query request sent by a client device is received and parsed. An execution plan for executing the data query request is determined based on a parsing result. If the execution plan is a nested loop anti-join, whether there is a possibility that a to-be-queried field in a to-be-queried data table indicated by the data query request contains a NULL value is determined. If there is a possibility that the to-be-queried field contains a NULL value, a filter condition is generated and the execution plan is optimized based on the filter condition.

Claims (61)

1. A computer-implemented method for database query optimization, comprising:

receiving a data query request sent by a client device;

obtaining a parsing result by parsing the data query request;

determining, based on the parsing result, that an execution plan for executing the data query request is a nested loop anti-join, wherein the nested loop anti-join comprises a nested loop join algorithm for implementing an anti-join;

in response to determining that the execution plan is the nested loop anti-join, determining that a probability is greater than zero that a to-be-queried field in two to-be-queried data tables indicated by the data query request contains a NULL value, wherein the two to-be-queried data tables comprise a left to-be-queried data table and a right to-be-queried data table, and wherein determining that the probability is greater than zero that the to-be-queried field in the two to-be-queried data tables indicated by the data query request contains a NULL value comprises:

determining a NULL attribute of the to-be-queried field in the two to-be-queried data tables indicated by the data query request; and

in response to determining that the probability is greater than zero that the to-be-queried field contains a NULL value, generating a filter condition and optimizing the execution plan based on the filter condition generated, wherein the filter condition comprises that a field value of a second to-be-queried field in the left to-be-queried data table associated with the data query request comprises a NULL value, wherein the field value is currently traversed to by an outer loop of the nested loop join algorithm, wherein the outer loop traverses the left to-be-queried data table, and wherein the optimizing the execution plan based on the filter condition generated comprises:

if the field value of the second to-be-queried field in the left to-be-queried data table comprises a NULL value, the field value is not output as part of a query result for the data query request.

2. The computer-implemented method of claim 1 , further comprising:

in response to determining that the NULL attribute of the to-be-queried field is in a default state, determining that the probability that the to-be-queried field contains a NULL value is zero, wherein the default state indicates that a value of the to-be-queried field is not allowed to be a NULL value; and

in response to determining that the NULL attribute of the to-be-queried field is in a non-default state, determining that the probability that the to-be-queried field contains a NULL value is greater than zero, wherein the non-default state indicates that the value of the to-be-queried field is allowed to be a NULL value.

3. The computer-implemented method of claim 1 , wherein generating the filter condition comprises:

determining a data representation form of a field value of the to-be-queried field in the two to-be-queried data tables, wherein the data representation form comprises a single-value form or a vector form; and

generating the filter condition based on the data representation form, wherein different data representation forms correspond to different filter conditions.

4. The computer-implemented method of claim 3 , wherein generating the filter condition based on the data representation form comprises:

in response to determining that the data representation form is the single-value form, generating a first filter condition.

5. The computer-implemented method of claim 4 , further comprising:

in response to determining that the data representation form is the vector form, generating a second filter condition.

6. The computer-implemented method of claim 1 , wherein optimizing the execution plan based on the filter condition generated comprises:

applying the filter condition generated as a join condition for inner loop scanning in the nested loop anti-join.

7. A non-transitory, computer-readable medium storing one or more instructions executable by a computer system to perform operations comprising:

receiving a data query request sent by a client device;

obtaining a parsing result by parsing the data query request;

determining, based on the parsing result, that an execution plan for executing the data query request is a nested loop anti-join, wherein the nested loop anti-loin comprises a nested loop loin algorithm for implementing an anti-join;

in response to determining that the execution plan is the nested loop anti-join, determining that a probability is greater than zero that a to-be-queried field in two to-be-queried data tables indicated by the data query request contains a NULL value, wherein the two to-be-queried data tables comprise a left to-be-queried data table and a right to-be-queried data table, and wherein determining that the probability is greater than zero that the to-be-queried field in the two to-be-queried tables indicated by the data query request contains a NULL value comprises:

determining a NULL attribute of the to-be-queried field in the two to-be-queried data tables indicated by the data query request; and

in response to determining that the probability is greater than zero that the to-be-queried field contains a NULL value, generating a filter condition and optimizing the execution plan based on the filter condition generated, wherein the filter condition comprises that a field value of a second to-be-queried field in the left to-be-queried data table associated with the data query request comprises a NULL value, wherein the field value is currently traversed to by an outer loop of the nested loop join algorithm, wherein the outer loop traverses the left to-be-queried data table, and wherein the optimizing the execution plan based on the filter condition generated comprises:

if the field value of the second to-be-queried field in the left to-be-queried data table comprises a NULL value, the field value is not output as part of a query result for the data query request.

8. The non-transitory, computer-readable medium of claim 7 , further comprising:

in response to determining that the NULL attribute of the to-be-queried field is in a default state, determining that the probability that the to-be-queried field contains a NULL value is zero, wherein the default state indicates that a value of the to-be-queried field is not allowed to be a NULL value; and

in response to determining that the NULL attribute of the to-be-queried field is in a non-default state, determining that the probability that the to-be-queried field contains a NULL value is greater than zero, wherein the non-default state indicates that the value of the to-be-queried field is allowed to be a NULL value.

9. The non-transitory, computer-readable medium of claim 7 , wherein generating the filter condition comprises:

determining a data representation form of a field value of the to-be-queried field in the two to-be-queried data tables, wherein the data representation form comprises a single-value form or a vector form; and

generating the filter condition based on the data representation form, wherein different data representation forms correspond to different filter conditions.

10. The non-transitory, computer-readable medium of claim 9 , wherein generating the filter condition based on the data representation form comprises:

in response to determining that the data representation form is the single-value form, generating a first filter condition.

11. The non-transitory, computer-readable medium of claim 10 , further comprising:

in response to determining that the data representation form is the vector form, generating a second filter condition.

12. The non-transitory, computer-readable medium of claim 7 , wherein optimizing the execution plan based on the filter condition generated comprises:

applying the filter condition generated as a join condition for inner loop scanning in the nested loop anti-join.

13. A computer-implemented system, comprising:

one or more computers; and

one or more computer memory devices interoperably coupled with the one or more computers and having tangible, non-transitory, machine-readable media storing one or more instructions that, when executed by the one or more computers, perform one or more operations comprising:

receiving a data query request sent by a client device;

obtaining a parsing result by parsing the data query request;

determining, based on the parsing result, that an execution plan for executing the data query request is a nested loop anti-join, wherein the nested loop anti-loin comprises a nested loop join algorithm for implementing an anti-join;

in response to determining that the execution plan is the nested loop anti-join, determining that a probability is greater than zero that a to-be-queried field in two to-be-queried data tables indicated by the data query request contains a NULL value, wherein the two to-be-queried data tables comprise a left to-be-queried data table and a right to-be-queried data table, and wherein determining that the probability is greater than zero that the to-be-queried field in the two to-be-queried data tables indicated by the data query request contains a NULL value comprises:

determining a NULL attribute of the to-be-queried field in the two to-be-queried data tables indicated by the data query request; and

in response to determining that the probability is greater than zero that the to-be-queried field contains a NULL value, generating a filter condition and optimizing the execution plan based on the filter condition generated, wherein the filter condition comprises that a field value of a second to-be-queried field in the left to-be-queried data table associated with the data query request comprises a NULL value, wherein the field value is currently traversed to by an outer loop of the nested loop loin algorithm, wherein the outer loop traverses the left to-be-queried data table, and wherein the optimizing the execution plan based on the filter condition generated comprises:

if the field value of the second to-be-queried field in the left to-be-queried data table comprises a NULL value, the field value is not output as part of a query result for the data query request.

14. The computer-implemented system of claim 13 , further comprising:

in response to determining that the NULL attribute of the to-be-queried field is in a default state, determining that the probability that the to-be-queried field contains a NULL value is zero, wherein the default state indicates that a value of the to-be-queried field is not allowed to be a NULL value; and

in response to determining that the NULL attribute of the to-be-queried field is in a non-default state, determining that the probability that the to-be-queried field contains a NULL value is greater than zero, wherein the non-default state indicates that the value of the to-be-queried field is allowed to be a NULL value.

15. The computer-implemented system of claim 13 , wherein generating the filter condition comprises:

determining a data representation form of a field value of the to-be-queried field in the two to-be-queried data tables, wherein the data representation form comprises a single-value form or a vector form; and

generating the filter condition based on the data representation form, wherein different data representation forms correspond to different filter conditions.

16. The computer-implemented system of claim 15 , wherein generating the filter condition based on the data representation form comprises:

in response to determining that the data representation form is the single-value form, generating a first filter condition; and

in response to determining that the data representation form is the vector form, generating a second filter condition.

17. The computer-implemented system of claim 13 , wherein optimizing the execution plan based on the filter condition generated comprises:

applying the filter condition generated as a join condition for inner loop scanning in the nested loop anti-join.

Assignments (3)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 27, 2021
From: ANT FINANCIAL (HANG ZHOU) NETWORK TECHNOLOGY CO., LTD.
To: BEIJING OCEANBASE TECHNOLOGY CO., LTD.
Reel/Frame 057349/0070 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Apr 14, 2021
From: YAO, YINGYING; XIAO, YI; LI, YANG; PAN, YI; JIANG, ZHIYONG
To: ADVANCED NEW TECHNOLOGIES CO., LTD.
Reel/Frame 055917/0099 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Feb 11, 2021
From: ADVANCED NEW TECHNOLOGIES CO., LTD.
To: ANT FINANCIAL (HANG ZHOU) NETWORK TECHNOLOGY CO., LTD.
Reel/Frame 055237/0137 →