IP Library Granted Patent US 12,455,880
Granted Patent B2
US 12,455,880 · App. 18/075,781 · Granted Oct 28, 2025

Intelligent optimization of parameterized queries

Inventors: Taehyung Lee (Seoul, KR); Taeyoung Jeong (Seoul, KR); Taehun Kim (Seoul, KR); Sungwon Kim (Seoul, KR); Sanghee Lee (Seoul, KR)
Assignee: SAP SE
G06F16/2454G06F16/24542
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,455,880
App. No.
18/075,781
Granted
Oct 28, 2025
Kind
B2
Abstract

A computer implemented method can receive a parameterized query written in a declarative language. The parameterized query comprises a parameter which can be assigned different values. The method can perform a first compilation session of the parameterized query in which the parameter has no assigned value. Performing the first compilation session can generate an intermediate representation of the parameterized query. The intermediate representation describes a relational algebra expression to implement the parameterized query. The method can perform a second compilation session of the parameterized query in which parameter has an assigned value. Performing the second compilation session reuses the intermediate representation of the parameterized query.

Claims (52)

1 . A computer-implemented method for improving efficiency of parameterized query optimization, the method comprising:

receiving a parameterized query written in a declarative language, wherein the parameterized query comprises a placeholder which can be assigned different values when the parameterized query is executed;

generating a first query plan, wherein generating the first query plan comprises performing a first compilation session of the parameterized query in which the placeholder has no assigned value, wherein performing the first compilation session comprises:

generating an intermediate representation of the parameterized query, wherein the intermediate representation describes a relational algebra expression to implement the parameterized query; and

generating the first query plan based on the intermediate representation;

serializing the intermediate representation into an abstract query plan; and

generating a second query plan different from the first query plan, wherein generating the second query plan comprises performing a second compilation session of the parameterized query in which the placeholder has an assigned value, wherein performing the second compilation session comprises:

providing the abstract query plan and the assigned value as input to the second compilation session;

deserializing the abstract query plan into the intermediate representation; and

reusing the intermediate representation to generate the second query plan; and

executing the parameterized query using the second query plan.

2 . The method of claim 1 , wherein the intermediate representation represents the parameterized query as a query tree object comprising a plurality of nodes connected by edges, wherein the nodes represent database operations.

3 . The method of claim 1 , wherein the abstract query plan is written in a data exchange format that is transportable between different compilation sessions.

4 . The method of claim 1 , wherein one or more compilation steps of the first compilation session that are used to generate the intermediate representation are skipped in the second compilation session.

5 . The method of claim 4 , wherein the skipped one or more compilation steps operate independently of value assigned to the placeholder.

6 . The method of claim 4 , wherein the skipped one or more compilation steps comprise steps for parsing the parameterized query to generate an abstract syntax tree.

7 . The method of claim 6 , wherein the skipped one or more compilation steps comprise steps for normalizing the abstract syntax tree.

8 . The method of claim 6 , wherein the skipped one or more compilation steps comprise steps for converting the abstract syntax tree to the intermediate representation.

9 . The method of claim 8 , wherein converting the abstract syntax tree to the intermediate representation comprises sequentially applying one or more algebraic transformation rules to the abstract syntax tree.

10 . A computing system for improving efficiency of parameterized query optimization, the system comprising:

memory;

one or more hardware processors coupled to the memory; and

one or more computer readable storage media storing instructions that, when loaded into the memory, cause the one or more hardware processors to perform operations comprising:

receiving a parameterized query written in a declarative language, wherein the parameterized query comprises a placeholder which can be assigned different values when the parameterized query is executed;

generating a first query plan, wherein generating the first query plan comprises performing a first compilation session of the parameterized query in which the placeholder has no assigned value, wherein performing the first compilation session comprises:

generating an intermediate representation of the parameterized query, wherein the intermediate representation describes a relational algebra expression to implement the parameterized query; and

generating the first query plan based on the intermediate representation;

serializing the intermediate representation into an abstract query plan; and

generating a second query plan different from the first query plan, wherein generating the second query plan comprises performing a second compilation session of the parameterized query in which the placeholder has an assigned value, wherein performing the second compilation session comprises:

providing the abstract query plan and the assigned value as input to the second compilation session;

deserializing the abstract query plan into the intermediate representation; and

reusing the intermediate representation to generate the second query plan; and

executing the parameterized query using the second query plan.

11 . The system of claim 10 , wherein the intermediate representation represents the parameterized query as a query tree object comprising a plurality of nodes connected by edges, wherein the nodes represent database operations.

12 . The system of claim 10 , wherein one or more compilation steps of the first compilation session that are used to generate the intermediate representation are skipped in the second compilation session.

13 . The system of claim 12 , wherein the skipped one or more compilation steps operate independently of value assigned to the placeholder.

14 . The system of claim 12 , wherein the skipped one or more compilation steps comprise steps for parsing the parameterized query to generate an abstract syntax tree.

15 . The system of claim 14 , wherein the skipped one or more compilation steps comprise steps for normalizing the abstract syntax tree.

16 . The system of claim 14 , wherein the skipped one or more compilation steps comprise steps for converting the abstract syntax tree to the intermediate representation.

17 . The system of claim 16 , wherein converting the abstract syntax tree to the intermediate representation comprises sequentially applying one or more algebraic transformation rules to the abstract syntax tree.

18 . One or more non-transitory computer-readable media having encoded thereon computer-executable instructions causing one or more processors to perform a method for improving efficiency of parameterized query optimization, the method comprising:

receiving a parameterized query written in a declarative language, wherein the parameterized query comprises a placeholder which can be assigned different values when the parameterized query is executed;

generating a first query plan, wherein generating the first query plan comprises performing a first compilation session of the parameterized query in which the placeholder has no assigned value, wherein performing the first compilation session comprises:

generating an intermediate representation of the parameterized query, wherein the intermediate representation describes a relational algebra expression to implement the parameterized query; and

generating the first query plan based on the intermediate representation;

serializing the intermediate representation into an abstract query plan;

generating a second query plan different from the first query plan, wherein generating the second query plan comprises performing a second compilation session of the parameterized query in which the placeholder has an assigned value;

wherein performing the second compilation session comprises:

providing the abstract query plan and the assigned value as input to the second compilation session;

deserializing the abstract query plan into the intermediate representation, and

reusing the intermediate representation to generate the second query plan; and

executing the parameterized query using the second query plan.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 23, 2022
From: LEE, TAEHYUNG; JEONG, TAEYOUNG; KIM, TAEHUN; KIM, SUNGWON; LEE, SANGHEE
To: SAP SE
Reel/Frame 062195/0457 →
Continuity (2)
Provisional Application 63405711 · Sep 12, 2022
Related Publication 20240086404A1 · Mar 14, 2024
References Cited (24)
US 7933894B2 · Friedman · 2011 [cited by examiner]
US 8224806B2 · Al-Omari · 2012 [cited by examiner]
US 9886477B2 · Jahankhani · 2018 [cited by applicant]
US 20110029508A1 · Al-Omari · 2011 [cited by examiner]
US 20130198232A1 · Shamgunov · 2013 [cited by examiner]
US 20210303571A1 · Chang · 2021 [cited by examiner]
US 20210357407A1 · Bok · 2021 [cited by examiner]
Ioannidis, Yannis E., et al., “Parametric Query Optimization”, The VLDB Journal, vol. 6, May 1997, pp. 132-151. [cited by examiner]
Chaudhuri, Surajit, et al., “Variance Aware Optimization of Parameterized Queries”, SIGMOD '10, Indianapolis, IN, Jun. 6-10, 2010, pp. 531-542. Chaudhuri, Surajit, et al., “Variance Aware Optimization of Parameterized Q… [cited by examiner]
“SAP HANA Performance Guide for Developers”, SAP HANA Platform 2.0 SPS 04, Document Version: 1.1, Oct. 31, 2019, pp. 1-4, 28-34, 117, 134-136, 153, 161, 171 and 242. [cited by examiner]
“Compiler”, Wikipedia, downloaded from: https://en.wikipedia.org/wiki/Compiler on Apr. 9, 2025, pp. 1-18. [cited by examiner]
Ghazal, Ahmad, et al., “Dynamic Plan Generation for Parameterized Queries”, SIGMOD '09, Providence, RI, Jun. 29-Jul. 2, 2009 , pp. 909-915. [cited by examiner]
Microsoft Dictionary, 5th Edition, Microsoft Press, Microsoft Corp., Redmond, WA, © 2002, pp. 185 and 529. [cited by examiner]
“Abstract syntax tree,” Wikipedia, https://en.wikipedia.org/wiki/Abstract_syntax_tree, printed Oct. 5, 2022, 5 pages. [cited by applicant]
Randolf Eilenberger, “Safeguard Performance of ABAP CDS Views—Part 2 HANA SQL Optimizer and Plan Cache,” Safeguard Performance of ABAP CDS Views—Part 2 HANA SQL Optimizer and Plan Cache I SAP Blogs, printed Sep. 21, 202… [cited by applicant]
GE Digital, “Parameterized SQL Queries,” Historian 7.2 Documentation, ttps://www.ge.com/digital/documentation/historian/version72/c_parameterized_sql_queries.html, printed Aug. 29, 2022, 1 page. [cited by applicant]
Microsoft Tech Community, “How and Why to Use Parameterized Queries,” https://techcommunity.microsoft.com/t5/sql-server-blog/how-and-why-to-use-parameterized-queries/ba-p/383483, printed Aug. 29, 2022, 5 pages. [cited by applicant]
SAP, “SAP HANA Performance Guide for Developers, SAP HANA SQL Optimizer” https://help.sap.com/docs/SAP_HANA_PLATFORM/9de0171a6027400bb3b9bee385222eff?locale=en-US&state=PRODUCTION&version=2.0.04, printed Oct. 5, 2022, 1… [cited by applicant]
SAP, “SAP HANA Troubleshooting and Performance Analysis Guide, SQL Plan Stability,” https://help.sap.com/docs/SAP_HANA_PLATFORM/bed8c14f9f024763b0777aa72b5436f6?locale=en-US&state=PRODUCTION&version=2.0.04, printed Oct.… [cited by applicant]
SAP, “Performance and Tuning Series: Query Processing and Abstract Plans,” SAP Adaptive Server Enterprise 16.0 SP04, Aug. 12, 2021, 366 pages. [cited by applicant]
SAP, “Performance and Tuning Series: Query Processing and Abstract Plans, Abstract Query Plan Guide,” https://help.sap.com/docs/SAP_ASE/a7b3e46335184f5caf70a08c91c540f3?locale=en-US&state=PRODUCTION&version=16.0.3.6, pr… [cited by applicant]
“SAP Note 2410208—Collect Explain Plan of a Prepared Statement,” https://www.forosap.com/forum/foros-de-sap/notas-sap/38333-sap-note-2410208-collect-explain-plan-of-a-prepared-statement, printed Sep. 21, 2022, 2 pages. [cited by applicant]
SQLshack, “SQL Server Database Parameterization option and its Query Performance effects,” SQL Server Database Parameterization option and its Query Performance effects (sqlshack.com), printed Aug. 29, 2022, 12 pages. [cited by applicant]
Tae Suk Son, “Protect from performance regression with SQL Plan Stability,” SAP Blogs, https://blogs.sap.com/2018/07/03/protect-from-performance-regression-with-sql-plan-stability/, printed Aug. 29, 2022, 5 pages. [cited by applicant]