US 12,135,715 B1
Multi-phase query plan caching
Xuelai Cui, Seattle, WA (US); Prashant Gaharwar, Fremont, CA (US); Vineet Garg, San Jose, CA (US); Boyung Lee, Kirkland, WA (US); Kevin Ye Jie Li, Burnaby (CA); Nicola Dan Onose, San Jose, CA (US); Andrew Xue, San Mateo, CA (US); and Jiaqi Yan, Menlo Park, CA (US)
Assigned to Snowflake Inc., Bozeman, MT (US)
Filed by Snowflake Inc., Bozeman, MT (US)
Filed on Apr. 28, 2023, as Appl. No. 18/309,490.
Int. Cl. G06F 16/30 (2019.01); G06F 11/34 (2006.01); G06F 16/2452 (2019.01); G06F 16/2453 (2019.01)
CPC G06F 16/24542 (2019.01) [G06F 11/3409 (2013.01); G06F 16/24528 (2019.01); G06F 16/24539 (2019.01)] 28 Claims
OG exemplary drawing
 
1. A network-based database system comprising:
at least one hardware processor; and
a memory storing instructions that cause the at least one hardware processor to perform operations comprising:
receiving a query, the query including a statement for performing the query;
performing a first lookup operation on a multi-phase cache based on the query;
performing, in response to a first cache miss of the multi-phase cache, parsing of the statement from the query;
performing, based on the parsing, a compilation process on the query to generate a compiled query plan, the compilation process determining an optimization and a generalization for the query;
determining that the compiled query plan is cacheable;
registering, in response to the compiled query plan being cacheable, a dummy entry in the multi-phase cache;
receiving a second particular query, the second particular query including a second particular statement for performing the second particular query;
performing, in response to a cache miss of the multi-phase cache based on the dummy entry, parsing of the second particular statement from the second particular query;
performing a partial auto-parameterization process based on the parsed second particular statement;
performing a second particular lookup operation on the multi-phase cache based on the partial auto-parameterization process;
determining a set of generalization requirements, the determining based on performing a full auto-parameterization process that generates a modified parse tree with the set of generalization requirements being applied; and
performing the compilation process on the second particular query to generate a compiled second particular query plan, the compilation process using the set of generalization requirements.