IP Library Granted Patent US 12,475,119
Granted Patent B2
US 12,475,119 · App. 17/561,104 · Granted Nov 18, 2025

Operator movement optimization technique for procedures

Inventors: Taeyoung Jeong (Seoul, KR); Kisung Park (Seoul, KR); Chanho Jeong (Seoul, KR); Ki Hong Kim (Seoul, KR); Young-Koo Lee (Seoul, KR); Md Mostofa Kamal Rasel (Dacca, BD)
Assignee: SAP SE
G06F16/24542G06F16/24537
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 12,475,119
App. No.
17/561,104
Granted
Nov 18, 2025
Kind
B2
Abstract

In some embodiments, a method receives a statement graph for a procedure that is used to access data and determines a set of producer statements and a set of consumer statements in the statement graph. A producer statement produces a variable for a consumer statement, and the consumer statement consumes the variable from the producer statement. The method optimizes the statement graph to generate an optimized procedure by moving an operator from a consumer statement to a producer statement or by moving an operator from a producer statement to a consumer statement. The optimized procedure is output based on the optimized statement graph.

Claims (73)

1 . A method comprising:

receiving, by a query processor operating on a computing device, a query to retrieve data from a database, the query comprising software code including a procedure to determine which data to retrieve from the database, wherein the procedure comprises a plurality of statements;

generating, by the query processor operating on the computing device, a control flow graph and a data dependency graph, wherein the control flow graph represents an execution plan for the procedure and the data dependency graph is a directed acyclic graph comprising nodes and edges, wherein the nodes represent one or more of statements, tables, or input parameters and edges represent control dependency between nodes;

determining, by the query processor operating on the computing device, a set of producer statements and a set of consumer statements from the control flow graph and data dependency graph, wherein a producer statement produces a variable for a consumer statement, and the consumer statement consumes the variable from the producer statement;

generating, by the query processor operating on the computing device, a statement graph for the procedure representing relationships between the producer statements and consumer statements;

optimizing, by the query processor operating on the computing device, the statement graph by moving an operator from a consumer statement to a producer statement or by moving an operator from a producer statement to a consumer statement, wherein optimizing further comprises one or more of:

performing an intra-statement transformation to move statements within a single query tree; and

performing an inter-statement transformation comprising one or more safety checks to move statements between a plurality of query trees;

outputting, the query processor operating on the computing device, the optimized procedure based on the optimized statement graph; and

executing the optimized procedure to retrieve data from the database.

2 . The method of claim 1 , wherein receiving the statement graph comprises:

analyzing the procedure to determine statements in the procedure.

3 . The method of claim 2 , wherein analyzing the procedure comprises:

determining the control flow graph for the procedure based on a traversal path of execution from the procedure.

4 . The method of claim 3 , wherein analyzing the procedure comprises:

determining the data flow graph of data through the traversal path, wherein the data flow graph is used to determine whether a statement is a producer statement or a consumer statement.

5 . The method of claim 1 , wherein optimizing the statement graph comprises:

moving the operator from the consumer statement to the producer statement; and

updating a link between another statement and the consumer statement to point to the producer statement.

6 . The method of claim 1 , wherein optimizing the statement graph comprises:

moving the operator from the producer statement to the consumer statement; and

updating a link between another statement and the producer statement to point to the consumer statement.

7 . The method of claim 1 , wherein optimizing the statement graph comprises:

blocking moving the operator from the consumer statement to the producer statement or moving the operator from the producer statement to the consumer statement when a violation of a transformation rule occurs.

8 . The method of claim 1 , wherein optimizing the statement graph comprises:

blocking moving another operator from a consumer statement to a producer statement or moving the another operator from a producer statement to a consumer statement when a variable that is produced by a statement S0 and a statement S1, the variable is consumed by the statement S1 and a statement S2, and the statement S1 updates the value of variable before being consumed by statement S2.

9 . The method of claim 1 , wherein optimizing the statement graph comprises:

blocking moving of another operator from a consumer statement to a producer statement or another moving the another operator from a producer statement to a consumer statement when the moving of the another operator results in a loop head or branch head being empty.

10 . The method of claim 1 , wherein optimizing the statement graph comprises:

determining a first optimization rule; and

moving the operator from the consumer statement to the producer statement or moving the operator from the producer statement to the consumer statement based on the first optimization rule to form a first intermediate plan for the statement graph.

11 . The method of claim 10 , wherein optimizing the statement graph comprises:

determining a second optimization rule; and

moving another operator from a consumer statement to a producer statement or moving the another operator from a producer statement to a consumer statement based on the second optimization rule to form a second intermediate plan for the statement graph.

12 . The method of claim 1 , wherein optimizing the statement graph comprises:

performing an optimization of the procedure based on a plurality of optimization rules to alter the statement graph, wherein the statement graph is iteratively optimized by each optimization rule.

13 . The method of claim 1 , wherein optimizing the statement graph comprises:

performing the intra-statement transformation to move an operator within a statement to transform the operator into an operator that can be moved from the consumer statement to the producer statement or from the producer statement to the consumer statement.

14 . The method of claim 1 , wherein optimizing the statement graph comprises:

determining sibling statements that provide a same variable to a consumer statement; and

performing the intra-statement transformation to move an operator within one of the sibling statements to make the operator movable from the producer statement to the consumer statement or from the consumer statement to the producer statement.

15 . A non-transitory computer-readable storage medium having stored thereon computer executable instructions, which when executed by a computing device, cause the computing device to be operable for:

receiving, by a query processor operating on a computing device, a query to retrieve data from a database, the query comprising software code including a procedure to determine which data to retrieve from the database, wherein the procedure comprises a plurality of statements;

generating, by the query processor operating on the computing device, a control flow graph and a data dependency graph, wherein the control flow graph represents an execution plan for the procedure and the data dependency graph is a directed acyclic graph comprising nodes and edges, wherein the nodes represent one or more of statements, tables, or input parameters and edges represent control dependency between nodes;

determining, by the query processor operating on the computing device, a set of producer statements and a set of consumer statements from the control flow graph and data dependency graph, wherein a producer statement produces a variable for a consumer statement, and the consumer statement consumes the variable from the producer statement;

generating, by the query processor operating on the computing device, a statement graph for the procedure representing relationships between the producer statements and consumer statements;

optimizing, by the query processor operating on the computing device, the statement graph by moving an operator from a consumer statement to a producer statement or by moving an operator from a producer statement to a consumer statement, wherein optimizing further comprises one or more of:

performing an intra-statement transformation to move statements within a single query tree; and

performing an inter-statement transformation comprising one or more safety checks to move statements between a plurality of query trees;

outputting, the query processor operating on the computing device, the optimized procedure based on the optimized statement graph; and

executing the optimized procedure to retrieve data from the database.

16 . The non-transitory computer-readable storage medium of claim 15 , wherein optimizing the statement graph comprises:

moving the operator from the consumer statement to the producer statement; and

updating a link between another statement and the consumer statement to point to the producer statement.

17 . The non-transitory computer-readable storage medium of claim 15 , wherein optimizing the statement graph comprises:

blocking moving another operator from a consumer statement to a producer statement or moving the another operator from a producer statement to a consumer statement when a variable that is produced by a statement S0 and a statement S1, the variable is consumed by the statement S1 and a statement S2, and the statement S1 updates the value of variable before being consumed by statement S2.

18 . The non-transitory computer-readable storage medium of claim 15 , wherein optimizing the statement graph comprises:

determining a first optimization rule;

moving the operator from the consumer statement to the producer statement or moving the operator from the producer statement to the consumer statement based on the first optimization rule to form a first intermediate plan for the statement graph;

determining a second optimization rule; and

moving another operator from a consumer statement to a producer statement or moving the another operator from a producer statement to a consumer statement based on the second optimization rule to form a second intermediate plan for the statement graph.

19 . An apparatus comprising:

one or more computer processors; and

a computer-readable storage medium comprising instructions for controlling the one or more computer processors to be operable for:

receiving, by a query processor operating on a computing device, a query to retrieve data from a database, the query comprising software code including a procedure to determine which data to retrieve from the database, wherein the procedure comprises a plurality of statements;

generating, by the query processor operating on the computing device, a control flow graph and a data dependency graph, wherein the control flow graph represents an execution plan for the procedure and the data dependency graph is a directed acyclic graph comprising nodes and edges, wherein the nodes represent one or more of statements, tables, or input parameters and edges represent control dependency between nodes;

determining, by the query processor operating on the computing device, a set of producer statements and a set of consumer statements from the control flow graph and data dependency graph, wherein a producer statement produces a variable for a consumer statement, and the consumer statement consumes the variable from the producer statement;

generating, by the query processor operating on the computing device, a statement graph for the procedure representing relationships between the producer statements and consumer statements;

optimizing, by the query processor operating on the computing device, the statement graph by moving an operator from a consumer statement to a producer statement or by moving an operator from a producer statement to a consumer statement, wherein optimizing further comprises one or more of:

performing an intra-statement transformation to move statements within a single query tree; and

performing an inter-statement transformation comprising one or more safety checks to move statements between a plurality of query trees;

outputting, the query processor operating on the computing device, the optimized procedure based on the optimized statement graph; and

executing the optimized procedure to retrieve data from the database.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 24, 2021
From: JEONG, TAEYOUNG; PARK, KISUNG; JEONG, CHANHO; KIM, KI HONG; LEE, YOUNG-KOO; RASEL, MD MOSTOFA KAMAL
To: SAP SE
Reel/Frame 058476/0329 →
Continuity (2)
Provisional Application 63231893 · Aug 11, 2021
Related Publication 20230048391A1 · Feb 16, 2023
References Cited (52)
US 8005818B2 · Perry · 2011 [cited by examiner]
US 8661023B1 · Chun · 2014 [cited by examiner]
US 10740514B1 · Zhang · 2020 [cited by examiner]
US 11455152B2 · Zhang · 2022 [cited by examiner]
US 11475005B2 · Vogelsgesang · 2022 [cited by examiner]
US 20080002740A1 · Ramachandran · 2008 [cited by examiner]
US 20100083240A1 · Siman · 2010 [cited by examiner]
US 20120323885A1 · Wang · 2012 [cited by examiner]
US 20140304251A1 · Bornea · 2014 [cited by examiner]
US 20150074034A1 · Ait-Mohktar · 2015 [cited by examiner]
US 20180096166A1 · Rogers · 2018 [cited by examiner]
US 20180121315A1 · Abadi · 2018 [cited by examiner]
US 20180129581A1 · Abadi · 2018 [cited by examiner]
US 20180253473A1 · Ziegler · 2018 [cited by examiner]
US 20190095309A1 · Levit-Gurevich · 2019 [cited by examiner]
US 20190188006A1 · Ritter · 2019 [cited by examiner]
US 20190278771A1 · Bozkaya · 2019 [cited by examiner]
US 20200089491A1 · Sahu · 2020 [cited by examiner]
US 20200142990A1 · Freedman · 2020 [cited by examiner]
US 20200159934A1 · Yamaguchi · 2020 [cited by examiner]
US 20200175102A1 · Sobran · 2020 [cited by examiner]
US 20200218535A1 · Alomari · 2020 [cited by examiner]
US 20200265090A1 · Hilloulin · 2020 [cited by examiner]
US 20200401386A1 · Punathil · 2020 [cited by examiner]
US 20210232390A1 · Hwang · 2021 [cited by examiner]
US 20210241108A1 · Chai · 2021 [cited by examiner]
US 20210263779A1 · Haghighat · 2021 [cited by examiner]
US 20210279338A1 · Bowman · 2021 [cited by examiner]
US 20210286718A1 · Ravindar · 2021 [cited by examiner]
US 20210319023A1 · Ding · 2021 [cited by examiner]
US 20210397148A1 · Ota · 2021 [cited by examiner]
Binnig et al.: “SQL Script: Efficiently Analyzing Big Enterprise Data in SAP HANA”, 20 pages. [cited by applicant]
Chen et al.: “Query Grouping-Based Multi-Query Optimization Framework for Interactive SQL Query Engines on Hadoop”, Apr. 24, 2018, Wileyonlinelibrary.com, 16 pages. [cited by applicant]
Gulyassy et al.: “Material Planning with SAP”, Galileo Press, 2009, 33 pages. [cited by applicant]
Liewen et al.: “A Transformation-Based Approach To Optimizing Loops In Database Programming Languages”, University of Wisconsin, Computer Sciences Department, Jun. 1992, 10 pages. [cited by applicant]
Palkar, et al.: “Weld: A common runtime for high performance data analytics.” CIDR 2017—8th Biennial Conference on Innovative Data Systems Research, 9 pages. [cited by applicant]
Ramachandra et al.: “BlackMagic: Automatic Inlining of Scalar UDFs into SQL Queries with Froid”, Proceedings of the VLDB Endowment, vol. 12, No. 12, 4 pages. [cited by applicant]
Duta et al.: “Compiling PL/SQL Away”, 10th Annual Conference on Innovative Data Systems Research, Jan. 12-15, 2020, 8 pages. [cited by applicant]
Zhou et al.: “Efficient Exploitation of Similar Subexpressions for Query Processing”, SIGMOD, Jun. 12-14, 2007, 12 pages. [cited by applicant]
Silva et al.: “Exploiting Common Subexpressions For Cloud Query Processing”, 12 pages. [cited by applicant]
Emani et al.: “Extracting Equivalent SQL From Imperative Code in Database Applications”, Indian Institute of Technology, SIGMOD, Jun. 26-Jul. 1, 2016, 16 pages. [cited by applicant]
Ramachandra et al.: “Froid: Optimization of Imperative Programs in a Relational Database”, Proceedings of the VLDB Endowment, vol. 11, No. 4, Aug. 2018, 13 pages. [cited by applicant]
Diaconu et al.: “Hekaton: SQL Server's Memory-Optimized OLTP Engine”, SIGMOD, Jun. 22-27, 2013, 12 pages. [cited by applicant]
Cheung et al.: “Inferring SQL Queries Using Program Synthesis”, MIT CSAIL, downloaded Aug. 9, 2012, 12 pages. [cited by applicant]
Park et al.: “Iterative Query Processing Based On Unified Optimization Techniques”, SIGMOD, Jun. 30-Jul. 5, 2019, 15 pages. [cited by applicant]
Mistry et al.: “Materialized View Selection and Maintenance Using Multi-Query Optimization”, Downloaded Mar. 2, 2000, 22 pages. [cited by applicant]
Onizuka et al.: “Optimization for Iterative Queries on MapReduce”, Proceedings of the VLDB Endowment, vol. 7, No. 4, Sep. 1-5, 2014, 12 pages. [cited by applicant]
Cheung et al.: “Optimizing Database-Backed Applications With Query Synthesis”, MIT CSAIL, Jun. 16-19, 2013, 12 pages. [cited by applicant]
Guravannavar et al.: “Rewriting Procedures For Batched Bindings”, VLDB, Aug. 24-30, 2008, 17 pages. [cited by applicant]
Jindal et al.: “Selecting Subexpressions to Materialize at Datacenter Scale”, Proceedings of VLDB Endowment, vol. 11, No. 7, Aug. 2018, 13 pages. [cited by applicant]
Cheung et al.: “Sloth: Being Lazy is a Virtue (When Issuing Database Queries)”, SIGMOD Jun. 22-27, 2014, 12 pages. [cited by applicant]
Meehan et al.: “S-Store: Streaming Meets Transaction Processing”, Proceedings of VLDB Endowment, vol. 8, No. 13, Sep. 5-9, 2016, 12 pages. [cited by applicant]