US12511288B1ActiveUtility

Ad hoc query batch compilation serialization

54
Assignee: MICROSOFT TECHNOLOGY LICENSING LLCPriority: Nov 29, 2024Filed: Nov 29, 2024Granted: Dec 30, 2025
Est. expiryNov 29, 2044(~18.4 yrs left)· nominal 20-yr term from priority
G06F 16/24549G06F 16/24539
54
PatentIndex Score
0
Cited by
6
References
20
Claims

Abstract

When two ad hoc query batches with the same query text are to be compiled, one locking key is created for both ad hoc query batches. The locking key is allocated to the first ad hoc query batch. In a subsequent cache lookup stage, if no cache is found for the first ad hoc query batch, a plan is compiled for the first ad hoc query batch, and inserted into a cache. The locking key is released and allocated to the second ad hoc query batch. If the locking key for the second ad hoc query batch is the same as for the first ad hoc query batch, the compiled plan is identified in the cache. Plan compilation is bypassed for the second ad hoc query batch.

Claims

exact text as granted — not AI-modified
What is claimed is: 
     
         1 . A computer-implemented method for performing query compilation in a computing network providing database resources, the method comprising:
 in response to determining that two ad hoc query batches with the same query text are to be compiled, generating one locking key for both ad hoc query batches;   allocating the locking key to a first of the ad hoc query batches;   in a subsequent cache lookup stage, in response to determining that no cache is found for the first ad hoc query batch, compiling a plan for the first ad hoc query batch;   inserting the compiled plan into a cache and releasing the locking key;   allocating the locking key to a second of the ad hoc query batches;   determining that the locking key for the second ad hoc query batch is the same as for the first ad hoc query batch and identifying the compiled plan in the cache;   bypassing plan compilation for the second of the ad hoc query batches;   using the compiled plan in the cache to process the second of the ad hoc query batches; and   releasing the locking key for the second of the ad hoc query batches.   
     
     
         2 . The computer-implemented method of  claim 1 , wherein the database resources are SQL resources. 
     
     
         3 . The computer-implemented method of  claim 1 , wherein the method is performed in response to a failover from a primary instance providing the database resources to a secondary instance. 
     
     
         4 . The computer-implemented method of  claim 1 , wherein the ad hoc query batches are batches containing one or more of SELECT, INSERT, UPDATE, DELETE, or MERGE statements, and is not pre-prepared. 
     
     
         5 . The computer-implemented method of  claim 1 , wherein the locking key is generated using a hashing function. 
     
     
         6 . The computer-implemented method of  claim 1 , wherein a same locking key is generated when a same query batch is executed is from different sessions. 
     
     
         7 . The computer-implemented method of  claim 1 , wherein a same query batch being executed with different parameter values creates a same locking key. 
     
     
         8 . A computing device comprising:
 one or more processors;   a memory in communication with the one or more processors, the memory having computer-readable instructions stored thereupon which, when executed by the one or more processors, cause the computing device perform operations for performing query compilation in a computing network providing database resources, the operations comprising:   in response to determining that two ad hoc query batches with the same query text are to be compiled, generating one locking key for both ad hoc query batches;   allocating the locking key to a first of the ad hoc query batches;   in a subsequent cache lookup stage, in response to determining that no cache is found for the first ad hoc query batch, compiling a plan for the first ad hoc query batch;   inserting the compiled plan into a cache and releasing the locking key;   allocating the locking key to a second of the ad hoc query batches;   determining that the locking key for the second ad hoc query batch is the same as for the first ad hoc query batch and identifying the compiled plan in the cache;   bypassing plan compilation for the second of the ad hoc query batches;   using the compiled plan in the cache to process the second of the ad hoc query batches; and   releasing the locking key for the second of the ad hoc query batches.   
     
     
         9 . The computing device of  claim 8 , wherein the database resources are SQL resources. 
     
     
         10 . The computing device of  claim 8 , wherein the operations are performed in response to a failover from a primary instance providing the database resources to a backup instance. 
     
     
         11 . The computing device of  claim 8 , wherein the ad hoc query batches are batches containing one or more of SELECT, INSERT, UPDATE, DELETE, or MERGE statements, and is not pre-prepared. 
     
     
         12 . The computing device of  claim 8 , wherein the locking key is generated using a hashing function. 
     
     
         13 . The computing device of  claim 8 , wherein a same locking key is generated when a same query batch is executed is from different sessions. 
     
     
         14 . The computing device of  claim 8 , wherein a same query batch being executed with different parameter values creates a same locking key. 
     
     
         15 . A computer-readable storage medium comprising computer-readable instructions stored thereupon which, when executed by one or more processors of a computing device, cause the computing device perform operations for performing query compilation in a computing network providing database resources, the operations comprising:
 in response to determining that two ad hoc query batches with the same query text are to be compiled, generating one locking key for both ad hoc query batches;   allocating the locking key to a first of the ad hoc query batches;   in a subsequent cache lookup stage, in response to determining that no cache is found for the first ad hoc query batch, compiling a plan for the first ad hoc query batch;   inserting the compiled plan into a cache and releasing the locking key;   allocating the locking key to a second of the ad hoc query batches;   determining that the locking key for the second ad hoc query batch is the same as for the first ad hoc query batch and identifying the compiled plan in the cache;   bypassing plan compilation for the second of the ad hoc query batches;   using the compiled plan in the cache to process the second of the ad hoc query batches; and   releasing the locking key for the second of the ad hoc query batches.   
     
     
         16 . The computer-readable storage medium of  claim 15 , wherein the database resources are SQL resources. 
     
     
         17 . The computer-readable storage medium of  claim 15 , wherein the operations are performed in response to a failover from a primary instance providing the database resources to a backup instance. 
     
     
         18 . The computer-readable storage medium of  claim 15 , wherein the ad hoc query batches are batches containing one or more of SELECT, INSERT, UPDATE, DELETE, or MERGE statements, and is not pre-prepared. 
     
     
         19 . The computer-readable storage medium of  claim 15 , wherein the locking key is generated using a hashing function. 
     
     
         20 . The computer-readable storage medium of  claim 15 , wherein a same locking key is generated when a same query batch is executed is from different sessions.

Cited by (0)

No later patents cite this yet.

References (0)

No backward citations on record.