US 12,405,953 B1
Caching database query plans that include dynamic conditions
Boyang Zhang, Xi'an (CN); Yinghua Ouyang, Xi'an (CN); Zhen Tian, Xi'an (CN); Xun Zhang, Xi'an (CN); and Yanchen Cao, Xi'an (CN)
Assigned to SAP SE, Walldorf (DE)
Filed by SAP SE, Walldorf (DE)
Filed on Aug. 30, 2024, as Appl. No. 18/821,078.
Int. Cl. G06F 16/2453 (2019.01)
CPC G06F 16/24542 (2019.01) [G06F 16/24539 (2019.01)] 20 Claims
OG exemplary drawing
 
1. A computer-implemented method executed by at least one processor, the method comprising:
receiving, by the at least one processor, a request from a device to process a database query for at least one view based on at least one dynamic condition specified in a permission table;
determining, by the at least one processor, whether a query plan cache includes a cached query plan for the database query;
in response to determining that the query plan cache does not include a cached query plan for the database query, triggering, by the at least one processor, query plan compilation for the database query to generate a query plan for the database query; and
in response to determining that the query plan cache includes a cached query plan for the database query:
for each view of the at least one view, invoking, by the at least one processor, a condition provider database procedure executed on a computing device to generate a first filter string from the permission table;
determining, by the at least one processor, whether each first filter string matches a corresponding second filter string in the cached query plan;
in response to determining that at least one first filter string does not match the corresponding second filter string in the cached query plan, triggering, by the at least one processor, query plan compilation for the database query; and
in response to determining that each filter string matches each corresponding second filter string in the cached query plan, executing, by the at least one processor, the database query using the cached query plan without compiling the cached query plan.