IP Library › Granted Patent US 11,960,479
Granted Patent B2
US 11,960,479 · App. 18/050,913 · Granted Apr 16, 2024

Processing iterative query constructs in relational databases

Inventors: Yang Sun (Palo Alto, CA); Sofoklis Floratos (Columbus, OH); Ahmad Ghazal (Redondo Beach, CA); Jianjun Chen (Cupertino, CA); Xiaodong Zhang (Columbus, OH)
Assignee: Huawei Technologies Co., Ltd.
G06F16/2425G06F11/3409G06F16/2282G06F16/24544
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,960,479
App. No.
18/050,913
Granted
Apr 16, 2024
Kind
B2
Abstract

A method for functionally rewriting iterative queries for a relational database management system (RDBMS) is provided. The method comprises receiving a first iterative query, the first iterative query having a first non-iterative part that defines a first main table and a first iterative part that generates values in rows of a first working table based on values in rows of the first main table, determining that the first iterative part modifies all of the rows of the first working table, and rewriting the first iterative part, including: adding a renaming operation to rename the first working table to a new first main table and to rename the first main table to a new first working table, adding a first Delete operation to delete each row of the new first working table, and adding a first loop operation to repeat the first iterative part until a first termination condition is met.

Claims (99)

1. A method for functionally rewriting iterative queries for a relational database management system (RDBMS), the method comprising:

receiving a first iterative query, the first iterative query having a first non-iterative part that defines a first main table and a first iterative part that generates values in rows of a first working table based on values in rows of the first main table;

determining that the first iterative part modifies all of the rows of the first working table; and

rewriting the first iterative part including:

adding a renaming operation to rename the first working table to a new first main table and to rename the first main table to a new first working table;

adding a first delete operation to delete each row of the new first working table; and

adding a first loop operation to repeat the first iterative part until a first termination condition is met.

2. The method according to claim 1 , wherein:

the adding of the first loop operation includes adding a first comparison operation and a first branch operation as last operations in the first iterative part;

the first comparison operation is configured to test the first termination condition; and

the first branch operation is configured to:

conditionally branch to a first operation in the first iterative part when the first comparison operation determines that the first termination condition is not met; and

terminate the first iterative part when the first comparison operation determines that the first termination condition is met.

3. The method according to claim 2 , wherein the rewriting of the first iterative part includes adding the first renaming operation and the first delete operation immediately before the first comparison operation.

4. The method according to claim 2 , wherein:

the first termination condition includes a number of iterations to be performed by the first iterative part;

the method further includes rewriting the first non-iterative part to add an operation to initialize a counter; and

the adding of the first comparison operation includes adding an operation to compare a value of the counter to the number of iterations.

5. The method according to claim 2 , wherein:

the first termination condition includes an expression to be evaluated by the first iterative part; and

the adding of the first comparison operation includes adding operations for evaluating the expression to determine whether the first termination condition is met.

6. The method according to claim 2 , wherein:

the first termination condition includes a difference measurement between first values of target entries from the first main table for a previous iteration and second values of the target entries from the first main table for a current iteration;

the rewriting of the first iterative part further comprises adding an operator to store the first values of the target entries from the first main table as a first operation of the first iterative part; and

the adding of the first comparison operation includes adding an operation to determine whether a difference between the second values of the target entries from the first main table and the stored first values of the target entries is less than the difference measurement, wherein the first comparison operation determines whether the first termination condition is met.

7. The method according to claim 1 , further comprising:

receiving a second iterative query including a second a non-iterative part that defines a second main table and a second iterative part that generates values in rows of a second working table based on values in rows of the second main table;

determining that the second iterative part modifies less than all of the rows of the second working table; and

rewriting the second iterative part including:

adding an update operation, to replace corresponding rows in the second main table with the modified rows from the second working table; and

adding a second delete operation to delete each modified row of the second working table.

8. The method according to claim 7 , further comprising:

adding a second comparison operation and a second branch operation as last operations in the second iterative part, wherein:

the second comparison operation is configured to test a second termination condition; and

the second branch operation is configured to:

conditionally branch to a first operation in the second iterative part when the second comparison operation determines that the second termination condition is not met; and

terminate the second iterative part when the second comparison operation determines that the second termination condition is met; and

the rewriting of the second iterative part includes adding the update operation and the second delete operation immediately before the second comparison operation.

9. An apparatus for functionally rewriting iterative queries for a relational database management system (RDBMS), the apparatus comprising:

a memory storing instructions; and

at least one processor in communication with the memory, the at least one processor configured, upon execution of the instructions, to perform the following steps:

receiving a first iterative query, the first iterative query having a first non-iterative part that defines a first main table and a first iterative part that generates values in rows of a first working table based on values in rows of the first main table;

determining that the first iterative part modifies all of the rows of the first working table; and

rewriting the first iterative part including:

adding a renaming operation to rename the first working table to produce a new first main table and to rename the first main table to produce a new first working table;

adding a first delete operation to delete each row of the new first working table; and

adding a first loop operation to repeat the first iterative part until a first termination condition is met.

10. The apparatus according to claim 9 , wherein the adding of the first loop operation includes adding a first comparison operation and a first branch operation as last operations in the first iterative part, wherein:

the first comparison operation is configured to test the first termination condition; and

the first branch operation is configured to:

conditionally branch to a first operation in the first iterative part when the first comparison operation determines that the first termination condition is not met; and

terminate the first iterative part when the first comparison operation determines that the first termination condition is met.

11. The apparatus according to claim 10 , wherein the operation of rewriting the first iterative part includes adding the first renaming operation and the first delete operation immediately before the first comparison operation.

12. The apparatus according to claim 10 , wherein:

the first termination condition includes a number of iterations to be performed by the first iterative part and the operations further include rewriting the first non-iterative part to add an operation to initialize a counter; and

the adding of the first comparison operation includes adding an operation to compare a value of the counter to the number of iterations.

13. The apparatus according to claim 10 , wherein:

the first termination condition includes an expression to be evaluated by the first iterative part; and

the adding of the first comparison operation includes adding operations for evaluating the expression to determine whether the first termination condition is met.

14. The apparatus according to claim 10 , wherein:

the first termination condition includes a difference measurement between first values of target entries in the first main table for a previous iteration and second values of the target entries from the first main table for a current iteration;

the rewriting of the first iterative part further comprises adding an operator to store the first values of the target entries from the first main table as a first operation of the first iterative part; and

the adding of the first comparison operation includes adding an operation to determine whether a difference between the second values of the target entries from the first main table and the stored first values of the target entries is less than the difference measurement, wherein the first comparison operation determines whether the first termination condition is met.

15. The apparatus according to claim 9 , wherein the operations further include:

receiving a second iterative query including a second a non-iterative part that defines a second main table and a second iterative part that generates values of rows of a second working table based on values of rows of the second main table;

determining that the second iterative part modifies less than all of the rows of the second working table; and

rewriting the second iterative part including:

adding an update operation, to replace corresponding rows in the second main table with the modified rows from the second working table; and

adding a second delete operation to delete each modified row of the second working table.

16. The apparatus according to claim 15 , wherein:

the operations further include adding a second loop operation to repeat the second iterative part until a second termination condition is met; and

the rewriting of the second iterative part includes adding the Update operation and the second delete operation immediately before the second loop operation.

17. A non-transitory computer-readable storage medium storing computer instructions for functionally rewriting iterative queries for a relational database management system (RDBMS), that configure at least one processor, upon execution of the instructions, to perform the following steps:

receiving a first iterative query, the first iterative query having a first non-iterative part that defines a first main table and a first iterative part that generates values in rows of a first working table based on values in rows of the first main table;

determining that the first iterative part modifies all of the rows of the first working table; and

rewriting the first iterative part including:

adding a renaming operation to rename the first working table to produce a new first main table and to rename the first main table to produce a new first working table;

adding a first delete operation to delete each row of the new first working table; and

adding a first loop operation to repeat the first iterative part until a first termination condition is met.

18. The computer-readable storage medium according to claim 17 , wherein:

the adding of the first loop operation includes adding a first comparison operation and a first branch operation as last operations in the first iterative part; and

the first comparison operation is configured to:

test the first termination condition; and

the first branch operation is configured to:

conditionally branch to a first operation in the first iterative part when the first comparison operation determines that the first termination condition is not met; and

terminate the first iterative part when the first comparison operation determines that the first termination condition is met.

19. The computer-readable storage medium according to claim 17 , wherein the operations further comprise:

receiving a second iterative query including a second a non-iterative part that defines a second main table and a second iterative part that generates values in rows of a second working table based on values in rows of the second main table;

determining that the second iterative part modifies less than all of the rows of the second working table; and

rewriting the second iterative part including:

adding an update operation, to replace corresponding rows in the second main table with the modified rows from the second working table; and

adding a second delete operation to delete each modified row of the second working table.

20. The computer-readable storage medium according to claim 19 , wherein the operations further comprise:

adding a second comparison operation and a second branch operation as last operations in the second iterative part, wherein:

the second comparison operation is configured to test a second termination condition;

the second branch operation is configured to:

conditionally branch to a first operation in the second iterative part when the second comparison operation determines that the second termination condition is not met; and

terminate the second iterative part when the second comparison operation determines that the second termination condition is met; and

the rewriting of the second iterative part includes adding the update operation and the second delete operation immediately before the second comparison operation.

Assignments (2)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jan 6, 2023
From: SUN, YANG; FLORATOS, SOFOKLIS; GHAZAL, AHMAD; CHEN, JIANJUN; ZHANG, XIAODONG
To: FUTUREWEI TECHNOLOGIES, INC.
Reel/Frame 062298/0043 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jan 6, 2023
From: FUTUREWEI TECHNOLOGIES, INC.
To: HUAWEI TECHNOLOGIES CO., LTD.
Reel/Frame 062298/0804 →
Continuity (2)
Continuation PCTUS2020070011 · Apr 30, 2020
Related Publication 20230083420A1 · Mar 16, 2023